288
287
CHARSET_INFO *cs= &my_charset_bin;
290
289
if (!sub_pattern_end)
291
bzero((char*) l_time, sizeof(*l_time));
290
memset((char*) l_time, 0, sizeof(*l_time));
293
292
for (; ptr != end && val != val_end; ptr++)
885
884
/* Change values[0...i-1] -> values[0...count-1] */
886
885
bmove_upp((uchar*) (values+count), (uchar*) (values+i),
887
886
sizeof(*values)*i);
888
bzero((uchar*) values, sizeof(*values)*(count-i));
887
memset((uchar*) values, 0, sizeof(*values)*(count-i));
951
950
if (args[0]->type() == Item::FIELD_ITEM)
953
if (args[0]->field_type() == MYSQL_TYPE_NEWDATE)
952
if (args[0]->field_type() == DRIZZLE_TYPE_NEWDATE)
954
953
return MONOTONIC_STRICT_INCREASING;
955
if (args[0]->field_type() == MYSQL_TYPE_DATETIME)
954
if (args[0]->field_type() == DRIZZLE_TYPE_DATETIME)
956
955
return MONOTONIC_INCREASING;
958
957
return NON_MONOTONIC;
972
971
res=(int64_t) calc_daynr(ltime.year,ltime.month,ltime.day);
974
if (args[0]->field_type() == MYSQL_TYPE_NEWDATE)
973
if (args[0]->field_type() == DRIZZLE_TYPE_NEWDATE)
976
975
// TO_DAYS() is strictly monotonic for dates, leave incl_endp intact
1206
1205
enum_monotonicity_info Item_func_year::get_monotonicity_info() const
1208
1207
if (args[0]->type() == Item::FIELD_ITEM &&
1209
(args[0]->field_type() == MYSQL_TYPE_NEWDATE ||
1210
args[0]->field_type() == MYSQL_TYPE_DATETIME))
1208
(args[0]->field_type() == DRIZZLE_TYPE_NEWDATE ||
1209
args[0]->field_type() == DRIZZLE_TYPE_DATETIME))
1211
1210
return MONOTONIC_INCREASING;
1212
1211
return NON_MONOTONIC;
1254
1253
if (args[0]->type() == FIELD_ITEM)
1255
1254
{ // Optimize timestamp field
1256
1255
Field *field=((Item_field*) args[0])->field;
1257
if (field->type() == MYSQL_TYPE_TIMESTAMP)
1256
if (field->type() == DRIZZLE_TYPE_TIMESTAMP)
1258
1257
return ((Field_timestamp*) field)->get_timestamp(&null_value);
1299
1298
size_t length= 0;
1300
1299
CHARSET_INFO *cs=str_value->charset();
1302
bzero((char*) interval,sizeof(*interval));
1301
memset((char*) interval, 0, sizeof(*interval));
1303
1302
if ((int) int_type <= INTERVAL_MICROSECOND)
1305
1304
value= args->val_int();
1471
bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date __attribute__((__unused__)))
1470
bool Item_func_from_days::get_date(MYSQL_TIME *ltime, uint fuzzy_date __attribute__((unused)))
1473
1472
int64_t value=args[0]->val_int();
1474
1473
if ((null_value=args[0]->null_value))
1476
bzero(ltime, sizeof(MYSQL_TIME));
1475
memset(ltime, 0, sizeof(MYSQL_TIME));
1477
1476
get_date_from_daynr((long) value, <ime->year, <ime->month, <ime->day);
1478
1477
ltime->time_type= MYSQL_TIMESTAMP_DATE;
1651
int Item_func_now::save_in_field(Field *to, bool no_conversions __attribute__((__unused__)))
1650
int Item_func_now::save_in_field(Field *to, bool no_conversions __attribute__((unused)))
1653
1652
to->set_notnull();
1654
1653
return to->store_time(<ime, MYSQL_TIMESTAMP_DATETIME);
1713
int Item_func_sysdate_local::save_in_field(Field *to, bool no_conversions __attribute__((__unused__)))
1712
int Item_func_sysdate_local::save_in_field(Field *to, bool no_conversions __attribute__((unused)))
1715
1714
store_now_in_TIME(<ime);
1716
1715
to->set_notnull();
1768
1767
CHARSET_INFO *cs= thd->variables.collation_connection;
1769
uint32 repertoire= arg1->collation.repertoire;
1768
uint32_t repertoire= arg1->collation.repertoire;
1770
1769
if (!thd->variables.lc_time_names->is_ascii)
1771
1770
repertoire|= MY_REPERTOIRE_EXTENDED;
1772
1771
collation.set(cs, arg1->collation.derivation, repertoire);
2016
2015
The field type for the result of an Item_date function is defined as
2019
- If first arg is a MYSQL_TYPE_DATETIME result is MYSQL_TYPE_DATETIME
2020
- If first arg is a MYSQL_TYPE_NEWDATE and the interval type uses hours,
2021
minutes or seconds then type is MYSQL_TYPE_DATETIME.
2022
- Otherwise the result is MYSQL_TYPE_STRING
2018
- If first arg is a DRIZZLE_TYPE_DATETIME result is DRIZZLE_TYPE_DATETIME
2019
- If first arg is a DRIZZLE_TYPE_NEWDATE and the interval type uses hours,
2020
minutes or seconds then type is DRIZZLE_TYPE_DATETIME.
2021
- Otherwise the result is DRIZZLE_TYPE_STRING
2023
2022
(This is because you can't know if the string contains a DATE, MYSQL_TIME or
2024
2023
DATETIME argument)
2026
cached_field_type= MYSQL_TYPE_STRING;
2025
cached_field_type= DRIZZLE_TYPE_STRING;
2027
2026
arg0_field_type= args[0]->field_type();
2028
if (arg0_field_type == MYSQL_TYPE_DATETIME ||
2029
arg0_field_type == MYSQL_TYPE_TIMESTAMP)
2030
cached_field_type= MYSQL_TYPE_DATETIME;
2031
else if (arg0_field_type == MYSQL_TYPE_NEWDATE)
2027
if (arg0_field_type == DRIZZLE_TYPE_DATETIME ||
2028
arg0_field_type == DRIZZLE_TYPE_TIMESTAMP)
2029
cached_field_type= DRIZZLE_TYPE_DATETIME;
2030
else if (arg0_field_type == DRIZZLE_TYPE_NEWDATE)
2033
2032
if (int_type <= INTERVAL_DAY || int_type == INTERVAL_YEAR_MONTH)
2034
2033
cached_field_type= arg0_field_type;
2036
cached_field_type= MYSQL_TYPE_DATETIME;
2035
cached_field_type= DRIZZLE_TYPE_DATETIME;
2041
2040
/* Here arg[1] is a Item_interval object */
2043
bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date __attribute__((__unused__)))
2042
bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date __attribute__((unused)))
2045
2044
INTERVAL interval;
2348
2347
if (cast_length >= 0)
2350
if (res->length() > (length= (uint32) res->charpos(cast_length)))
2349
if (res->length() > (length= (uint32_t) res->charpos(cast_length)))
2351
2350
{ // Safe even if const arg
2352
2351
char char_type[40];
2353
2352
snprintf(char_type, sizeof(char_type), "%s(%lu)",
2373
2372
str->copy(*res);
2376
bzero((char*) res->ptr() + res->length(),
2377
(uint) cast_length - res->length());
2375
memset((char*) res->ptr() + res->length(), 0,
2376
(uint) cast_length - res->length());
2378
2377
res->length(cast_length);
2494
bool Item_date_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date __attribute__((__unused__)))
2493
bool Item_date_typecast::get_date(MYSQL_TIME *ltime, uint fuzzy_date __attribute__((unused)))
2496
2495
bool res= get_arg0_date(ltime, TIME_FUZZY_DATE);
2497
2496
ltime->hour= ltime->minute= ltime->second= ltime->second_part= 0;
2503
2502
bool Item_date_typecast::get_time(MYSQL_TIME *ltime)
2505
bzero((char *)ltime, sizeof(MYSQL_TIME));
2504
memset((char *)ltime, 0, sizeof(MYSQL_TIME));
2506
2505
return args[0]->null_value;
2626
2625
The field type for the result of an Item_func_add_time function is defined
2629
- If first arg is a MYSQL_TYPE_DATETIME or MYSQL_TYPE_TIMESTAMP
2630
result is MYSQL_TYPE_DATETIME
2631
- If first arg is a MYSQL_TYPE_TIME result is MYSQL_TYPE_TIME
2632
- Otherwise the result is MYSQL_TYPE_STRING
2628
- If first arg is a DRIZZLE_TYPE_DATETIME or DRIZZLE_TYPE_TIMESTAMP
2629
result is DRIZZLE_TYPE_DATETIME
2630
- If first arg is a DRIZZLE_TYPE_TIME result is DRIZZLE_TYPE_TIME
2631
- Otherwise the result is DRIZZLE_TYPE_STRING
2635
cached_field_type= MYSQL_TYPE_STRING;
2634
cached_field_type= DRIZZLE_TYPE_STRING;
2636
2635
arg0_field_type= args[0]->field_type();
2637
if (arg0_field_type == MYSQL_TYPE_NEWDATE ||
2638
arg0_field_type == MYSQL_TYPE_DATETIME ||
2639
arg0_field_type == MYSQL_TYPE_TIMESTAMP)
2640
cached_field_type= MYSQL_TYPE_DATETIME;
2641
else if (arg0_field_type == MYSQL_TYPE_TIME)
2642
cached_field_type= MYSQL_TYPE_TIME;
2636
if (arg0_field_type == DRIZZLE_TYPE_NEWDATE ||
2637
arg0_field_type == DRIZZLE_TYPE_DATETIME ||
2638
arg0_field_type == DRIZZLE_TYPE_TIMESTAMP)
2639
cached_field_type= DRIZZLE_TYPE_DATETIME;
2640
else if (arg0_field_type == DRIZZLE_TYPE_TIME)
2641
cached_field_type= DRIZZLE_TYPE_TIME;
2681
2680
if (l_time1.neg != l_time2.neg)
2682
2681
l_sign= -l_sign;
2684
bzero((char *)&l_time3, sizeof(l_time3));
2683
memset((char *)&l_time3, 0, sizeof(l_time3));
2686
2685
l_time3.neg= calc_time_diff(&l_time1, &l_time2, -l_sign,
2687
2686
&seconds, µseconds);
2769
2768
if (l_time1.neg != l_time2.neg)
2770
2769
l_sign= -l_sign;
2772
bzero((char *)&l_time3, sizeof(l_time3));
2771
memset((char *)&l_time3, 0, sizeof(l_time3));
2774
2773
l_time3.neg= calc_time_diff(&l_time1, &l_time2, l_sign,
2775
2774
&seconds, µseconds);
2818
2817
str->alloc(MAX_DATE_STRING_REP_LENGTH))))
2821
bzero((char *)<ime, sizeof(ltime));
2820
memset((char *)<ime, 0, sizeof(ltime));
2824
2823
/* Check for integer overflows */
3163
cached_field_type= MYSQL_TYPE_DATETIME;
3162
cached_field_type= DRIZZLE_TYPE_DATETIME;
3164
3163
max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
3165
3164
cached_timestamp_type= MYSQL_TIMESTAMP_NONE;
3166
3165
if ((const_item= args[1]->const_item()))
3175
3174
switch (cached_format_type) {
3176
3175
case DATE_ONLY:
3177
3176
cached_timestamp_type= MYSQL_TIMESTAMP_DATE;
3178
cached_field_type= MYSQL_TYPE_NEWDATE;
3177
cached_field_type= DRIZZLE_TYPE_NEWDATE;
3179
3178
max_length= MAX_DATE_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
3181
3180
case TIME_ONLY:
3182
3181
case TIME_MICROSECOND:
3183
3182
cached_timestamp_type= MYSQL_TIMESTAMP_TIME;
3184
cached_field_type= MYSQL_TYPE_TIME;
3183
cached_field_type= DRIZZLE_TYPE_TIME;
3185
3184
max_length= MAX_TIME_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
3188
3187
cached_timestamp_type= MYSQL_TIMESTAMP_DATETIME;
3189
cached_field_type= MYSQL_TYPE_DATETIME;
3188
cached_field_type= DRIZZLE_TYPE_DATETIME;
3207
3206
goto null_date;
3210
bzero((char*) ltime, sizeof(*ltime));
3209
memset((char*) ltime, 0, sizeof(*ltime));
3211
3210
date_time_format.format.str= (char*) format->ptr();
3212
3211
date_time_format.format.length= format->length();
3213
3212
if (extract_date_time(&date_time_format, val->ptr(), val->length(),