661
661
column read set or to register used fields in a view
664
bool Item_field::register_field_in_read_map(unsigned char *arg)
664
bool Item_field::register_field_in_read_map(uchar *arg)
666
Table *table= (Table *) arg;
666
TABLE *table= (TABLE *) arg;
667
667
if (field->table == table || !table)
668
668
bitmap_set_bit(field->table->read_set, field->field_index);
669
if (field->vcol_info && field->vcol_info->expr_item)
670
return field->vcol_info->expr_item->walk(&Item::register_field_in_read_map,
676
Mark field in bitmap supplied as *arg
680
bool Item_field::register_field_in_bitmap(unsigned char *arg)
682
MY_BITMAP *bitmap= (MY_BITMAP *) arg;
684
bitmap_set_bit(bitmap, field->field_index);
689
bool Item::check_cols(uint32_t c)
673
bool Item::check_cols(uint c)
909
893
String tmp(buff,sizeof(buff), &my_charset_bin),*res;
910
894
if (!(res=val_str(&tmp)) ||
911
895
str_to_datetime_with_warn(res->ptr(), res->length(),
912
ltime, fuzzydate) <= DRIZZLE_TIMESTAMP_ERROR)
896
ltime, fuzzydate) <= MYSQL_TIMESTAMP_ERROR)
917
int64_t value= val_int();
901
longlong value= val_int();
919
if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == -1L)
903
if (number_to_datetime(value, ltime, fuzzydate, &was_cut) == -1LL)
921
905
char buff[22], *end;
922
end= int64_t10_to_str(value, buff, -10);
923
make_truncated_value_warning(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
924
buff, (int) (end-buff), DRIZZLE_TIMESTAMP_NONE,
906
end= longlong10_to_str(value, buff, -10);
907
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
908
buff, (int) (end-buff), MYSQL_TIMESTAMP_NONE,
932
memset(ltime, 0, sizeof(*ltime));
916
bzero((char*) ltime,sizeof(*ltime));
969
953
int Item::save_in_field_no_warnings(Field *field, bool no_conversions)
972
Table *table= field->table;
956
TABLE *table= field->table;
973
957
THD *thd= table->in_use;
974
958
enum_check_fields tmp= thd->count_cuted_fields;
959
my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->write_set);
975
960
ulong sql_mode= thd->variables.sql_mode;
976
thd->variables.sql_mode&= ~(MODE_NO_ZERO_DATE);
961
thd->variables.sql_mode&= ~(MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE);
977
962
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
978
963
res= save_in_field(field, no_conversions);
979
964
thd->count_cuted_fields= tmp;
965
dbug_tmp_restore_column_map(table->write_set, old_map);
980
966
thd->variables.sql_mode= sql_mode;
1627
1620
return result_field->val_str(str,&str_value);
1630
bool Item_field::get_date(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
1623
bool Item_field::get_date(MYSQL_TIME *ltime,uint fuzzydate)
1632
1625
if ((null_value=field->is_null()) || field->get_date(ltime,fuzzydate))
1634
memset(ltime, 0, sizeof(*ltime));
1627
bzero((char*) ltime,sizeof(*ltime));
1640
bool Item_field::get_date_result(DRIZZLE_TIME *ltime,uint32_t fuzzydate)
1633
bool Item_field::get_date_result(MYSQL_TIME *ltime,uint fuzzydate)
1642
1635
if ((null_value=result_field->is_null()) ||
1643
1636
result_field->get_date(ltime,fuzzydate))
1645
memset(ltime, 0, sizeof(*ltime));
1638
bzero((char*) ltime,sizeof(*ltime));
1651
bool Item_field::get_time(DRIZZLE_TIME *ltime)
1644
bool Item_field::get_time(MYSQL_TIME *ltime)
1653
1646
if ((null_value=field->is_null()) || field->get_time(ltime))
1655
memset(ltime, 0, sizeof(*ltime));
1648
bzero((char*) ltime,sizeof(*ltime));
1768
1761
return new_item;
1771
int64_t Item_field::val_int_endpoint(bool left_endp __attribute__((unused)),
1772
bool *incl_endp __attribute__((unused)))
1764
longlong Item_field::val_int_endpoint(bool left_endp __attribute__((__unused__)),
1765
bool *incl_endp __attribute__((__unused__)))
1774
int64_t res= val_int();
1775
return null_value? INT64_MIN : res;
1767
longlong res= val_int();
1768
return null_value? LONGLONG_MIN : res;
1779
Create an item from a string we KNOW points to a valid int64_t
1772
Create an item from a string we KNOW points to a valid longlong
1780
1773
end \\0 terminated number string.
1781
1774
This is always 'signed'. Unsigned values are created with Item_uint()
1784
Item_int::Item_int(const char *str_arg, uint32_t length)
1777
Item_int::Item_int(const char *str_arg, uint length)
1786
1779
char *end_ptr= (char*) str_arg + length;
1834
1827
// following assert is redundant, because fixed=1 assigned in constructor
1835
1828
assert(fixed == 1);
1836
str->set((uint64_t) value, &my_charset_bin);
1829
str->set((ulonglong) value, &my_charset_bin);
1841
1834
void Item_uint::print(String *str,
1842
enum_query_type query_type __attribute__((unused)))
1835
enum_query_type query_type __attribute__((__unused__)))
1844
1837
// latin1 is good enough for numbers
1845
str_value.set((uint64_t) value, default_charset());
1838
str_value.set((ulonglong) value, default_charset());
1846
1839
str->append(str_value);
1850
Item_decimal::Item_decimal(const char *str_arg, uint32_t length,
1851
const CHARSET_INFO * const charset)
1843
Item_decimal::Item_decimal(const char *str_arg, uint length,
1844
CHARSET_INFO *charset)
1853
1846
str2my_decimal(E_DEC_FATAL_ERROR, str_arg, length, charset, &decimal_value);
1854
1847
name= (char*) str_arg;
1855
decimals= (uint8_t) decimal_value.frac;
1848
decimals= (uint8) decimal_value.frac;
1857
1850
max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
1858
1851
decimals, unsigned_flag);
1861
Item_decimal::Item_decimal(int64_t val, bool unsig)
1854
Item_decimal::Item_decimal(longlong val, bool unsig)
1863
1856
int2my_decimal(E_DEC_FATAL_ERROR, val, unsig, &decimal_value);
1864
decimals= (uint8_t) decimal_value.frac;
1857
decimals= (uint8) decimal_value.frac;
1866
1859
max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
1867
1860
decimals, unsigned_flag);
1894
1887
Item_decimal::Item_decimal(my_decimal *value_par)
1896
1889
my_decimal2decimal(value_par, &decimal_value);
1897
decimals= (uint8_t) decimal_value.frac;
1890
decimals= (uint8) decimal_value.frac;
1899
1892
max_length= my_decimal_precision_to_length(decimal_value.intg + decimals,
1900
1893
decimals, unsigned_flag);
1904
Item_decimal::Item_decimal(const unsigned char *bin, int precision, int scale)
1897
Item_decimal::Item_decimal(const uchar *bin, int precision, int scale)
1906
1899
binary2my_decimal(E_DEC_FATAL_ERROR, bin,
1907
1900
&decimal_value, precision, scale);
1908
decimals= (uint8_t) decimal_value.frac;
1901
decimals= (uint8) decimal_value.frac;
1910
1903
max_length= my_decimal_precision_to_length(precision, decimals,
1911
1904
unsigned_flag);
1915
int64_t Item_decimal::val_int()
1908
longlong Item_decimal::val_int()
1918
1911
my_decimal2int(E_DEC_FATAL_ERROR, &decimal_value, unsigned_flag, &result);
2138
2131
default_set_param_func(Item_param *param,
2139
unsigned char **pos __attribute__((unused)),
2132
uchar **pos __attribute__((unused)),
2140
2133
ulong len __attribute__((unused)))
2142
2135
param->set_null();
2146
Item_param::Item_param(uint32_t pos_in_query_arg) :
2139
Item_param::Item_param(uint pos_in_query_arg) :
2147
2140
state(NO_VALUE),
2148
2141
item_result_type(STRING_RESULT),
2149
2142
/* Don't pretend to be a literal unless value for this item is set. */
2150
2143
item_type(PARAM_ITEM),
2151
param_type(DRIZZLE_TYPE_VARCHAR),
2144
param_type(MYSQL_TYPE_VARCHAR),
2152
2145
pos_in_query(pos_in_query_arg),
2153
2146
set_param_func(default_set_param_func),
2154
2147
limit_clause_param(false)
2242
2235
the fact that even wrong value sent over binary protocol fits into
2243
2236
MAX_DATE_STRING_REP_LENGTH buffer.
2245
void Item_param::set_time(DRIZZLE_TIME *tm,
2246
enum enum_drizzle_timestamp_type time_type,
2247
uint32_t max_length_arg)
2238
void Item_param::set_time(MYSQL_TIME *tm, timestamp_type time_type,
2239
uint32 max_length_arg)
2249
2241
value.time= *tm;
2250
2242
value.time.time_type= time_type;
2252
2244
if (value.time.year > 9999 || value.time.month > 12 ||
2253
2245
value.time.day > 31 ||
2254
((time_type != DRIZZLE_TIMESTAMP_TIME) && value.time.hour > 23) ||
2246
((time_type != MYSQL_TIMESTAMP_TIME) && value.time.hour > 23) ||
2255
2247
value.time.minute > 59 || value.time.second > 59)
2257
2249
char buff[MAX_DATE_STRING_REP_LENGTH];
2258
uint32_t length= my_TIME_to_str(&value.time, buff);
2259
make_truncated_value_warning(current_thd, DRIZZLE_ERROR::WARN_LEVEL_WARN,
2250
uint length= my_TIME_to_str(&value.time, buff);
2251
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
2260
2252
buff, length, time_type, 0);
2261
set_zero_time(&value.time, DRIZZLE_TIMESTAMP_ERROR);
2253
set_zero_time(&value.time, MYSQL_TIMESTAMP_ERROR);
2264
2256
state= TIME_VALUE;
2925
2917
current->mark_as_dependent(last);
2926
2918
if (thd->lex->describe & DESCRIBE_EXTENDED)
2928
char warn_buff[DRIZZLE_ERRMSG_SIZE];
2920
char warn_buff[MYSQL_ERRMSG_SIZE];
2929
2921
sprintf(warn_buff, ER(ER_WARN_FIELD_RESOLVED),
2930
2922
db_name, (db_name[0] ? "." : ""),
2931
2923
table_name, (table_name [0] ? "." : ""),
2932
2924
resolved_item->field_name,
2933
2925
current->select_number, last->select_number);
2934
push_warning(thd, DRIZZLE_ERROR::WARN_LEVEL_NOTE,
2926
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
2935
2927
ER_WARN_FIELD_RESOLVED, warn_buff);
3787
3779
false otherwise
3790
bool Item_field::subst_argument_checker(unsigned char **arg)
3782
bool Item_field::subst_argument_checker(uchar **arg)
3792
3784
return (result_type() != STRING_RESULT) || (*arg);
3789
Convert a numeric value to a zero-filled string
3791
@param[in,out] item the item to operate on
3792
@param field The field that this value is equated to
3794
This function converts a numeric value to a string. In this conversion
3795
the zero-fill flag of the field is taken into account.
3796
This is required so the resulting string value can be used instead of
3797
the field reference when propagating equalities.
3800
static void convert_zerofill_number_to_string(Item **item, Field_num *field)
3802
char buff[MAX_FIELD_WIDTH],*pos;
3803
String tmp(buff,sizeof(buff), field->charset()), *res;
3805
res= (*item)->val_str(&tmp);
3806
field->prepend_zeros(res);
3807
pos= (char *) sql_strmake (res->ptr(), res->length());
3808
*item= new Item_string(pos, res->length(), field->charset());
3797
3813
Set a pointer to the multiple equality the field reference belongs to
3975
3999
String *Item::check_well_formed_result(String *str, bool send_error)
3977
4001
/* Check whether we got a well-formed string */
3978
const CHARSET_INFO * const cs= str->charset();
4002
CHARSET_INFO *cs= str->charset();
3979
4003
int well_formed_error;
3980
uint32_t wlen= cs->cset->well_formed_len(cs,
4004
uint wlen= cs->cset->well_formed_len(cs,
3981
4005
str->ptr(), str->ptr() + str->length(),
3982
4006
str->length(), &well_formed_error);
3983
4007
if (wlen < str->length())
3985
4009
THD *thd= current_thd;
3986
4010
char hexbuf[7];
3987
enum DRIZZLE_ERROR::enum_warning_level level;
3988
uint32_t diff= str->length() - wlen;
4011
enum MYSQL_ERROR::enum_warning_level level;
4012
uint diff= str->length() - wlen;
3989
4013
set_if_smaller(diff, 3);
3990
4014
octet2hex(hexbuf, str->ptr() + wlen, diff);
3991
4015
if (send_error)
4059
4083
@param table Table for which the field is created
4062
Field *Item::make_string_field(Table *table)
4086
Field *Item::make_string_field(TABLE *table)
4065
4089
assert(collation.collation);
4066
4090
if (max_length/collation.collation->mbmaxlen > CONVERT_IF_BIGGER_TO_BLOB)
4067
4091
field= new Field_blob(max_length, maybe_null, name,
4068
4092
collation.collation);
4093
/* Item_type_holder holds the exact type, do not change it */
4094
else if (max_length > 0 &&
4095
(type() != Item::TYPE_HOLDER || field_type() != MYSQL_TYPE_STRING))
4070
4096
field= new Field_varstring(max_length, maybe_null, name, table->s,
4071
4097
collation.collation);
4099
field= new Field_string(max_length, maybe_null, name,
4100
collation.collation);
4074
4102
field->init(table);
4088
4116
\# Created field
4091
Field *Item::tmp_table_field_from_field_type(Table *table, bool fixed_length __attribute__((unused)))
4119
Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length)
4094
4122
The field functions defines a field to be not null if null_ptr is not 0
4096
unsigned char *null_ptr= maybe_null ? (unsigned char*) "" : 0;
4124
uchar *null_ptr= maybe_null ? (uchar*) "" : 0;
4099
4127
switch (field_type()) {
4100
case DRIZZLE_TYPE_NEWDECIMAL:
4101
field= new Field_new_decimal((unsigned char*) 0, max_length, null_ptr, 0,
4128
case MYSQL_TYPE_NEWDECIMAL:
4129
field= new Field_new_decimal((uchar*) 0, max_length, null_ptr, 0,
4102
4130
Field::NONE, name, decimals, 0,
4103
4131
unsigned_flag);
4105
case DRIZZLE_TYPE_TINY:
4106
field= new Field_tiny((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
4107
name, 0, unsigned_flag);
4109
case DRIZZLE_TYPE_LONG:
4110
field= new Field_long((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
4111
name, 0, unsigned_flag);
4113
case DRIZZLE_TYPE_LONGLONG:
4114
field= new Field_int64_t((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
4133
case MYSQL_TYPE_TINY:
4134
field= new Field_tiny((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4135
name, 0, unsigned_flag);
4137
case MYSQL_TYPE_SHORT:
4138
field= new Field_short((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4139
name, 0, unsigned_flag);
4141
case MYSQL_TYPE_LONG:
4142
field= new Field_long((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4143
name, 0, unsigned_flag);
4145
case MYSQL_TYPE_LONGLONG:
4146
field= new Field_longlong((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4115
4147
name, 0, unsigned_flag);
4117
case DRIZZLE_TYPE_DOUBLE:
4118
field= new Field_double((unsigned char*) 0, max_length, null_ptr, 0, Field::NONE,
4149
case MYSQL_TYPE_FLOAT:
4150
field= new Field_float((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4151
name, decimals, 0, unsigned_flag);
4153
case MYSQL_TYPE_DOUBLE:
4154
field= new Field_double((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4119
4155
name, decimals, 0, unsigned_flag);
4121
case DRIZZLE_TYPE_NULL:
4122
field= new Field_null((unsigned char*) 0, max_length, Field::NONE,
4157
case MYSQL_TYPE_NULL:
4158
field= new Field_null((uchar*) 0, max_length, Field::NONE,
4123
4159
name, &my_charset_bin);
4125
case DRIZZLE_TYPE_NEWDATE:
4161
case MYSQL_TYPE_NEWDATE:
4126
4162
field= new Field_newdate(maybe_null, name, &my_charset_bin);
4128
case DRIZZLE_TYPE_TIME:
4164
case MYSQL_TYPE_TIME:
4129
4165
field= new Field_time(maybe_null, name, &my_charset_bin);
4131
case DRIZZLE_TYPE_TIMESTAMP:
4167
case MYSQL_TYPE_TIMESTAMP:
4132
4168
field= new Field_timestamp(maybe_null, name, &my_charset_bin);
4134
case DRIZZLE_TYPE_DATETIME:
4170
case MYSQL_TYPE_DATETIME:
4135
4171
field= new Field_datetime(maybe_null, name, &my_charset_bin);
4173
case MYSQL_TYPE_YEAR:
4174
field= new Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE,
4138
4178
/* This case should never be chosen */
4180
/* If something goes awfully wrong, it's better to get a string than die */
4181
case MYSQL_TYPE_STRING:
4182
if (fixed_length && max_length < CONVERT_IF_BIGGER_TO_BLOB)
4184
field= new Field_string(max_length, maybe_null, name,
4185
collation.collation);
4140
4188
/* Fall through to make_string_field() */
4141
case DRIZZLE_TYPE_ENUM:
4142
case DRIZZLE_TYPE_VARCHAR:
4189
case MYSQL_TYPE_ENUM:
4190
case MYSQL_TYPE_SET:
4191
case MYSQL_TYPE_VAR_STRING:
4192
case MYSQL_TYPE_VARCHAR:
4143
4193
return make_string_field(table);
4144
case DRIZZLE_TYPE_BLOB:
4194
case MYSQL_TYPE_BLOB:
4145
4195
if (this->type() == Item::TYPE_HOLDER)
4146
4196
field= new Field_blob(max_length, maybe_null, name, collation.collation,
4527
4577
// following assert is redundant, because fixed=1 assigned in constructor
4528
4578
assert(fixed == 1);
4529
uint64_t value= (uint64_t)val_int();
4579
ulonglong value= (ulonglong)val_int();
4530
4580
int2my_decimal(E_DEC_FATAL_ERROR, value, true, decimal_value);
4531
4581
return (decimal_value);
4535
4585
int Item_hex_string::save_in_field(Field *field,
4536
bool no_conversions __attribute__((unused)))
4586
bool no_conversions __attribute__((__unused__)))
4538
4588
field->set_notnull();
4539
4589
if (field->result_type() == STRING_RESULT)
4540
4590
return field->store(str_value.ptr(), str_value.length(),
4541
4591
collation.collation);
4544
uint32_t length= str_value.length();
4594
uint32 length= str_value.length();
4545
4595
if (length > 8)
4547
nr= field->flags & UNSIGNED_FLAG ? UINT64_MAX : INT64_MAX;
4597
nr= field->flags & UNSIGNED_FLAG ? ULONGLONG_MAX : LONGLONG_MAX;
4550
nr= (uint64_t) val_int();
4551
if ((length == 8) && !(field->flags & UNSIGNED_FLAG) && (nr > INT64_MAX))
4600
nr= (ulonglong) val_int();
4601
if ((length == 8) && !(field->flags & UNSIGNED_FLAG) && (nr > LONGLONG_MAX))
4556
return field->store((int64_t) nr, true); // Assume hex numbers are unsigned
4606
return field->store((longlong) nr, true); // Assume hex numbers are unsigned
4559
if (!field->store((int64_t) nr, true))
4560
field->set_warning(DRIZZLE_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE,
4609
if (!field->store((longlong) nr, true))
4610
field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE,
4566
4616
void Item_hex_string::print(String *str,
4567
enum_query_type query_type __attribute__((unused)))
4617
enum_query_type query_type __attribute__((__unused__)))
4569
4619
char *end= (char*) str_value.ptr() + str_value.length(),
4570
*ptr= end - cmin(str_value.length(), (uint32_t)sizeof(int64_t));
4620
*ptr= end - min(str_value.length(), sizeof(longlong));
4571
4621
str->append("0x");
4572
4622
for (; ptr != end ; ptr++)
4574
str->append(_dig_vec_lower[((unsigned char) *ptr) >> 4]);
4575
str->append(_dig_vec_lower[((unsigned char) *ptr) & 0x0F]);
4624
str->append(_dig_vec_lower[((uchar) *ptr) >> 4]);
4625
str->append(_dig_vec_lower[((uchar) *ptr) & 0x0F]);
4661
4711
switch ((f_type=field_type())) {
4663
case DRIZZLE_TYPE_NULL:
4664
case DRIZZLE_TYPE_ENUM:
4665
case DRIZZLE_TYPE_BLOB:
4666
case DRIZZLE_TYPE_VARCHAR:
4667
case DRIZZLE_TYPE_NEWDECIMAL:
4713
case MYSQL_TYPE_NULL:
4714
case MYSQL_TYPE_ENUM:
4715
case MYSQL_TYPE_SET:
4716
case MYSQL_TYPE_BLOB:
4717
case MYSQL_TYPE_STRING:
4718
case MYSQL_TYPE_VAR_STRING:
4719
case MYSQL_TYPE_VARCHAR:
4720
case MYSQL_TYPE_NEWDECIMAL:
4670
4723
if ((res=val_str(buffer)))
4671
4724
result= protocol->store(res->ptr(),res->length(),res->charset());
4674
case DRIZZLE_TYPE_TINY:
4727
case MYSQL_TYPE_TINY:
4678
4731
if (!null_value)
4679
4732
result= protocol->store_tiny(nr);
4682
case DRIZZLE_TYPE_LONG:
4735
case MYSQL_TYPE_SHORT:
4736
case MYSQL_TYPE_YEAR:
4741
result= protocol->store_short(nr);
4744
case MYSQL_TYPE_LONG:
4686
4748
if (!null_value)
4687
4749
result= protocol->store_long(nr);
4690
case DRIZZLE_TYPE_LONGLONG:
4752
case MYSQL_TYPE_LONGLONG:
4694
4756
if (!null_value)
4695
result= protocol->store_int64_t(nr, unsigned_flag);
4698
case DRIZZLE_TYPE_DOUBLE:
4757
result= protocol->store_longlong(nr, unsigned_flag);
4760
case MYSQL_TYPE_FLOAT:
4763
nr= (float) val_real();
4765
result= protocol->store(nr, decimals, buffer);
4768
case MYSQL_TYPE_DOUBLE:
4700
4770
double nr= val_real();
4701
4771
if (!null_value)
4702
4772
result= protocol->store(nr, decimals, buffer);
4705
case DRIZZLE_TYPE_DATETIME:
4706
case DRIZZLE_TYPE_TIMESTAMP:
4775
case MYSQL_TYPE_DATETIME:
4776
case MYSQL_TYPE_TIMESTAMP:
4709
4779
get_date(&tm, TIME_FUZZY_DATE);
4710
4780
if (!null_value)
4712
if (f_type == DRIZZLE_TYPE_NEWDATE)
4782
if (f_type == MYSQL_TYPE_NEWDATE)
4713
4783
return protocol->store_date(&tm);
4715
4785
result= protocol->store(&tm);
4719
case DRIZZLE_TYPE_TIME:
4789
case MYSQL_TYPE_TIME:
4723
4793
if (!null_value)
4724
4794
result= protocol->store_time(&tm);
6251
bool Item_type_holder::join_types(THD *thd __attribute__((unused)),
6325
bool Item_type_holder::join_types(THD *thd __attribute__((__unused__)),
6254
uint32_t max_length_orig= max_length;
6255
uint32_t decimals_orig= decimals;
6328
uint max_length_orig= max_length;
6329
uint decimals_orig= decimals;
6256
6330
fld_type= Field::field_type_merge(fld_type, get_real_type(item));
6258
6332
int item_decimals= item->decimals;
6259
6333
/* fix variable decimals which always is NOT_FIXED_DEC */
6260
6334
if (Field::result_merge_type(fld_type) == INT_RESULT)
6261
6335
item_decimals= 0;
6262
decimals= cmax((int)decimals, item_decimals);
6336
decimals= max(decimals, item_decimals);
6264
6338
if (Field::result_merge_type(fld_type) == DECIMAL_RESULT)
6266
decimals= cmin((int)cmax(decimals, item->decimals), DECIMAL_MAX_SCALE);
6267
int precision= cmin(cmax(prev_decimal_int_part, item->decimal_int_part())
6340
decimals= min(max(decimals, item->decimals), DECIMAL_MAX_SCALE);
6341
int precision= min(max(prev_decimal_int_part, item->decimal_int_part())
6268
6342
+ decimals, DECIMAL_MAX_PRECISION);
6269
6343
unsigned_flag&= item->unsigned_flag;
6270
6344
max_length= my_decimal_precision_to_length(precision, decimals,
6344
uint32_t Item_type_holder::display_length(Item *item)
6423
uint32 Item_type_holder::display_length(Item *item)
6346
6425
if (item->type() == Item::FIELD_ITEM)
6347
6426
return ((Item_field *)item)->max_disp_length();
6349
6428
switch (item->field_type())
6351
case DRIZZLE_TYPE_TIMESTAMP:
6352
case DRIZZLE_TYPE_TIME:
6353
case DRIZZLE_TYPE_DATETIME:
6354
case DRIZZLE_TYPE_NEWDATE:
6355
case DRIZZLE_TYPE_VARCHAR:
6356
case DRIZZLE_TYPE_NEWDECIMAL:
6357
case DRIZZLE_TYPE_ENUM:
6358
case DRIZZLE_TYPE_BLOB:
6359
case DRIZZLE_TYPE_TINY:
6430
case MYSQL_TYPE_TIMESTAMP:
6431
case MYSQL_TYPE_TIME:
6432
case MYSQL_TYPE_DATETIME:
6433
case MYSQL_TYPE_YEAR:
6434
case MYSQL_TYPE_NEWDATE:
6435
case MYSQL_TYPE_VARCHAR:
6436
case MYSQL_TYPE_NEWDECIMAL:
6437
case MYSQL_TYPE_ENUM:
6438
case MYSQL_TYPE_SET:
6439
case MYSQL_TYPE_BLOB:
6440
case MYSQL_TYPE_VAR_STRING:
6441
case MYSQL_TYPE_STRING:
6442
case MYSQL_TYPE_TINY:
6361
case DRIZZLE_TYPE_LONG:
6444
case MYSQL_TYPE_SHORT:
6446
case MYSQL_TYPE_LONG:
6362
6447
return MY_INT32_NUM_DECIMAL_DIGITS;
6363
case DRIZZLE_TYPE_DOUBLE:
6448
case MYSQL_TYPE_FLOAT:
6450
case MYSQL_TYPE_DOUBLE:
6365
case DRIZZLE_TYPE_NULL:
6452
case MYSQL_TYPE_NULL:
6367
case DRIZZLE_TYPE_LONGLONG:
6454
case MYSQL_TYPE_LONGLONG:
6370
6457
assert(0); // we should never go there
6386
Field *Item_type_holder::make_field_by_type(Table *table)
6473
Field *Item_type_holder::make_field_by_type(TABLE *table)
6389
6476
The field functions defines a field to be not null if null_ptr is not 0
6391
unsigned char *null_ptr= maybe_null ? (unsigned char*) "" : 0;
6478
uchar *null_ptr= maybe_null ? (uchar*) "" : 0;
6394
6481
switch (fld_type) {
6395
case DRIZZLE_TYPE_ENUM:
6482
case MYSQL_TYPE_ENUM:
6396
6483
assert(enum_set_typelib);
6397
field= new Field_enum((unsigned char *) 0, max_length, null_ptr, 0,
6484
field= new Field_enum((uchar *) 0, max_length, null_ptr, 0,
6398
6485
Field::NONE, name,
6399
6486
get_enum_pack_length(enum_set_typelib->count),
6400
6487
enum_set_typelib, collation.collation);
6402
6489
field->init(table);
6404
case DRIZZLE_TYPE_NULL:
6491
case MYSQL_TYPE_SET:
6492
assert(enum_set_typelib);
6493
field= new Field_set((uchar *) 0, max_length, null_ptr, 0,
6495
get_set_pack_length(enum_set_typelib->count),
6496
enum_set_typelib, collation.collation);
6500
case MYSQL_TYPE_NULL:
6405
6501
return make_string_field(table);