52 #if !defined (SERVER_MODE) 64 #if defined (SUPPRESS_STRLEN_WARNING) 65 #define strlen(s1) ((int) strlen(s1)) 74 #define ARE_COMPARABLE(typ1, typ2) \ 76 (QSTR_IS_CHAR(typ1) && QSTR_IS_CHAR(typ2)) || \ 77 (QSTR_IS_NATIONAL_CHAR(typ1) && QSTR_IS_NATIONAL_CHAR(typ2))) 79 #define DBL_MAX_DIGITS ((int)ceil(DBL_MAX_EXP * log10((double) FLT_RADIX))) 81 #define TP_NEAR_MATCH(t1, t2) \ 83 ((t1) == DB_TYPE_CHAR && (t2) == DB_TYPE_VARCHAR) || \ 84 ((t1) == DB_TYPE_VARCHAR && (t2) == DB_TYPE_CHAR) || \ 85 ((t1) == DB_TYPE_NCHAR && (t2) == DB_TYPE_VARNCHAR) || \ 86 ((t1) == DB_TYPE_VARNCHAR && (t2) == DB_TYPE_VARCHAR) || \ 87 ((t1) == DB_TYPE_BIT && (t2) == DB_TYPE_VARBIT) || \ 88 ((t1) == DB_TYPE_VARBIT && (t2) == DB_TYPE_BIT)) 90 #define TP_NUM_MIDXKEY_DOMAIN_LIST (10) 92 #define DB_DATETIMETZ_INITIALIZER { {0, 0}, 0 } 157 #define DOMAIN_INIT \ 167 TP_DOMAIN_COLL_NORMAL, \ 176 #define DOMAIN_INIT2(codeset, coll) \ 184 TP_DOMAIN_COLL_NORMAL, \ 196 #define DOMAIN_INIT3 \ 206 TP_DOMAIN_COLL_NORMAL, \ 215 #define DOMAIN_INIT4(prec, scale) \ 225 TP_DOMAIN_COLL_NORMAL, \ 357 &tp_Midxkey_domain_list_heads[0],
395 &tp_Midxkey_domain_list_heads[0],
396 &tp_Midxkey_domain_list_heads[1],
397 &tp_Midxkey_domain_list_heads[2],
398 &tp_Midxkey_domain_list_heads[3],
399 &tp_Midxkey_domain_list_heads[4],
400 &tp_Midxkey_domain_list_heads[5],
401 &tp_Midxkey_domain_list_heads[6],
402 &tp_Midxkey_domain_list_heads[7],
403 &tp_Midxkey_domain_list_heads[8],
404 &tp_Midxkey_domain_list_heads[9],
550 #if defined (SERVER_MODE) 552 static pthread_mutex_t tp_domain_cache_lock = PTHREAD_MUTEX_INITIALIZER;
558 #if !defined (SERVER_MODE) 563 #if defined(ENABLE_UNUSED_FUNCTION) 564 static int tp_null_terminate (
const DB_VALUE * src,
char **strp,
int str_len,
bool * do_alloc);
575 #if defined(ENABLE_UNUSED_FUNCTION) 576 static char *tp_itoa (
int value,
char *
string,
int radix);
582 static int bfmt_print (
int bfmt,
const DB_VALUE * the_db_bit,
char *
string,
int max_size);
585 bool preserve_domain);
588 #if defined(CUBRID_DEBUG) 589 static void fprint_domain (FILE * fp,
TP_DOMAIN * domain);
624 if (tp_Domain_area ==
NULL)
636 for (i = 0; tp_Domains[
i] !=
NULL; i++)
653 for (i = 1; tp_Midxkey_domains[
i] !=
NULL; i++)
655 d = tp_Midxkey_domains[
i];
679 if (tp_Domain_area ==
NULL)
723 for (i = 0; tp_Domains[
i] !=
NULL; i++)
725 dlist = tp_Domains[
i];
757 for (i = 1; tp_Midxkey_domains[
i] !=
NULL; i++)
759 dlist = tp_Midxkey_domains[
i];
778 if (tp_Domain_area !=
NULL)
781 tp_Domain_area =
NULL;
797 if (enumeration ==
NULL || enumeration->
count == 0)
802 for (i = 0; i < enumeration->
count; i++)
825 if (db_enum1 == db_enum2)
830 if (db_enum1 ==
NULL || db_enum2 ==
NULL)
844 for (i = 0; i < db_enum1->
count; i++)
1077 int fixed_precision;
1085 #if !defined (NDEBUG) 1086 if (precision != fixed_precision)
1091 precision = fixed_precision;
1095 new_dm->
scale = scale;
1099 #if !defined (NDEBUG) 1130 #if defined (SERVER_MODE) 1159 char *dest_str =
NULL;
1203 for (i = 0; i < src->
count; i++)
1213 if (dest_str ==
NULL)
1237 for (--i; i >= 0; i--)
1285 for (d = domain; d !=
NULL; d = d->
next)
1288 if (new_domain ==
NULL)
1339 last->
next = new_domain;
1349 for (d = first; d !=
NULL; d = d->
next)
1370 domain = domain->
next;
1563 #if defined (SERVER_MODE) 1706 int i, dsize1, dsize2;
1713 if (dsize1 == dsize2)
1719 for (i = 0; i < dsize1; i++)
1726 element_dom1 = element_dom1->
next;
1727 element_dom2 = element_dom2->
next;
1858 #if !defined (NDEBUG) 1883 return &(tp_Midxkey_domains[list_index]);
1887 return &(tp_Domains[type]);
1924 if (domain ==
transient)
1970 if (domain->
is_desc == transient->is_desc)
1985 #if defined (SERVER_MODE) 2021 if (domain->
is_desc == transient->is_desc)
2063 if (dsize1 > dsize2)
2068 if (dsize1 == dsize2)
2179 if (dsize1 > dsize2)
2184 if (dsize1 == dsize2)
2190 for (i = 0; i < dsize1; i++)
2198 element_dom1 = element_dom1->
next;
2199 element_dom2 = element_dom2->
next;
2234 if (domain->
precision < transient->precision)
2239 match = ((domain->
precision ==
transient->precision) && (domain->
collation_id == transient->collation_id)
2240 && (domain->
is_desc ==
transient->is_desc)
2249 match = ((domain->
precision >=
transient->precision) && (domain->
collation_id == transient->collation_id)
2250 && (domain->
is_desc ==
transient->is_desc)
2263 match = ((domain->
collation_id ==
transient->collation_id) && (domain->
is_desc == transient->is_desc)
2284 if (domain->
precision < transient->precision)
2289 match = ((domain->
precision ==
transient->precision) && (domain->
is_desc == transient->is_desc));
2297 match = ((domain->
precision >=
transient->precision) && (domain->
is_desc == transient->is_desc));
2309 match = (domain->
is_desc ==
transient->is_desc);
2332 if (domain->
precision > transient->precision)
2337 match = ((domain->
precision ==
transient->precision) && (domain->
is_desc == transient->is_desc));
2352 || domain->
precision >=
transient->precision) && (domain->
is_desc == transient->is_desc));
2371 if (domain->
precision > transient->precision)
2376 match = ((domain->
precision ==
transient->precision) && (domain->
collation_id == transient->collation_id)
2377 && (domain->
is_desc ==
transient->is_desc)
2386 match = ((domain->
collation_id ==
transient->collation_id)
2388 || domain->
precision >=
transient->precision)
2389 && (domain->
is_desc == transient->is_desc)
2411 if (domain->
precision < transient->precision)
2416 match = ((domain->
precision ==
transient->precision) && (domain->
collation_id == transient->collation_id)
2417 && (domain->
is_desc ==
transient->is_desc)
2423 match = ((domain->
collation_id ==
transient->collation_id) && (domain->
is_desc == transient->is_desc)
2443 if (transient->precision == domain->
precision && transient->scale == domain->
scale 2444 && transient->is_desc == domain->
is_desc)
2457 if ((domain->
precision < transient->precision)
2458 || ((domain->
precision == transient->precision) && (domain->
scale < transient->scale)))
2468 match = ((domain->
precision ==
transient->precision) && (domain->
scale == transient->scale)
2469 && (domain->
is_desc ==
transient->is_desc));
2491 if (domain->
is_desc == transient->is_desc)
2503 while (domain !=
NULL)
2523 return (match ? domain :
NULL);
2526 #if !defined (SERVER_MODE) 2694 if (precision < dom->precision)
2756 #if defined (SERVER_MODE) 2814 if (dsize == src_dsize)
2831 if (dsize == src_dsize)
2837 for (i = 0; i < dsize; i++)
2856 for (d2 = setdomain; d2 !=
NULL; d2 = d2->
next)
2864 for (d2 = setdomain; d2 !=
NULL; d2 = d2->
next)
2936 #if defined (SERVER_MODE) 2941 if (
transient ==
NULL || transient->type ==
NULL)
2947 if (transient->is_cached)
2952 #if !defined (SERVER_MODE) 2982 #if defined (SERVER_MODE) 3032 #if defined (SERVER_MODE) 3094 if (type >=
sizeof (tp_Domains) /
sizeof (tp_Domains[0]))
3100 return tp_Domains[type];
3144 resolved_dom = default_dom;
3147 return resolved_dom;
3216 if (midxkey !=
NULL)
3218 domain = midxkey->
domain;
3253 #if !defined (SERVER_MODE) 3377 if (domain->
scale == -1)
3460 #if defined(ENABLE_UNUSED_FUNCTION) 3643 last->
next = domain;
3655 #if !defined (SERVER_MODE) 3781 *dlist = found->
next;
3813 #if !defined (SERVER_MODE) 3822 #if !defined (SERVER_MODE) 3870 int has_object, changes, set_changes, domain_change;
3873 has_object = changes = 0;
3874 if (list_changes !=
NULL)
3879 for (d = dlist, prev =
NULL, next =
NULL; d !=
NULL; d = next)
3925 changes |= set_changes;
3931 if (list_changes !=
NULL)
3933 *list_changes = changes;
3953 strncpy (buffer, domain->
type->
name, maxlen);
3954 buffer[maxlen - 1] =
'\0';
3972 buffer[maxlen - 1] =
'\0';
4014 for (d = dest; d !=
NULL && found ==
NULL; d = d->
next)
4025 for (d = dest; d !=
NULL && found ==
NULL; d = d->
next)
4060 for (d = src; equal && d !=
NULL; d = d->
next)
4062 if (tp_domain_find_compatible (d, dest) ==
NULL)
4141 #if !defined (SERVER_MODE) 4200 #if !defined (SERVER_MODE) 4221 #if !defined (SERVER_MODE) 4270 int val_idx, dom_size, val_size;
4271 const char *dom_str =
NULL, *val_str =
NULL;
4310 if (val_str ==
NULL)
4327 if (dom_str ==
NULL)
4334 if (!ignore_trailing_space)
4338 if (
QSTR_COMPARE (d->collation_id, (
const unsigned char *) dom_str, dom_size,
4339 (
const unsigned char *) val_str, val_size, ti) == 0)
4379 if (best ==
NULL && allow_coercion)
4381 others = tp_Domain_conversion_matrix[vtype];
4384 for (i = 0; others[
i] !=
NULL && best ==
NULL; i++)
4388 if (d->type == others[i]->
type)
4400 #if !defined (SERVER_MODE) 4438 for (d = domain_list; d !=
NULL && best ==
NULL; d = d->
next)
4448 for (d = domain_list; d !=
NULL && best ==
NULL; d = d->
next)
4459 for (d = domain_list; d !=
NULL && best ==
NULL; d = d->
next)
4468 if (best ==
NULL && allow_coercion)
4470 others = tp_Domain_conversion_matrix[type];
4479 for (i = 0; others[
i] !=
NULL && best ==
NULL; i++)
4481 for (d = domain_list; d !=
NULL && best ==
NULL; d = d->
next)
4565 DB_TYPE original_type, desired_type;
4566 int original_length, original_size, desired_precision;
4577 desired_precision = desired_domain->
precision;
4581 if (original_size > desired_precision)
4609 desired_precision = original_length;
4612 switch (desired_type)
4615 return (desired_precision == original_length
4619 return (desired_precision >= original_length
4622 return (desired_precision == original_length
4626 return (desired_precision >= original_length
4629 return (desired_precision == original_length
4632 return (desired_precision >= original_length
4639 #if defined(ENABLE_UNUSED_FUNCTION) 4651 tp_null_terminate (
const DB_VALUE * src,
char **strp,
int str_len,
bool * do_alloc)
4666 if (str[str_size] ==
'\0')
4674 if (str_size >= str_len)
4676 *strp = (
char *) malloc (str_size + 1);
4686 memcpy (*strp, str, str_size);
4687 (*strp)[str_size] =
'\0';
4781 bool dummy_has_zone;
4830 bool dummy_has_zone;
4889 const char *strp =
NULL;
4890 bool do_alloc =
false;
4892 const char *
p, *end;
4904 if (size > 0 && *end)
4916 char *strp_tmp =
NULL;
4919 if (size >
sizeof (str) - 1)
4921 strp_tmp = (
char *) malloc (size + 1);
4922 if (strp_tmp ==
NULL)
4936 memcpy (strp_tmp, p, size);
4938 strp_tmp[size] =
'\0';
4949 char *end_ptr =
NULL;
4952 if (errno == ERANGE)
4995 const char *stre =
NULL;
4998 bool is_negative =
false;
5000 bool is_hex =
false, is_scientific =
false;
5001 bool has_leading_zero =
false;
5017 if (strp != stre && (*strp ==
'-' || *strp ==
'+'))
5019 is_negative = (*strp ==
'-');
5024 is_negative =
false;
5028 if (strp != stre && *strp ==
'0' && (strp + 1) != stre && (*(strp + 1) ==
'x' || *(strp + 1) ==
'X'))
5035 while (strp != stre && *strp ==
'0')
5039 if (!has_leading_zero)
5041 has_leading_zero =
true;
5056 if (p != stre && *p ==
'.')
5067 if (!has_leading_zero && p == strp)
5078 if (*p ==
'e' || *p ==
'E')
5083 if (p != stre && (*p ==
'+' || *p ==
'-'))
5103 is_scientific =
true;
5116 status =
tp_hex_str_to_bi (strp, stre, codeset, is_negative, num_value, data_stat);
5118 else if (is_scientific)
5130 #if defined(ENABLE_UNUSED_FUNCTION) 5139 tp_itoa (
int value,
char *
string,
int radix)
5148 if (radix > 36 || radix <= 1)
5153 sign = (radix == 10 && value < 0);
5161 v = (unsigned) value;
5164 while (v || tp == tmp)
5174 *tp++ = i +
'a' - 10;
5180 string = (
char *) malloc ((tp - tmp) + sign + 1);
5218 if (radix > 36 || radix <= 1)
5223 sign = (radix == 10 && value < 0);
5234 while (v || tp == tmp)
5244 *tp++ = i +
'a' - 10;
5250 string = (
char *) malloc ((tp - tmp) + sign + 1);
5292 assert (new_string && rve);
5296 if (ndigits >= decpt && decpt > -4)
5299 if (decpt > rve - new_string)
5302 while (new_string + decpt > rve)
5309 else if (decpt <= 0)
5313 size_t n_left_pad = +2 - decpt;
5315 char *
p = new_string + n_left_pad;
5320 *rve = *(rve - n_left_pad);
5325 *rve = *(rve - n_left_pad);
5328 while (p != new_string + 1)
5335 else if (decpt != rve - new_string)
5340 while (rve != new_string + decpt)
5351 if (rve > new_string + 1)
5356 while (p != new_string)
5380 *rve++ =
'0' + decpt / 100;
5381 *rve++ =
'0' + decpt % 100 / 10;
5382 *rve++ =
'0' + decpt % 10;
5386 *rve++ =
'0' + decpt / 10;
5387 *rve++ =
'0' + decpt % 10;
5390 *rve++ =
'0' + decpt;
5399 char ch = *new_string;
5401 rve = new_string + 1;
5442 char *str_float, *rve;
5449 if (str_float ==
NULL)
5459 str_float[ndigits] =
'\0';
5513 char *str_double, *rve;
5520 if (str_double ==
NULL)
5528 str_double[ndigits] =
'\0';
5600 #define BITS_IN_BYTE 8 5601 #define HEX_IN_BYTE 2 5602 #define BITS_IN_HEX 4 5604 #define BYTE_COUNT(bit_cnt) (((bit_cnt)+BITS_IN_BYTE-1)/BITS_IN_BYTE) 5605 #define BYTE_COUNT_HEX(bit_cnt) (((bit_cnt)+BITS_IN_HEX-1)/BITS_IN_HEX) 5620 int string_index = 0;
5623 const char *bstring;
5625 static const char digits[16] = {
5626 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
5627 '8',
'9',
'a',
'b',
'c',
'd',
'e',
'f' 5636 if (length + 1 > max_size)
5642 for (byte_index = 0; byte_index <
BYTE_COUNT (length); byte_index++)
5644 for (bit_index = 7; bit_index >= 0 && string_index < length; bit_index--)
5646 *
string = digits[((bstring[byte_index] >> bit_index) & 0x1)];
5662 for (byte_index = 0; byte_index <
BYTE_COUNT (length); byte_index++)
5664 *
string = digits[((bstring[byte_index] >>
BITS_IN_HEX) & 0x0f)];
5669 *
string = digits[((bstring[byte_index] & 0x0f))];
5686 #define ROUND(x) ((x) > 0 ? ((x) + .5) : ((x) - .5)) 5687 #define SECONDS_IN_A_DAY (long)(86400) 5688 #define TP_IS_CHAR_STRING(db_val_type) \ 5689 (db_val_type == DB_TYPE_CHAR || db_val_type == DB_TYPE_VARCHAR || \ 5690 db_val_type == DB_TYPE_NCHAR || db_val_type == DB_TYPE_VARNCHAR) 5692 #define TP_IS_LOB(db_val_type) \ 5693 (db_val_type == DB_TYPE_BLOB || db_val_type == DB_TYPE_CLOB) 5695 #define TP_IS_DATETIME_TYPE(db_val_type) TP_IS_DATE_OR_TIME_TYPE (db_val_type) 5697 #define TP_IMPLICIT_COERCION_NOT_ALLOWED(src_type, dest_type) \ 5698 ((TP_IS_CHAR_STRING(src_type) && !(TP_IS_CHAR_STRING(dest_type) || \ 5699 TP_IS_DATETIME_TYPE(dest_type) || \ 5700 TP_IS_NUMERIC_TYPE(dest_type) || \ 5701 dest_type == DB_TYPE_ENUMERATION)) ||\ 5702 (!TP_IS_CHAR_STRING(src_type) && src_type != DB_TYPE_ENUMERATION && \ 5703 TP_IS_CHAR_STRING(dest_type)) || \ 5704 (TP_IS_LOB(src_type) || TP_IS_LOB(dest_type))) 5728 ret =
tp_atof (value, &dbl, &data_stat);
5751 switch (desired_type)
5809 DB_TYPE desired_type, original_type;
5820 if (desired_domain ==
NULL)
5834 if (desired_type == original_type)
5863 switch (desired_type)
5866 switch (original_type)
5877 if (modf (val, &i) != 0)
5910 if (modff (val, &i) != 0)
5927 if (modf (val, &i) != 0)
5943 double num_value = 0.0,
i = 0.0;
5955 if (modf (num_value, &
i) != 0)
5970 switch (original_type)
5985 if (modf (val, &i) != 0)
6010 if (modff (val, &i) != 0)
6027 if (modf (val, &i) != 0)
6043 double num_value = 0.0,
i = 0.0;
6055 if (modf (num_value, &
i) != 0)
6070 switch (original_type)
6087 if (modf (val, &i) != 0)
6105 if (modff (val, &i) != 0)
6122 if (modf (val, &i) != 0)
6138 double num_value = 0.0,
i = 0.0;
6150 if (modf (num_value, &
i) != 0)
6165 switch (original_type)
6184 double num_value = 0.0;
6208 switch (original_type)
6234 double num_value = 0.0;
6255 switch (original_type)
6289 switch (original_type)
6314 double num_value = 0.0;
6336 switch (original_type)
6359 switch (original_type)
6381 if (src_dt->
time != 0)
6412 tz_id = dt_tz_p->
tz_id;
6421 if (local_dt.
time != 0)
6473 switch (original_type)
6522 datetime.
time = time * 1000;
6523 datetime.
date = date;
6540 datetime.
time = time * 1000;
6541 datetime.
date = date;
6552 switch (original_type)
6646 switch (original_type)
6706 datetime.
time = time * 1000;
6707 datetime.
date = date;
6719 datetime.
time = time * 1000;
6720 datetime.
date = date;
6731 switch (original_type)
6836 switch (original_type)
6941 switch (original_type)
7074 const TP_COERCION_MODE coercion_mode,
bool do_domain_select,
bool preserve_domain)
7076 DB_TYPE desired_type, original_type;
7090 int hour, minute, second, millisecond;
7091 int year, month, day;
7104 if (desired_domain ==
NULL)
7111 if (do_domain_select)
7118 desired_domain = best;
7127 if (preserve_domain)
7139 if (desired_type != original_type && original_type ==
DB_TYPE_JSON)
7146 bool use_replacement =
true;
7150 case DB_JSON_DOUBLE:
7156 case DB_JSON_BIGINT:
7160 switch (desired_type)
7173 case DB_JSON_STRING:
7177 use_replacement =
false;
7182 if (use_replacement)
7191 src = &src_replacement;
7195 if (desired_type == original_type)
7212 switch (desired_type)
7263 if (preserve_domain)
7312 desired_domain = p_tmp_desired_domain;
7329 while (elem_dom !=
NULL)
7332 save_elem_dom_next = elem_dom->
next;
7335 elem_dom->
next = save_elem_dom_next;
7345 elem_dom = elem_dom->
next;
7348 desired_domain = p_tmp_desired_domain;
7379 switch (desired_type)
7382 switch (original_type)
7447 double num_value = 0.0;
7482 switch (original_type)
7520 tmp_int = (int)
ROUND (tmp_float);
7563 double num_value = 0.0;
7598 switch (original_type)
7738 switch (original_type)
7782 double num_value = 0.0;
7817 switch (original_type)
7847 double num_value = 0.0;
7888 switch (original_type)
7936 switch (original_type)
7965 double num_value = 0.0;
8000 switch (original_type)
8040 v_date = v_datetime.
date;
8041 v_time = v_datetime.
time / 1000;
8057 v_date = v_datetime.
date;
8058 v_time = v_datetime.
time / 1000;
8116 switch (original_type)
8151 v_date = v_datetime.
date;
8152 v_time = v_datetime.
time / 1000;
8173 v_date = v_datetime.
date;
8174 v_time = v_datetime.
time / 1000;
8250 switch (original_type)
8287 v_date = v_datetime.
date;
8288 v_time = v_datetime.
time / 1000;
8312 v_date = v_datetime.
date;
8313 v_time = v_datetime.
time / 1000;
8365 switch (original_type)
8402 v_datetime.
date = v_date;
8403 v_datetime.
time = v_time * 1000;
8415 v_datetime.
date = v_date;
8416 v_datetime.
time = v_time * 1000;
8422 v_datetime.
time = 0;
8462 switch (original_type)
8496 v_datetime.
time = v_time * 1000;
8497 v_datetime.
date = v_date;
8504 v_datetime.
time = v_time * 1000;
8505 v_datetime.
date = v_date;
8514 v_datetime.
time = 0;
8546 switch (original_type)
8606 v_datetime.
time = 0;
8646 switch (original_type)
8726 tz_id = dt_tz_p->
tz_id;
8735 db_datetime_decode (&v_datetime, &month, &day, &year, &hour, &minute, &second, &millisecond);
8748 switch (original_type)
8787 db_datetime_decode (&dt_local, &month, &day, &year, &hour, &minute, &second, &millisecond);
8801 db_datetime_decode (&dt_local, &month, &day, &year, &hour, &minute, &second, &millisecond);
8900 #if !defined (SERVER_MODE) 8907 switch (original_type)
8952 if (obj_class == desired_domain->
class_mop)
9067 if (!setref || err < 0)
9089 if (src != dest || !setref)
9105 #if !defined (SERVER_MODE) 9164 switch (original_type)
9172 char *bit_char_string;
9174 int dst_size = (src_size + 1) / 2;
9177 if (bit_char_string)
9277 switch (original_type)
9360 if (
tp_ltoa (num, new_string, 10))
9423 max_size =
strlen (str_buf) + 1;
9425 if (new_string ==
NULL)
9431 strcpy (new_string, str_buf);
9462 new_string[max_size - 1] =
'\0';
9464 p = new_string +
strlen (new_string);
9465 for (--p; p >= new_string && *p ==
'0'; p--)
9508 switch (original_type)
9586 new_string, max_size);
9602 else if (convert_error == -1)
9616 switch (desired_type)
9671 switch (original_type)
9706 switch (original_type)
9735 unsigned short val_idx = 0;
9736 int val_str_size = 0;
9737 const char *val_str =
NULL;
9738 bool exit =
false, alloc_string =
true;
9749 switch (original_type)
9826 val_idx = (
unsigned short) floor (v_money->
amount);
9844 do_domain_select,
false);
9897 if (val_str ==
NULL)
9950 if (val_str !=
NULL)
9957 for (i = 1; i <= elem_count; i++)
9962 if (!ignore_trailing_space)
9978 if (val_str[0] == 0)
9999 else if (val_idx == 0)
10015 const char *enum_str;
10022 alloc_string =
false;
10029 if (enum_str_tmp ==
NULL)
10037 memcpy (enum_str_tmp, val_str, val_str_size);
10038 enum_str_tmp[val_str_size] = 0;
10041 enum_str = enum_str_tmp;
10045 enum_str = val_str;
10060 switch (original_type)
10068 const DB_VALUE *json_str_val = &utf8_str;
10165 if (preserve_domain)
10176 else if (src == dest)
10229 bool implicit_coercion,
bool preserve_domain)
10249 bool implicit_coercion)
10286 if (temp_domain ==
NULL)
10294 temp_domain->
codeset = codeset;
10351 static int rank_init = 0;
10354 if (type1 == type2)
10360 #if defined (CUBRID_DEBUG) 10361 printf (
"tp_more_general_type: DB type 1 out of range: %d\n", type1);
10367 #if defined (CUBRID_DEBUG) 10368 printf (
"tp_more_general_type: DB type 2 out of range: %d\n", type2);
10386 return rank[type1] - rank[type2];
10444 if (vtype1 != vtype2)
10562 bool * can_compare)
10564 DB_VALUE temp1, temp2, tmp_char_conv;
10565 int coercion, char_conv;
10568 #if !defined (SERVER_MODE) 10572 bool use_collation_of_v1 =
false;
10573 bool use_collation_of_v2 =
false;
10580 if (can_compare !=
NULL)
10582 *can_compare =
true;
10602 int common_coll = -1;
10617 if (vtype1 != vtype2)
10619 #if defined (SERVER_MODE) 10635 return oidcmp (oid1, oid2);
10653 return oidcmp (oid1, oid2);
10757 use_collation_of_v2 =
true;
10803 use_collation_of_v1 =
true;
10849 if (can_compare !=
NULL)
10851 *can_compare =
false;
10879 else if (
TP_IS_CHAR_TYPE (vtype1) && (use_collation_of_v1 || use_collation_of_v2))
10888 if (use_collation_of_v1)
10890 assert (!use_collation_of_v2);
10895 assert (use_collation_of_v2 ==
true);
10921 v1 = &tmp_char_conv;
10943 v2 = &tmp_char_conv;
10951 if (common_coll == -1)
10955 if (can_compare !=
NULL)
10957 *can_compare =
false;
10962 result = pr_type->
cmpval (v1, v2, do_coercion, total_order,
NULL, common_coll);
11093 if (domain ==
NULL)
11122 int src_precision, src_length;
11150 assert (src_length >= 0);
11160 src_precision = src_length;
11183 assert (src_length >= 0);
11195 src_precision = src_length;
11216 #if defined(CUBRID_DEBUG) 11224 fprint_domain (FILE * fp,
TP_DOMAIN * domain)
11228 for (d = domain; d !=
NULL; d = d->
next)
11239 fprintf (fp,
"sub(");
11241 #if !defined (SERVER_MODE) 11248 fprintf (fp,
"object");
11262 fprintf (fp,
"union(");
11268 fprintf (fp,
"set(");
11273 fprintf (fp,
"multiset(");
11278 fprintf (fp,
"sequence(");
11304 fprintf (fp,
"%s", d->
type->
name);
11323 fprint_domain (stdout, domain);
11324 fprintf (stdout,
"\n");
11335 fprint_domain (stdout, domain);
11345 tp_domain_fprint (FILE * fp,
TP_DOMAIN * domain)
11347 fprint_domain (fp, domain);
11420 for (; dom; dom = dom->
next)
11505 if (cast_dom ==
NULL)
11537 DB_TYPE arg1_type, arg2_type, common_type;
11538 bool need_to_domain_update =
false;
11542 arg1_type = arg1->
type->
id;
11543 arg2_type = arg2->
type->
id;
11545 if (arg1_type == arg2_type)
11547 common_type = arg1_type;
11549 need_to_domain_update =
true;
11553 common_type = arg2_type;
11558 common_type = arg1_type;
11569 common_type = arg1_type;
11574 common_type = arg2_type;
11577 need_to_domain_update =
true;
11585 if (need_to_domain_update)
11587 int arg1_prec, arg2_prec, arg1_scale, arg2_scale;
11590 arg1_scale = arg1->
scale;
11593 arg2_scale = arg2->
scale;
11598 target_domain->
scale = 0;
11602 int integral_digits1, integral_digits2;
11604 integral_digits1 = arg1_prec - arg1_scale;
11605 integral_digits2 = arg2_prec - arg2_scale;
11606 target_domain->
scale = MAX (arg1_scale, arg2_scale);
11607 target_domain->
precision = (target_domain->
scale + MAX (integral_digits1, integral_digits2));
11612 target_domain->
precision = MAX (arg1_prec, arg2_prec);
11613 target_domain->
scale = 0;
11618 return target_domain;
11702 char str[64] = { 0 };
11703 const char *
p =
NULL;
11704 const char *strp =
NULL, *stre =
NULL;
11705 size_t n_digits = 0;
11707 bool round =
false;
11708 bool truncated =
false;
11723 n_digits = p - strp;
11731 if (p != stre && *p ==
'.')
11782 strncpy (str + 1, strp, n_digits);
11783 str[n_digits + 1] =
'\0';
11788 strp = strncpy (str, strp, n_digits);
11789 str[n_digits] =
'\0';
11793 bigint = strtoll (strp,
NULL, 10);
11795 if (errno == ERANGE)
11832 *num_value = bigint;
11852 #define HIGHEST_4BITS_OF_UBI 0xF000000000000000 11855 const char *
p =
NULL;
11857 unsigned int tmp_ui = 0;
11858 bool round =
false;
11859 bool truncated =
false;
11874 else if (*p >=
'a' && *p <=
'f')
11876 tmp_ui = *p -
'a' + 10;
11878 else if (*p >=
'A' && *p <=
'F')
11880 tmp_ui = *p -
'A' + 10;
11882 else if (*p ==
'.')
11888 if (*p >=
'0' && *p <
'8')
11956 #undef HIGHEST_4BITS_OF_UBI 11979 bool truncated =
false;
11980 bool round =
false;
11981 const char *
p =
NULL;
11982 const char *base_int_start =
NULL, *base_int_end =
NULL;
11983 const char *base_float_start =
NULL, *base_float_end =
NULL;
11984 const char *exp_start =
NULL, *exp_end =
NULL;
11985 bool is_exp_negative =
false;
11992 base_int_start = start;
11993 p = base_int_start;
12002 if (base_int_start == base_int_end)
12004 base_int_start =
NULL;
12005 base_int_end =
NULL;
12008 if (p != end && *p ==
'.')
12013 base_float_start =
p;
12019 base_float_end =
p;
12022 if (base_float_start == base_float_end)
12024 base_float_start =
NULL;
12025 base_float_end =
NULL;
12031 if (base_int_start ==
NULL && base_float_start ==
NULL)
12037 if (p != end && (*p ==
'e' || *p ==
'E'))
12044 is_exp_negative =
true;
12047 else if (*p ==
'+')
12061 if (exp_start == exp_end)
12069 if (exp_start ==
NULL)
12079 while (p != exp_end)
12081 exp = exp * 10 + (*p -
'0');
12091 if (is_exp_negative)
12097 if (base_int_start !=
NULL)
12103 if (base_int_end - base_int_start >= -exp)
12105 base_int_end += exp;
12109 base_int_end = base_int_start - 1;
12113 p = base_int_start;
12114 while (p < base_int_end)
12123 ubi = ubi + *p -
'0';
12129 if (exp < 0 && base_int_end >= base_int_start && *base_int_end >=
'5')
12140 if (base_float_start !=
NULL)
12144 p = base_float_start;
12145 while (p != base_float_end && exp > 0)
12154 ubi = ubi + *p -
'0';
12161 if (p != base_float_end && *p >=
'5')
12182 else if (exp == 0 && base_float_start !=
NULL && *base_float_start >=
'5')
12211 #define HIGHEST_BIT_OF_UINT64 0x8000000000000000 12290 #undef HIGHEST_BIT_OF_UINT64 12303 #define HIGHEST_3BITS_OF_UBI 0xE000000000000000 12305 UINT64 tmp_ubi = 0;
12317 tmp_ubi = ubi << 3;
12318 ubi = (ubi << 1) + tmp_ubi;
12330 #undef HIGHEST_3BITS_OF_UBI
TP_DOMAIN tp_String_domain
DB_C_FLOAT db_get_float(const DB_VALUE *value)
static int tp_atoutime(const DB_VALUE *src, DB_UTIME *temp)
static void format_floating_point(char *new_string, char *rve, int ndigits, int decpt, int sign)
struct db_domain_info::char_info char_info
static TP_DOMAIN * tp_Monetary_conv[]
#define BYTE_COUNT(bit_cnt)
#define TP_IS_DATE_OR_TIME_TYPE(typeid)
bool tp_domain_references_objects(const TP_DOMAIN *dom)
TP_DOMAIN_STATUS tp_value_coerce(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain)
int tp_domain_disk_size(TP_DOMAIN *domain)
static int tp_domain_size_internal(const TP_DOMAIN *domain)
int db_make_json(DB_VALUE *value, JSON_DOC *json_document, bool need_clear)
#define DB_DATETIMETZ_PRECISION
int db_make_datetime(DB_VALUE *value, const DB_DATETIME *datetime)
TP_DOMAIN tp_Datetimeltz_domain
#define ER_TP_CANT_COERCE
#define WS_IS_DELETED(mop)
TP_DOMAIN tp_Substructure_domain
int sm_check_object_domain(TP_DOMAIN *domain, MOP object)
int db_value_coerce(const DB_VALUE *src, DB_VALUE *dest, const DB_DOMAIN *desired_domain)
static int bfmt_print(int bfmt, const DB_VALUE *the_db_bit, char *string, int max_size)
TP_DOMAIN_STATUS tp_value_change_coll_and_codeset(DB_VALUE *src, DB_VALUE *dest, int coll_id, int codeset)
#define DB_GET_ENUM_ELEM_STRING(elem)
int db_value_put_null(DB_VALUE *value)
const char * lang_currency_symbol(DB_CURRENCY curr)
DB_COLLECTION * db_get_set(const DB_VALUE *value)
int db_value_scale(const DB_VALUE *value)
#define LANG_SYS_COLLATION
#define TP_NUM_MIDXKEY_DOMAIN_LIST
void tp_domain_init(TP_DOMAIN *domain, DB_TYPE type_id)
TP_DOMAIN tp_Error_domain
static TP_DOMAIN * tp_is_domain_cached(TP_DOMAIN *dlist, TP_DOMAIN *transient, TP_MATCH exact, TP_DOMAIN **ins_pos)
TP_DOMAIN_STATUS tp_domain_check(const TP_DOMAIN *domain, const DB_VALUE *value, TP_MATCH exact_match)
DB_MIDXKEY * db_get_midxkey(const DB_VALUE *value)
bool db_json_are_validators_equal(JSON_VALIDATOR *val1, JSON_VALIDATOR *val2)
int db_timestamptz_to_string(char *buf, int bufsize, DB_TIMESTAMP *utime, const TZ_ID *tz_id)
TP_DOMAIN * tp_domain_resolve_default_w_coll(DB_TYPE type, int coll_id, TP_DOMAIN_COLL_ACTION coll_flag)
#define DB_SET_ENUM_ELEM_STRING(elem, str)
static char * tp_ltoa(DB_BIGINT value, char *string, int radix)
DB_VALUE_COMPARE_RESULT tp_value_compare(const DB_VALUE *value1, const DB_VALUE *value2, int allow_coercion, int total_order)
TP_DOMAIN tp_Variable_domain
static void tp_ftoa(DB_VALUE const *src, DB_VALUE *result)
double db_json_get_double_from_document(const JSON_DOC *doc)
int tp_domain_compatible(const TP_DOMAIN *src, const TP_DOMAIN *dest)
const char * db_get_class_name(DB_OBJECT *class_)
TP_DOMAIN tp_Short_domain
int tp_get_fixed_precision(DB_TYPE domain_type)
MOP ws_mop(const OID *oid, MOP class_mop)
#define OR_CHECK_BIGINT_OVERFLOW(i)
#define HIGHEST_4BITS_OF_UBI
TP_DOMAIN * tp_domain_select(const TP_DOMAIN *domain_list, const DB_VALUE *value, int allow_coercion, TP_MATCH exact_match)
int tp_value_domain_name(const DB_VALUE *value, char *buffer, int maxlen)
DB_OBJECT * db_real_instance(DB_OBJECT *obj)
void area_destroy(AREA *area)
TP_DOMAIN tp_Timestamptz_domain
DB_SET * db_seq_create(MOP classop, const char *name, int size)
DB_CONST_C_BIT db_get_bit(const DB_VALUE *value, int *length)
#define TP_IS_SET_TYPE(typenum)
JSON_DOC * db_get_json_document(const DB_VALUE *value)
#define DB_MAX_STRING_LENGTH
static TP_DOMAIN * tp_VarBit_conv[]
static int tp_atodate(const DB_VALUE *src, DB_DATE *temp)
int db_bit_string_coerce(const DB_VALUE *src_string, DB_VALUE *dest_string, DB_DATA_STATUS *data_status)
int db_date_to_string(char *buf, int bufsize, DB_DATE *date)
struct tp_domain * next_list
#define ER_JSON_INVALID_JSON
int db_make_bigint(DB_VALUE *value, const DB_BIGINT num)
int db_get_int(const DB_VALUE *value)
int db_date_parse_datetime(char const *str, int str_len, DB_DATETIME *datetime)
int db_is_vclass(DB_OBJECT *op)
int tp_more_general_type(const DB_TYPE type1, const DB_TYPE type2)
int tp_value_equal(const DB_VALUE *value1, const DB_VALUE *value2, int do_coercion)
#define LANG_IS_COERCIBLE_COLL(c)
int tz_create_datetimetz_from_ses(const DB_DATETIME *dt, DB_DATETIMETZ *dt_tz)
DB_C_DOUBLE db_get_double(const DB_VALUE *value)
int db_char_to_blob(const DB_VALUE *src_value, DB_VALUE *result_value)
int tp_domain_copy_enumeration(DB_ENUMERATION *dest, const DB_ENUMERATION *src)
int db_make_varchar(DB_VALUE *value, const int max_char_length, DB_CONST_C_CHAR str, const int char_str_byte_size, const int codeset, const int collation_id)
int db_seq_put(DB_SET *set, int index, DB_VALUE *value)
int db_datetime_decode(const DB_DATETIME *datetime, int *month, int *day, int *year, int *hour, int *minute, int *second, int *millisecond)
#define DB_GET_COMPRESSED_STRING(v)
int db_get_string_collation(const DB_VALUE *value)
DB_COLLECTION * set_copy(DB_COLLECTION *set)
#define DB_DATETIMETZ_INITIALIZER
int tp_domain_drop(TP_DOMAIN **dlist, TP_DOMAIN *domain)
void initval(DB_VALUE *value, int precision, int scale) const
struct tp_domain * setdomain
int sm_check_class_domain(TP_DOMAIN *domain, MOP class_)
#define pthread_mutex_unlock(a)
int db_timestamp_encode_ses(const DB_DATE *date, const DB_TIME *timeval, DB_TIMESTAMP *utime, TZ_ID *dest_tz_id)
int db_value_clone(DB_VALUE *src, DB_VALUE *dest)
TP_DOMAIN_STATUS tp_value_auto_cast(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain)
DB_VALUE_COMPARE_RESULT tp_value_compare_with_error(const DB_VALUE *value1, const DB_VALUE *value2, int do_coercion, int total_order, bool *can_compare)
static TP_DOMAIN_STATUS tp_value_cast_internal(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain, TP_COERCION_MODE coercion_mode, bool do_domain_select, bool preserve_domain)
TP_DOMAIN * tp_domain_select_type(const TP_DOMAIN *domain_list, DB_TYPE type, DB_OBJECT *class_mop, int allow_coercion)
const TZ_ID * tz_get_utc_tz_id(void)
int db_get_enum_codeset(const DB_VALUE *value)
TP_DOMAIN * tp_domain_find_enumeration(const DB_ENUMERATION *enumeration, bool is_desc)
int db_get_enum_string_size(const DB_VALUE *value)
static TP_DOMAIN * tp_Bigint_conv[]
#define assert_release(e)
#define DOMAIN_INIT2(codeset, coll)
int db_make_object(DB_VALUE *value, DB_C_OBJECT *obj)
int db_make_pointer(DB_VALUE *value, DB_C_POINTER ptr)
#define DB_TIME_PRECISION
static TP_DOMAIN * tp_Integer_conv[]
void db_json_set_double_to_doc(JSON_DOC *doc, double d)
static void tp_dtoa(DB_VALUE const *src, DB_VALUE *result)
DB_VALUE_COMPARE_RESULT cmpval(const DB_VALUE *value, const DB_VALUE *value2, int do_coercion, int total_order, int *start_colp, int collation) const
TP_DOMAIN tp_Midxkey_domain_list_heads[TP_NUM_MIDXKEY_DOMAIN_LIST]
unsigned int db_on_server
int vid_oid_to_object(const DB_VALUE *value, DB_OBJECT **mop)
#define TP_FLOAT_MANTISA_DECIMAL_PRECISION
void setobj_put_domain(COL *set, TP_DOMAIN *domain)
#define DB_SET_ENUM_ELEM_SHORT(elem, sv)
int db_make_date(DB_VALUE *value, const int month, const int day, const int year)
#define OID_SET_NULL(oidp)
DB_DATETIMETZ * db_get_datetimetz(const DB_VALUE *value)
int tp_value_coerce_strict(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain)
int db_make_datetimeltz(DB_VALUE *value, const DB_DATETIME *datetime)
static TP_DOMAIN * tp_Domains[]
TP_DOMAIN tp_Object_domain
TP_DOMAIN * tp_domain_resolve_value(const DB_VALUE *val, TP_DOMAIN *dbuf)
static DB_VALUE_COMPARE_RESULT oidcmp(OID *oid1, OID *oid2)
static int tp_domain_match_internal(const TP_DOMAIN *dom1, const TP_DOMAIN *dom2, TP_MATCH exact, bool match_order)
int db_make_sequence(DB_VALUE *value, DB_C_SET *set)
#define TP_IS_STRING_TYPE(typeid)
int vid_object_to_vobj(const DB_OBJECT *obj, DB_VALUE *vobj)
TP_DOMAIN * tp_domain_copy(const TP_DOMAIN *domain, bool check_cache)
static int tp_domain_check_class(TP_DOMAIN *domain, int *change)
int db_string_to_timestamptz_ex(const char *str, int str_len, DB_TIMESTAMPTZ *ts_tz, bool *has_zone, bool is_cast)
TP_DOMAIN * tp_domain_find_charbit(DB_TYPE type, int codeset, int collation_id, unsigned char collation_flag, int precision, bool is_desc)
int numeric_db_value_coerce_to_num(DB_VALUE *src, DB_VALUE *dest, DB_DATA_STATUS *data_status)
TP_DOMAIN tp_Integer_domain
#define TP_NEAR_MATCH(t1, t2)
int db_is_subclass(MOP classmop, MOP supermop)
TP_DOMAIN ** tp_Domain_conversion_matrix[]
static int tp_atobi(const DB_VALUE *src, DB_BIGINT *num_value, DB_DATA_STATUS *data_stat)
#define DB_VALUE_PRECISION(value)
enum tp_domain_status TP_DOMAIN_STATUS
#define DB_SHORT_PRECISION
int setobj_build_domain_from_col(COL *col, TP_DOMAIN **set_domain)
TP_DOMAIN tp_Utime_domain
TP_DOMAIN * tp_domain_find_set(DB_TYPE type, TP_DOMAIN *setdomain, bool is_desc)
#define DB_DEFAULT_NUMERIC_SCALE
AREA * area_create(const char *name, size_t element_size, size_t alloc_count)
#define HIGHEST_3BITS_OF_UBI
int get_mem_size_of_mem(const void *mem, const tp_domain *domain=NULL) const
#define DB_VALUE_SCALE(value)
int tp_setdomain_size(const TP_DOMAIN *domain)
int db_datetimetz_to_string(char *buf, int bufsize, DB_DATETIME *dt, const TZ_ID *tz_id)
#define DB_DATETIME_DECIMAL_SCALE
#define DB_FLOAT_DECIMAL_PRECISION
#define TP_DOUBLE_MANTISA_DECIMAL_PRECISION
#define TP_DOUBLE_AS_CHAR_LENGTH
#define TP_IS_DATETIME_TYPE(db_val_type)
static TP_DOMAIN * tp_NChar_conv[]
static TP_DOMAIN * tp_Float_conv[]
#define DATETIMETZ_BUF_SIZE
DB_TIMESTAMPTZ * db_get_timestamptz(const DB_VALUE *value)
TP_DOMAIN tp_Double_domain
int db_make_short(DB_VALUE *value, const DB_C_SHORT num)
int db_timestamp_to_string(char *buf, int bufsize, DB_TIMESTAMP *utime)
const char * lang_get_collation_name(const int coll_id)
TP_DOMAIN_STATUS tp_value_cast_preserve_domain(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain, bool implicit_coercion, bool preserve_domain)
int db_make_string(DB_VALUE *value, DB_CONST_C_CHAR str)
TP_DOMAIN tp_VarNChar_domain
DB_MONETARY * db_get_monetary(const DB_VALUE *value)
static INLINE TP_DOMAIN ** tp_domain_get_list_ptr(DB_TYPE type, TP_DOMAIN *setdomain) __attribute__((ALWAYS_INLINE))
bool pr_is_set_type(DB_TYPE type)
TP_DOMAIN tp_Datetime_domain
unsigned int DB_TIMESTAMP
unsigned is_parameterized
PR_TYPE * pr_type_from_id(DB_TYPE id)
#define DB_MAX_VARBIT_PRECISION
DB_COLLECTION * set_coerce(DB_COLLECTION *set, TP_DOMAIN *domain, bool implicit_coercion)
TP_DOMAIN * tp_domain_resolve_default(DB_TYPE type)
#define ER_MR_NULL_DOMAIN
void er_set(int severity, const char *file_name, const int line_no, int err_id, int num_args,...)
LANG_COLLATION * lang_get_collation(const int coll_id)
#define TP_FLOAT_AS_CHAR_LENGTH
int db_make_enumeration(DB_VALUE *value, unsigned short index, DB_CONST_C_CHAR str, int size, unsigned char codeset, const int collation_id)
int db_value_put_encoded_time(DB_VALUE *value, const DB_TIME *time)
#define DB_MAX_VARCHAR_PRECISION
int tp_domain_match(const TP_DOMAIN *dom1, const TP_DOMAIN *dom2, TP_MATCH exact)
#define DB_MAX_NUMERIC_PRECISION
JSON_VALIDATOR * db_json_copy_validator(JSON_VALIDATOR *validator)
static TP_DOMAIN * tp_Double_conv[]
#define DB_DATETIME_PRECISION
int db_make_monetary(DB_VALUE *value, const DB_CURRENCY type, const double amount)
#define DOMAIN_INIT4(prec, scale)
static int tp_atoudatetime(const DB_VALUE *src, DB_DATETIME *temp)
int tz_create_session_tzid_for_datetime(const DB_DATETIME *src_dt, bool src_is_utc, TZ_ID *tz_id)
#define DB_SET_ENUM_ELEM_STRING_SIZE(elem, sz)
int qstr_hex_to_bin(char *dest, int dest_size, const char *src, int src_size)
int db_string_to_datetimetz_ex(const char *str, int str_len, DB_DATETIMETZ *dt_tz, bool *has_zone)
#define DB_DOUBLE_DECIMAL_PRECISION
int db_make_set(DB_VALUE *value, DB_C_SET *set)
struct db_domain_info::numeric_info numeric_info
TP_DOMAIN tp_Bigint_domain
int db_make_multiset(DB_VALUE *value, DB_C_SET *set)
static const TP_DOMAIN * tp_domain_find_compatible(const TP_DOMAIN *src, const TP_DOMAIN *dest)
TP_DOMAIN * tp_infer_common_domain(TP_DOMAIN *arg1, TP_DOMAIN *arg2)
int db_timestamp_encode_utc(const DB_DATE *date, const DB_TIME *timeval, DB_TIMESTAMP *utime)
int tp_domain_status_er_set(TP_DOMAIN_STATUS status, const char *file_name, const int line_no, const DB_VALUE *src, const TP_DOMAIN *domain)
struct db_object * class_mop
#define ER_IT_DATA_OVERFLOW
#define TP_DOMAIN_SELF_REF
#define ER_OUT_OF_VIRTUAL_MEMORY
const char * intl_skip_spaces(const char *str, const char *str_end, const INTL_CODESET codeset)
int tp_domain_name(const TP_DOMAIN *domain, char *buffer, int maxlen)
#define DOM_GET_ENUMERATION(dom)
#define INTL_CAN_STEAL_CS(cs_from, cs_to)
int tp_domain_size(const TP_DOMAIN *domain)
#define OR_CHECK_SHORT_OVERFLOW(i)
int db_time_encode(DB_TIME *timeval, int hour, int minute, int second)
#define DB_INTEGER_PRECISION
TP_DOMAIN * setobj_domain(COL *set)
int db_json_get_json_from_str(const char *json_raw, JSON_DOC *&doc, size_t json_raw_length)
void tp_init_value_domain(TP_DOMAIN *domain, DB_VALUE *value)
int numeric_db_value_coerce_from_num(DB_VALUE *src, DB_VALUE *dest, DB_DATA_STATUS *data_status)
#define DB_VALUE_DOMAIN_TYPE(value)
int tp_value_string_to_double(const DB_VALUE *value, DB_VALUE *result)
#define DOM_GET_ENUM_ELEM(dom, idx)
#define TP_DOMAIN_COLLATION(dom)
static TP_DOMAIN * tp_Set_conv[]
#define TP_IS_NUMERIC_TYPE(typeid)
bool is_always_variable() const
static enum scanner_mode mode
#define DOM_GET_ENUM_ELEMS_COUNT(dom)
static DB_BIGINT tp_ubi_to_bi_with_args(UINT64 ubi, bool is_negative, bool truncated, bool round, DB_DATA_STATUS *data_stat)
#define OR_CHECK_INT_OVERFLOW(i)
static void tp_value_slam_domain(DB_VALUE *value, const DB_DOMAIN *domain)
int db_json_get_int_from_document(const JSON_DOC *doc)
std::int64_t db_json_get_bigint_from_document(const JSON_DOC *doc)
#define db_get_json_schema(v)
void db_json_delete_doc(JSON_DOC *&doc)
static TP_DOMAIN * tp_Char_conv[]
DB_OBJECT * db_get_object(const DB_VALUE *value)
int db_make_timestamptz(DB_VALUE *value, const DB_C_TIMESTAMPTZ *ts_tz_val)
#define OID_EQ(oidp1, oidp2)
static TP_DOMAIN * tp_Midxkey_domains[TP_NUM_MIDXKEY_DOMAIN_LIST+1]
int db_string_put_cs_and_collation(DB_VALUE *value, const int codeset, const int collation_id)
static int tp_enumeration_match(const DB_ENUMERATION *db_enum1, const DB_ENUMERATION *db_enum2)
TP_DOMAIN_STATUS tp_value_cast(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain, bool implicit_coercion)
int db_char_string_coerce(const DB_VALUE *src_string, DB_VALUE *dest_string, DB_DATA_STATUS *data_status)
TP_DOMAIN tp_Pointer_domain
#define TP_DOMAIN_TYPE(dom)
void db_json_set_bigint_to_doc(JSON_DOC *doc, std::int64_t i)
static int tp_atonumeric(const DB_VALUE *src, DB_VALUE *temp)
#define WS_SET_DELETED(mop)
static TP_DOMAIN * tp_String_conv[]
static TP_DOMAIN * tp_VarNChar_conv[]
unsigned short db_get_enum_short(const DB_VALUE *value)
int tp_valid_indextype(DB_TYPE type)
int db_date_parse_time(char const *str, int str_len, DB_TIME *time, int *millisecond)
#define NUMERIC_MAX_STRING_SIZE
int db_blob_to_bit(const DB_VALUE *src_value, const DB_VALUE *length_value, DB_VALUE *result_value)
TP_DOMAIN * tp_domain_find_noparam(DB_TYPE type, bool is_desc)
int tz_datetimeltz_to_local(const DB_DATETIME *dt_ltz, DB_DATETIME *dt_local)
DB_OBJECT * db_get_class(MOP obj)
const char * pr_type_name(DB_TYPE id)
static UINT64 tp_ubi_times_ten(UINT64 ubi, bool *truncated)
TP_DOMAIN * tp_domain_cache(TP_DOMAIN *transient)
#define db_private_free_and_init(thrd, ptr)
int db_value_put_encoded_date(DB_VALUE *value, const DB_DATE *date)
int db_timestamp_decode_w_tz_id(const DB_TIMESTAMP *utime, const TZ_ID *tz_id, DB_DATE *date, DB_TIME *timeval)
#define TP_BIGINT_PRECISION
TP_DOMAIN_STATUS tp_value_cast_no_domain_select(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain, bool implicit_coercion)
DB_VALUE_COMPARE_RESULT set_compare(DB_COLLECTION *set1, DB_COLLECTION *set2, int do_coercion)
int db_date_parse_date(char const *str, int str_len, DB_DATE *date)
static int tp_digit_number_str_to_bi(const char *start, const char *end, INTL_CODESET codeset, bool is_negative, DB_BIGINT *num_value, DB_DATA_STATUS *data_stat)
int numeric_db_value_coerce_from_num_strict(DB_VALUE *src, DB_VALUE *dest)
#define db_private_alloc(thrd, size)
#define CONST_CAST(dest_type, expr)
#define TP_IMPLICIT_COERCION_NOT_ALLOWED(src_type, dest_type)
int tp_domain_add(TP_DOMAIN **dlist, TP_DOMAIN *domain)
need_clear_type need_clear
#define DB_TIMESTAMP_PRECISION
static int tp_atotimestamptz(const DB_VALUE *src, DB_TIMESTAMPTZ *temp)
int pr_clear_value(DB_VALUE *value)
int db_timestamp_decode_ses(const DB_TIMESTAMP *utime, DB_DATE *date, DB_TIME *timeval)
DB_BIGINT db_get_bigint(const DB_VALUE *value)
#define DB_MONETARY_DECIMAL_PRECISION
DB_JSON_TYPE db_json_get_type(const JSON_DOC *doc)
#define DB_BIGINT_PRECISION
int vid_vobj_to_object(const DB_VALUE *vobj, DB_OBJECT **mop)
int db_time_to_string(char *buf, int bufsize, DB_TIME *time)
DB_DOMAIN * db_type_to_db_domain(const DB_TYPE type)
#define DB_DEFAULT_NUMERIC_PRECISION
int db_json_copy_and_convert_to_utf8(const DB_VALUE *src_dbval, DB_VALUE *dest_dbval, const DB_VALUE **json_str_dbval)
int db_make_time(DB_VALUE *value, const int hour, const int minute, const int second)
int db_datetime_to_string(char *buf, int bufsize, DB_DATETIME *datetime)
TP_DOMAIN_STATUS tp_check_value_size(TP_DOMAIN *domain, DB_VALUE *value)
int db_make_datetimetz(DB_VALUE *value, const DB_DATETIMETZ *datetimetz)
TP_DOMAIN tp_Float_domain
struct db_domain_info::general_info general_info
TP_DOMAIN tp_Numeric_domain
int db_clob_to_char(const DB_VALUE *src_value, const DB_VALUE *codeset_value, DB_VALUE *result_value)
void tp_apply_sys_charset(void)
DB_ENUMERATION enumeration
DB_CONST_C_CHAR db_get_enum_string(const DB_VALUE *value)
#define TP_IS_CHAR_TYPE(typeid)
TP_DOMAIN_COLL_ACTION collation_flag
static void error(const char *msg)
TP_DOMAIN * set_get_domain(DB_COLLECTION *set)
int db_make_float(DB_VALUE *value, const DB_C_FLOAT num)
#define DB_DEFAULT_PRECISION
#define DB_GET_ENUM_ELEM_STRING_SIZE(elem)
TP_DOMAIN * tp_domain_construct(DB_TYPE domain_type, DB_OBJECT *class_obj, int precision, int scale, TP_DOMAIN *setdomain)
#define BYTE_COUNT_HEX(bit_cnt)
#define TP_TYPE_HAS_COLLATION(typeid)
char * numeric_db_value_print(const DB_VALUE *val, char *buf)
#define OR_CHECK_FLOAT_OVERFLOW(i)
int tz_utc_datetimetz_to_local(const DB_DATETIME *dt_utc, const TZ_ID *tz_id, DB_DATETIME *dt_local)
int locator_does_exist_object(MOP mop, DB_FETCH_MODE purpose)
static void tp_swizzle_oid(TP_DOMAIN *domain)
TP_DOMAIN tp_Timestampltz_domain
void db_json_set_int_to_doc(JSON_DOC *doc, int i)
int pr_clone_value(const DB_VALUE *src, DB_VALUE *dest)
OID * db_get_oid(const DB_VALUE *value)
const char * db_json_get_string_from_document(const JSON_DOC *doc)
TP_DOMAIN * tp_domain_find_numeric(DB_TYPE type, int precision, int scale, bool is_desc)
TP_DOMAIN_STATUS set_check_domain(DB_COLLECTION *set, TP_DOMAIN *domain)
#define DB_SET_ENUM_ELEM_CODESET(elem, cs)
#define free_and_init(ptr)
int sm_coerce_object_domain(TP_DOMAIN *domain, MOP object, MOP *dest_object)
int db_make_timestampltz(DB_VALUE *value, const DB_C_TIMESTAMP ts_val)
DB_DATE * db_get_date(const DB_VALUE *value)
int oid_compare(const void *a, const void *b)
DB_ENUM_ELEMENT * elements
#define HIGHEST_BIT_OF_UINT64
#define DB_DATE_PRECISION
int db_value_precision(const DB_VALUE *value)
TP_DOMAIN tp_Datetimetz_domain
int db_make_string_copy(DB_VALUE *value, DB_CONST_C_CHAR str)
void db_json_delete_validator(JSON_VALIDATOR *&validator)
TP_DOMAIN tp_Monetary_domain
int tp_domain_filter_list(TP_DOMAIN *dlist, int *list_changes)
int db_json_validate_doc(JSON_VALIDATOR *validator, JSON_DOC *doc)
enum intl_codeset INTL_CODESET
static bool tp_Initialized
void * area_alloc(AREA *area)
TP_DOMAIN tp_Enumeration_domain
bool prm_get_bool_value(PARAM_ID prm_id)
JSON_VALIDATOR * json_validator
int db_json_load_validator(const char *json_schema_raw, JSON_VALIDATOR *&validator)
DB_TIMESTAMP * db_get_timestamp(const DB_VALUE *value)
int db_get_string_size(const DB_VALUE *value)
DB_C_SHORT db_get_short(const DB_VALUE *value)
void tp_domain_clear_enumeration(DB_ENUMERATION *enumeration)
static int tp_atotime(const DB_VALUE *src, DB_TIME *temp)
#define TP_IS_DATE_TYPE(typeid)
int area_free(AREA *area, void *ptr)
static int tp_atodatetimetz(const DB_VALUE *src, DB_DATETIMETZ *temp)
void db_timestamp_decode_utc(const DB_TIMESTAMP *utime, DB_DATE *date, DB_TIME *timeval)
int db_make_varnchar(DB_VALUE *value, const int max_nchar_length, DB_CONST_C_NCHAR str, const int nchar_str_byte_size, const int codeset, const int collation_id)
#define TP_FLOATING_PRECISION_VALUE
#define ER_QSTR_INCOMPATIBLE_COLLATIONS
int tp_enumeration_to_varchar(const DB_VALUE *src, DB_VALUE *result)
#define DB_VALUE_TYPE(value)
#define ARE_COMPARABLE(typ1, typ2)
#define DB_CURRENCY_DEFAULT
int db_get_enum_collation(const DB_VALUE *value)
static const DB_TYPE db_type_rank[]
int db_make_null(DB_VALUE *value)
#define DB_TIMESTAMPTZ_PRECISION
int tp_value_str_auto_cast_to_number(DB_VALUE *src, DB_VALUE *dest, DB_TYPE *val_type)
static TP_DOMAIN * tp_Sequence_conv[]
#define DB_IS_NULL(value)
static TP_DOMAIN * tp_Bit_conv[]
int db_make_double(DB_VALUE *value, const DB_C_DOUBLE num)
int tp_can_steal_string(const DB_VALUE *val, const DB_DOMAIN *desired_domain)
TP_DOMAIN * tp_domain_resolve(DB_TYPE domain_type, DB_OBJECT *class_obj, int precision, int scale, TP_DOMAIN *setdomain, int collation)
void db_date_decode(const DB_DATE *date, int *monthp, int *dayp, int *yearp)
TP_DOMAIN tp_Sequence_domain
DB_DATETIME * db_get_datetime(const DB_VALUE *value)
int db_char_to_clob(const DB_VALUE *src_value, DB_VALUE *result_value)
#define pthread_mutex_lock(a)
#define DB_MAX_VARNCHAR_PRECISION
static int tp_scientific_str_to_bi(const char *start, const char *end, INTL_CODESET codeset, bool is_negative, DB_BIGINT *num_value, DB_DATA_STATUS *data_stat)
int db_make_timestamp(DB_VALUE *value, const DB_C_TIMESTAMP timeval)
int db_make_int(DB_VALUE *value, const int num)
int db_get_string_length(const DB_VALUE *value)
struct db_object * class_mop
#define LANG_RT_COMMON_COLL(c1, c2, coll)
int db_make_oid(DB_VALUE *value, const OID *oid)
int db_make_char(DB_VALUE *value, const int char_length, DB_CONST_C_CHAR str, const int char_str_byte_size, const int codeset, const int collation_id)
int tp_domain_attach(TP_DOMAIN **dlist, TP_DOMAIN *domain)
#define db_date_parse_utime
static INLINE TP_DOMAIN * tp_domain_get_list(DB_TYPE type, TP_DOMAIN *setdomain) __attribute__((ALWAYS_INLINE))
#define TP_DOMAIN_CODESET(dom)
int tp_domain_match_ignore_order(const TP_DOMAIN *dom1, const TP_DOMAIN *dom2, TP_MATCH exact)
#define OR_CHECK_ASSIGN_OVERFLOW(dest, src)
int get_disk_size_of_mem(const void *mem, const tp_domain *domain=NULL) const
DB_TIME * db_get_time(const DB_VALUE *value)
int numeric_coerce_string_to_num(const char *astring, int astring_length, INTL_CODESET codeset, DB_VALUE *result)
void db_time_decode(DB_TIME *timeval, int *hourp, int *minutep, int *secondp)
#define DB_GET_ENUM_ELEM_CODESET(elem)
int tz_create_session_tzid_for_timestamp(const DB_UTIME *src_ts, TZ_ID *tz_id)
DB_C_POINTER db_get_pointer(const DB_VALUE *value)
enum tp_coersion_mode TP_COERCION_MODE
#define TP_IS_BIT_TYPE(typeid)
#define DOM_SET_ENUM(dom, elems, cnt)
static TP_DOMAIN * tp_Multiset_conv[]
#define string_to_double(str, end_ptr)
TP_DOMAIN * tp_domain_new(DB_TYPE type)
static int tp_hex_str_to_bi(const char *start, const char *end, INTL_CODESET codeset, bool is_negative, DB_BIGINT *num_value, DB_DATA_STATUS *data_stat)
#define TP_IS_CHAR_STRING(db_val_type)
TP_DOMAIN_STATUS tp_value_cast_force(const DB_VALUE *src, DB_VALUE *dest, const TP_DOMAIN *desired_domain, bool implicit_coercion)
bool db_json_get_bool_from_document(const JSON_DOC *doc)
char * db_json_get_bool_as_str_from_document(const JSON_DOC *doc)
int db_make_bit(DB_VALUE *value, const int bit_length, DB_CONST_C_BIT bit_str, const int bit_str_bit_size)
int db_get_string_codeset(const DB_VALUE *value)
TP_DOMAIN tp_Multiset_domain
#define TP_IS_CHAR_BIT_TYPE(typeid)
JSON_DOC * db_json_allocate_doc()
DB_VALUE_COMPARE_RESULT tp_set_compare(const DB_VALUE *value1, const DB_VALUE *value2, int do_coercion, int total_order)
void tp_domain_free(TP_DOMAIN *dom)
DB_CONST_C_CHAR db_get_string(const DB_VALUE *value)
TP_DOMAIN tp_NChar_domain
TP_DOMAIN * tp_domain_find_object(DB_TYPE type, OID *class_oid, struct db_object *class_mop, bool is_desc)
int db_bit_to_blob(const DB_VALUE *src_value, DB_VALUE *result_value)
#define QSTR_COMPARE(id, string1, size1, string2, size2, ti)
int db_make_nchar(DB_VALUE *value, const int nchar_length, DB_CONST_C_NCHAR str, const int nchar_str_byte_size, const int codeset, const int collation_id)
static TP_DOMAIN * tp_Short_conv[]
static void make_desired_string_db_value(DB_TYPE desired_type, const TP_DOMAIN *desired_domain, const char *new_string, DB_VALUE *target, TP_DOMAIN_STATUS *status, DB_DATA_STATUS *data_stat)
int tp_domain_memory_size(TP_DOMAIN *domain)
#define OR_CHECK_USHRT_OVERFLOW(i)
static TP_DOMAIN * tp_Numeric_conv[]
#define DB_GET_ENUM_ELEM_SHORT(elem)
static int tp_atof(const DB_VALUE *src, double *num_value, DB_DATA_STATUS *data_stat)
TP_DOMAIN tp_VarBit_domain
int db_value_domain_init(DB_VALUE *value, const DB_TYPE type, const int precision, const int scale)
int db_value_alter_type(DB_VALUE *value, const DB_TYPE type)
char * db_json_get_raw_json_body_from_document(const JSON_DOC *doc)