432
uint Item::decimal_precision() const
432
uint32_t Item::decimal_precision() const
434
434
Item_result restype= result_type();
436
436
if ((restype == DECIMAL_RESULT) || (restype == INT_RESULT))
437
return min(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
437
return cmin(my_decimal_length_to_precision(max_length, decimals, unsigned_flag),
438
438
(unsigned int)DECIMAL_MAX_PRECISION);
439
return min(max_length, (uint32_t)DECIMAL_MAX_PRECISION);
439
return cmin(max_length, (uint32_t)DECIMAL_MAX_PRECISION);
917
917
int64_t value= val_int();
919
if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == -1LL)
919
if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == -1L)
921
921
char buff[22], *end;
922
922
end= int64_t10_to_str(value, buff, -10);
923
923
make_truncated_value_warning(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
924
924
buff, (int) (end-buff), DRIZZLE_TIMESTAMP_NONE,
1261
1261
bool agg_item_collations(DTCollation &c, const char *fname,
1262
Item **av, uint count, uint flags, int item_sep)
1262
Item **av, uint32_t count, uint32_t flags, int item_sep)
1266
1266
c.set(av[0]->collation);
1267
1267
for (i= 1, arg= &av[item_sep]; i < count; i++, arg++)
1285
1285
bool agg_item_collations_for_comparison(DTCollation &c, const char *fname,
1286
Item **av, uint count, uint flags)
1286
Item **av, uint32_t count, uint32_t flags)
1288
1288
return (agg_item_collations(c, fname, av, count,
1289
1289
flags | MY_COLL_DISALLOW_NONE, 1));
1324
1324
bool agg_item_charsets(DTCollation &coll, const char *fname,
1325
Item **args, uint nargs, uint flags, int item_sep)
1325
Item **args, uint32_t nargs, uint32_t flags, int item_sep)
1327
1327
Item **arg, *safe_args[2];
1420
1413
/**********************************************/
1422
1415
Item_field::Item_field(Field *f)
1423
:Item_ident(0, NullS, *f->table_name, f->field_name),
1416
:Item_ident(0, NULL, *f->table_name, f->field_name),
1424
1417
item_equal(0), no_const_subst(0),
1425
1418
have_privileges(0), any_privileges(0)
1521
1514
tmp=(char*) sql_alloc((uint) strlen(db_name)+(uint) strlen(table_name)+
1522
1515
(uint) strlen(field_name)+3);
1523
strxmov(tmp,db_name,".",table_name,".",field_name,NullS);
1516
strxmov(tmp,db_name,".",table_name,".",field_name,NULL);
1529
1522
tmp= (char*) sql_alloc((uint) strlen(table_name) +
1530
1523
(uint) strlen(field_name) + 2);
1531
strxmov(tmp, table_name, ".", field_name, NullS);
1524
strxmov(tmp, table_name, ".", field_name, NULL);
1534
1527
tmp= (char*) field_name;
1548
1541
if (table_name && table_name[0])
1550
stpcpy(t_name_buff, table_name);
1543
my_stpcpy(t_name_buff, table_name);
1551
1544
my_casedn_str(files_charset_info, t_name_buff);
1552
1545
t_name= t_name_buff;
1554
1547
if (db_name && db_name[0])
1556
stpcpy(d_name_buff, db_name);
1549
my_stpcpy(d_name_buff, db_name);
1557
1550
my_casedn_str(files_charset_info, d_name_buff);
1558
1551
d_name= d_name_buff;
1825
Item_uint::Item_uint(const char *str_arg, uint length):
1818
Item_uint::Item_uint(const char *str_arg, uint32_t length):
1826
1819
Item_int(str_arg, length)
1828
1821
unsigned_flag= 1;
1832
Item_uint::Item_uint(const char *str_arg, int64_t i, uint length):
1825
Item_uint::Item_uint(const char *str_arg, int64_t i, uint32_t length):
1833
1826
Item_int(str_arg, i, length)
1835
1828
unsigned_flag= 1;
1857
Item_decimal::Item_decimal(const char *str_arg, uint length,
1850
Item_decimal::Item_decimal(const char *str_arg, uint32_t length,
1858
1851
const CHARSET_INFO * const charset)
1860
1853
str2my_decimal(E_DEC_FATAL_ERROR, str_arg, length, charset, &decimal_value);
1911
Item_decimal::Item_decimal(const uchar *bin, int precision, int scale)
1904
Item_decimal::Item_decimal(const unsigned char *bin, int precision, int scale)
1913
1906
binary2my_decimal(E_DEC_FATAL_ERROR, bin,
1914
1907
&decimal_value, precision, scale);
2145
2138
default_set_param_func(Item_param *param,
2146
uchar **pos __attribute__((unused)),
2139
unsigned char **pos __attribute__((unused)),
2147
2140
ulong len __attribute__((unused)))
2149
2142
param->set_null();
2153
Item_param::Item_param(uint pos_in_query_arg) :
2146
Item_param::Item_param(uint32_t pos_in_query_arg) :
2154
2147
state(NO_VALUE),
2155
2148
item_result_type(STRING_RESULT),
2156
2149
/* Don't pretend to be a literal unless value for this item is set. */
2261
2255
value.time.minute > 59 || value.time.second > 59)
2263
2257
char buff[MAX_DATE_STRING_REP_LENGTH];
2264
uint length= my_TIME_to_str(&value.time, buff);
2258
uint32_t length= my_TIME_to_str(&value.time, buff);
2265
2259
make_truncated_value_warning(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2266
2260
buff, length, time_type, 0);
2267
2261
set_zero_time(&value.time, DRIZZLE_TIMESTAMP_ERROR);
3985
3979
/* Check whether we got a well-formed string */
3986
3980
const CHARSET_INFO * const cs= str->charset();
3987
3981
int well_formed_error;
3988
uint wlen= cs->cset->well_formed_len(cs,
3982
uint32_t wlen= cs->cset->well_formed_len(cs,
3989
3983
str->ptr(), str->ptr() + str->length(),
3990
3984
str->length(), &well_formed_error);
3991
3985
if (wlen < str->length())
4102
4096
The field functions defines a field to be not null if null_ptr is not 0
4104
uchar *null_ptr= maybe_null ? (uchar*) "" : 0;
4098
unsigned char *null_ptr= maybe_null ? (unsigned char*) "" : 0;
4107
4101
switch (field_type()) {
4108
4102
case DRIZZLE_TYPE_NEWDECIMAL:
4109
field= new Field_new_decimal((uchar*) 0, max_length, null_ptr, 0,
4103
field= new Field_new_decimal((unsigned char*) 0, max_length, null_ptr, 0,
4110
4104
Field::NONE, name, decimals, 0,
4111
4105
unsigned_flag);
4113
4107
case DRIZZLE_TYPE_TINY:
4114
field= new Field_tiny((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4108
field= new Field_tiny((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
4115
4109
name, 0, unsigned_flag);
4117
case DRIZZLE_TYPE_SHORT:
4118
field= new Field_short((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4119
name, 0, unsigned_flag);
4121
4111
case DRIZZLE_TYPE_LONG:
4122
field= new Field_long((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4112
field= new Field_long((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
4123
4113
name, 0, unsigned_flag);
4125
4115
case DRIZZLE_TYPE_LONGLONG:
4126
field= new Field_int64_t((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4116
field= new Field_int64_t((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
4127
4117
name, 0, unsigned_flag);
4129
4119
case DRIZZLE_TYPE_DOUBLE:
4130
field= new Field_double((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4120
field= new Field_double((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
4131
4121
name, decimals, 0, unsigned_flag);
4133
4123
case DRIZZLE_TYPE_NULL:
4134
field= new Field_null((uchar*) 0, max_length, Field::NONE,
4124
field= new Field_null((unsigned char*) 0, max_length, Field::NONE,
4135
4125
name, &my_charset_bin);
4137
4127
case DRIZZLE_TYPE_NEWDATE:
4525
4515
// following assert is redundant, because fixed=1 assigned in constructor
4526
4516
assert(fixed == 1);
4527
4517
char *end=(char*) str_value.ptr()+str_value.length(),
4528
*ptr=end-min(str_value.length(),(uint32_t)sizeof(int64_t));
4518
*ptr=end-cmin(str_value.length(),(uint32_t)sizeof(int64_t));
4530
4520
uint64_t value=0;
4531
4521
for (; ptr != end ; ptr++)
4532
value=(value << 8)+ (uint64_t) (uchar) *ptr;
4522
value=(value << 8)+ (uint64_t) (unsigned char) *ptr;
4533
4523
return (int64_t) value;
4579
4569
enum_query_type query_type __attribute__((unused)))
4581
4571
char *end= (char*) str_value.ptr() + str_value.length(),
4582
*ptr= end - min(str_value.length(), (uint32_t)sizeof(int64_t));
4572
*ptr= end - cmin(str_value.length(), (uint32_t)sizeof(int64_t));
4583
4573
str->append("0x");
4584
4574
for (; ptr != end ; ptr++)
4586
str->append(_dig_vec_lower[((uchar) *ptr) >> 4]);
4587
str->append(_dig_vec_lower[((uchar) *ptr) & 0x0F]);
4576
str->append(_dig_vec_lower[((unsigned char) *ptr) >> 4]);
4577
str->append(_dig_vec_lower[((unsigned char) *ptr) & 0x0F]);
4620
4610
In number context this is a int64_t value.
4623
Item_bin_string::Item_bin_string(const char *str, uint str_length)
4613
Item_bin_string::Item_bin_string(const char *str, uint32_t str_length)
4625
4615
const char *end= str + str_length - 1;
4616
unsigned char bits= 0;
4629
4619
max_length= (str_length + 7) >> 3;
4630
4620
char *ptr= (char*) sql_alloc(max_length + 1);
4838
4820
Item **item, const char *table_name_arg,
4839
4821
const char *field_name_arg,
4840
4822
bool alias_name_used_arg)
4841
:Item_ident(context_arg, NullS, table_name_arg, field_name_arg),
4823
:Item_ident(context_arg, NULL, table_name_arg, field_name_arg),
4842
4824
result_field(0), ref(item)
4844
4826
alias_name_used= alias_name_used_arg;
5815
5797
case REAL_RESULT:
5816
5798
{ // It must REAL_RESULT
5817
5799
double result= item->val_real();
5818
uint length=item->max_length,decimals=item->decimals;
5800
uint32_t length=item->max_length,decimals=item->decimals;
5819
5801
bool null_value=item->null_value;
5820
5802
new_item= (null_value ? (Item*) new Item_null(name) : (Item*)
5821
5803
new Item_float(name, result, decimals, length));
6271
6253
bool Item_type_holder::join_types(THD *thd __attribute__((unused)),
6274
uint max_length_orig= max_length;
6275
uint decimals_orig= decimals;
6256
uint32_t max_length_orig= max_length;
6257
uint32_t decimals_orig= decimals;
6276
6258
fld_type= Field::field_type_merge(fld_type, get_real_type(item));
6278
6260
int item_decimals= item->decimals;
6279
6261
/* fix variable decimals which always is NOT_FIXED_DEC */
6280
6262
if (Field::result_merge_type(fld_type) == INT_RESULT)
6281
6263
item_decimals= 0;
6282
decimals= max((int)decimals, item_decimals);
6264
decimals= cmax((int)decimals, item_decimals);
6284
6266
if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
6286
decimals= min((int)max(decimals, item->decimals), DECIMAL_MAX_SCALE);
6287
int precision= min(max(prev_decimal_int_part, item->decimal_int_part())
6268
decimals= cmin((int)cmax(decimals, item->decimals), DECIMAL_MAX_SCALE);
6269
int precision= cmin(cmax(prev_decimal_int_part, item->decimal_int_part())
6288
6270
+ decimals, DECIMAL_MAX_PRECISION);
6289
6271
unsigned_flag&= item->unsigned_flag;
6290
6272
max_length= my_decimal_precision_to_length(precision, decimals,
6411
6391
The field functions defines a field to be not null if null_ptr is not 0
6413
uchar *null_ptr= maybe_null ? (uchar*) "" : 0;
6393
unsigned char *null_ptr= maybe_null ? (unsigned char*) "" : 0;
6416
6396
switch (fld_type) {
6417
6397
case DRIZZLE_TYPE_ENUM:
6418
6398
assert(enum_set_typelib);
6419
field= new Field_enum((uchar *) 0, max_length, null_ptr, 0,
6399
field= new Field_enum((unsigned char *) 0, max_length, null_ptr, 0,
6420
6400
Field::NONE, name,
6421
6401
get_enum_pack_length(enum_set_typelib->count),
6422
6402
enum_set_typelib, collation.collation);