46 #define DB_CURRENCY_DEFAULT db_get_currency_default() 48 #define db_make_utime db_make_timestamp 50 #define DB_VALUE_CLONE_AS_NULL(src_value, dest_value) \ 52 if ((db_value_domain_init(dest_value, \ 53 db_value_domain_type(src_value), \ 54 db_value_precision(src_value), \ 55 db_value_scale(src_value))) \ 57 (void)db_value_put_null(dest_value); \ 60 #define db_get_collection db_get_set 61 #define db_get_utime db_get_timestamp 63 #define DB_IS_NULL(value) db_value_is_null(value) 65 #define DB_IS_STRING(value) (db_value_type(value) == DB_TYPE_VARCHAR || \ 66 db_value_type(value) == DB_TYPE_CHAR || \ 67 db_value_type(value) == DB_TYPE_VARNCHAR || \ 68 db_value_type(value) == DB_TYPE_NCHAR) 70 #define DB_VALUE_DOMAIN_TYPE(value) db_value_domain_type(value) 72 #define DB_VALUE_TYPE(value) db_value_type(value) 73 #define DB_VALUE_PRECISION(value) db_value_precision(value) 74 #define DB_VALUE_SCALE(value) db_value_scale(value) 76 #define DB_SET_COMPRESSED_STRING(value, compressed_string, compressed_size, compressed_need_clear) \ 77 db_set_compressed_string(value, compressed_string, compressed_size, compressed_need_clear) 79 #define DB_TRIED_COMPRESSION(value) (db_get_compressed_size(value) != DB_NOT_YET_COMPRESSED) 83 #define DB_NEED_CLEAR(v) \ 85 && ((v)->need_clear == true \ 86 || ((DB_VALUE_DOMAIN_TYPE(v) == DB_TYPE_VARCHAR || DB_VALUE_DOMAIN_TYPE(v) == DB_TYPE_VARNCHAR) \ 87 && (v)->data.ch.info.compressed_need_clear != 0)))) 89 #define DB_GET_COMPRESSED_STRING(v) \ 90 ((DB_VALUE_DOMAIN_TYPE(v) != DB_TYPE_VARCHAR) && (DB_VALUE_DOMAIN_TYPE(v) != DB_TYPE_VARNCHAR) \ 91 ? NULL : (v)->data.ch.medium.compressed_buf) 94 #define DB_GET_STRING_PRECISION(v) \ 95 ((v)->domain.char_info.length) 97 #define DB_GET_ENUMERATION(v) \ 98 ((v)->data.enumeration) 99 #define DB_GET_ENUM_ELEM_SHORT(elem) \ 101 #define DB_GET_ENUM_ELEM_DBCHAR(elem) \ 103 #define DB_GET_ENUM_ELEM_STRING(elem) \ 104 ((elem)->str_val.medium.buf) 105 #define DB_GET_ENUM_ELEM_STRING_SIZE(elem) \ 106 ((elem)->str_val.medium.size) 108 #define DB_GET_ENUM_ELEM_CODESET(elem) \ 109 ((elem)->str_val.info.codeset) 111 #define DB_SET_ENUM_ELEM_CODESET(elem, cs) \ 112 ((elem)->str_val.info.codeset = (cs)) 114 #define DB_SET_ENUM_ELEM_SHORT(elem, sv) \ 115 ((elem)->short_val = (sv)) 116 #define DB_SET_ENUM_ELEM_STRING(elem, str) \ 117 ((elem)->str_val.medium.buf = (str), \ 118 (elem)->str_val.info.style = MEDIUM_STRING) 119 #define DB_SET_ENUM_ELEM_STRING_SIZE(elem, sz) \ 120 ((elem)->str_val.medium.size = (sz)) 122 #define DB_GET_STRING_SAFE(v) \ 124 || DB_VALUE_DOMAIN_TYPE (v) == DB_TYPE_ERROR) ? "" \ 125 : ((assert (DB_VALUE_DOMAIN_TYPE(v) == DB_TYPE_VARCHAR \ 126 || DB_VALUE_DOMAIN_TYPE(v) == DB_TYPE_CHAR \ 127 || DB_VALUE_DOMAIN_TYPE(v) == DB_TYPE_VARNCHAR \ 128 || DB_VALUE_DOMAIN_TYPE(v) == DB_TYPE_NCHAR \ 129 || DB_VALUE_DOMAIN_TYPE(v) == DB_TYPE_VARBIT \ 130 || DB_VALUE_DOMAIN_TYPE(v) == DB_TYPE_BIT)), \ 131 (v)->data.ch.medium.buf)) 133 #define DB_GET_NUMERIC_PRECISION(val) \ 134 ((val)->domain.numeric_info.precision) 136 #define DB_GET_NUMERIC_SCALE(val) \ 137 ((val)->domain.numeric_info.scale) 139 #define DB_GET_STRING_PRECISION(v) \ 140 ((v)->domain.char_info.length) 142 #define DB_GET_BIT_PRECISION(v) \ 143 ((v)->domain.char_info.length) 145 #define DB_GET_JSON_SCHEMA(v) \ 146 ((v)->data.json.schema_raw) 148 #define db_get_json_schema(v) DB_GET_JSON_SCHEMA(v) 179 const int codeset,
const int collation_id,
const DB_ENUMERATION * enumeration);
181 const int codeset,
const int collation_id,
const DB_ENUMERATION * enumeration);
183 const int codeset,
const int collation_id,
DB_ENUMERATION * enumeration);
226 if (src ==
NULL || dst ==
NULL || src == dst)
232 memcpy (dst, src,
sizeof (
DB_VALUE));
void db_date_decode(const DB_DATE *date, int *monthp, int *dayp, int *yearp)
int db_value_put(DB_VALUE *value, const DB_TYPE_C c_type, void *input, const int input_length)
#define TP_IS_SET_TYPE(typenum)
int db_value_put_encoded_date(DB_VALUE *value, const DB_DATE *date_value)
int db_value_get(DB_VALUE *value, const DB_TYPE_C type, void *buf, const int buflen, int *transferlen, int *outputlen)
int db_value_free(DB_VALUE *value)
int db_value_domain_init(DB_VALUE *value, DB_TYPE type, const int precision, const int scale)
DB_VALUE * db_value_create(void)
int db_value_put_monetary_currency(DB_VALUE *value, const DB_CURRENCY type)
DB_VALUE * db_value_copy(DB_VALUE *value)
int db_value_put_monetary_amount_as_double(DB_VALUE *value, const double amount)
int db_string_truncate(DB_VALUE *value, const int max_precision)
int db_json_val_from_str(const char *raw_str, const int str_size, DB_VALUE *json_val)
int db_date_encode(DB_DATE *date, int month, int day, int year)
int db_init_db_json_pointers(DB_JSON *val)
void db_value_print(const DB_VALUE *value)
double db_value_get_monetary_amount_as_double(const DB_VALUE *value)
int db_value_put_encoded_time(DB_VALUE *value, const DB_TIME *time_value)
DB_TYPE db_value_domain_type(const DB_VALUE *value)
int db_value_alter_type(DB_VALUE *value, DB_TYPE type)
bool db_value_is_corrupted(const DB_VALUE *value)
int db_value_domain_default(DB_VALUE *value, const DB_TYPE type, const int precision, const int scale, const int codeset, const int collation_id, DB_ENUMERATION *enumeration)
int db_value_domain_zero(DB_VALUE *value, const DB_TYPE type, const int precision, const int scale)
int db_value_domain_min(DB_VALUE *value, DB_TYPE type, const int precision, const int scale, const int codeset, const int collation_id, const DB_ENUMERATION *enumeration)
int db_value_put_null(DB_VALUE *value)
bool db_value_type_is_collection(const DB_VALUE *value)
void db_value_domain_init_default(DB_VALUE *value, const DB_TYPE type)
int db_value_compare(const DB_VALUE *value1, const DB_VALUE *value2)
void db_time_decode(DB_TIME *timeval, int *hourp, int *minutep, int *secondp)
int db_value_clone(DB_VALUE *src, DB_VALUE *dest)
int db_value_clear_array(DB_VALUE_ARRAY *value_array)
need_clear_type need_clear
DB_TYPE setobj_type(struct setobj *set)
int db_convert_json_into_scalar(const DB_VALUE *src, DB_VALUE *dest)
int db_time_encode(DB_TIME *timeval, int hour, int minute, int second)
DB_DOMAIN * db_type_to_db_domain(DB_TYPE type)
int db_get_deep_copy_of_json(const DB_JSON *src, DB_JSON *dst)
DB_CURRENCY db_get_currency_default(void)
unsigned char compressed_need_clear
const char * db_default_expression_string(DB_DEFAULT_EXPR_TYPE default_expr_type)
char * db_get_json_raw_body(const DB_VALUE *value)
bool db_is_json_value_type(DB_TYPE type)
int db_value_clear(DB_VALUE *value)
DB_CURRENCY db_value_get_monetary_currency(const DB_VALUE *value)
#define DB_IS_NULL(value)
int db_value_domain_max(DB_VALUE *value, DB_TYPE type, const int precision, const int scale, const int codeset, const int collation_id, const DB_ENUMERATION *enumeration)
void db_value_fprint(FILE *fp, const DB_VALUE *value)
int db_value_coerce(const DB_VALUE *src, DB_VALUE *dest, const DB_DOMAIN *desired_domain)
int db_value_equal(const DB_VALUE *value1, const DB_VALUE *value2)
bool db_is_json_doc_type(DB_TYPE type)