32
56
bool get_interval_value(Item *args,interval_type int_type,
33
57
String *str_value, INTERVAL *interval);
35
class Item_func_period_add :public Item_int_func
38
Item_func_period_add(Item *a,Item *b) :Item_int_func(a,b) {}
40
const char *func_name() const { return "period_add"; }
41
void fix_length_and_dec()
43
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
48
class Item_func_period_diff :public Item_int_func
51
Item_func_period_diff(Item *a,Item *b) :Item_int_func(a,b) {}
53
const char *func_name() const { return "period_diff"; }
54
void fix_length_and_dec()
57
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
62
class Item_func_to_days :public Item_int_func
65
Item_func_to_days(Item *a) :Item_int_func(a) {}
67
const char *func_name() const { return "to_days"; }
68
void fix_length_and_dec()
71
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
74
enum_monotonicity_info get_monotonicity_info() const;
75
int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
79
class Item_func_dayofmonth :public Item_int_func
82
Item_func_dayofmonth(Item *a) :Item_int_func(a) {}
84
const char *func_name() const { return "dayofmonth"; }
85
void fix_length_and_dec()
88
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
94
class Item_func_month :public Item_func
97
Item_func_month(Item *a) :Item_func(a) {}
100
{ assert(fixed == 1); return (double) Item_func_month::val_int(); }
101
String *val_str(String *str)
103
str->set(val_int(), &my_charset_bin);
104
return null_value ? 0 : str;
106
const char *func_name() const { return "month"; }
107
enum Item_result result_type () const { return INT_RESULT; }
108
void fix_length_and_dec()
110
collation.set(&my_charset_bin);
112
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
118
class Item_func_monthname :public Item_func_month
121
Item_func_monthname(Item *a) :Item_func_month(a) {}
122
const char *func_name() const { return "monthname"; }
123
String *val_str(String *str);
124
enum Item_result result_type () const { return STRING_RESULT; }
125
void fix_length_and_dec()
127
collation.set(&my_charset_bin);
129
max_length=10*my_charset_bin.mbmaxlen;
135
class Item_func_dayofyear :public Item_int_func
138
Item_func_dayofyear(Item *a) :Item_int_func(a) {}
140
const char *func_name() const { return "dayofyear"; }
141
void fix_length_and_dec()
144
max_length=3*MY_CHARSET_BIN_MB_MAXLEN;
150
class Item_func_hour :public Item_int_func
153
Item_func_hour(Item *a) :Item_int_func(a) {}
155
const char *func_name() const { return "hour"; }
156
void fix_length_and_dec()
159
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
165
class Item_func_minute :public Item_int_func
168
Item_func_minute(Item *a) :Item_int_func(a) {}
170
const char *func_name() const { return "minute"; }
171
void fix_length_and_dec()
174
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
180
class Item_func_quarter :public Item_int_func
183
Item_func_quarter(Item *a) :Item_int_func(a) {}
185
const char *func_name() const { return "quarter"; }
186
void fix_length_and_dec()
189
max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
195
class Item_func_second :public Item_int_func
198
Item_func_second(Item *a) :Item_int_func(a) {}
200
const char *func_name() const { return "second"; }
201
void fix_length_and_dec()
204
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
210
class Item_func_week :public Item_int_func
213
Item_func_week(Item *a,Item *b) :Item_int_func(a,b) {}
215
const char *func_name() const { return "week"; }
216
void fix_length_and_dec()
219
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
224
class Item_func_yearweek :public Item_int_func
227
Item_func_yearweek(Item *a,Item *b) :Item_int_func(a,b) {}
229
const char *func_name() const { return "yearweek"; }
230
void fix_length_and_dec()
233
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
239
class Item_func_year :public Item_int_func
242
Item_func_year(Item *a) :Item_int_func(a) {}
244
const char *func_name() const { return "year"; }
245
enum_monotonicity_info get_monotonicity_info() const;
246
int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
247
void fix_length_and_dec()
250
max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
256
class Item_func_weekday :public Item_func
260
Item_func_weekday(Item *a,bool type_arg)
261
:Item_func(a), odbc_type(type_arg) {}
263
double val_real() { assert(fixed == 1); return (double) val_int(); }
264
String *val_str(String *str)
267
str->set(val_int(), &my_charset_bin);
268
return null_value ? 0 : str;
270
const char *func_name() const
272
return (odbc_type ? "dayofweek" : "weekday");
274
enum Item_result result_type () const { return INT_RESULT; }
275
void fix_length_and_dec()
277
collation.set(&my_charset_bin);
279
max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
284
class Item_func_dayname :public Item_func_weekday
287
Item_func_dayname(Item *a) :Item_func_weekday(a,0) {}
288
const char *func_name() const { return "dayname"; }
289
String *val_str(String *str);
290
enum Item_result result_type () const { return STRING_RESULT; }
291
void fix_length_and_dec()
293
collation.set(&my_charset_bin);
295
max_length=9*MY_CHARSET_BIN_MB_MAXLEN;
301
class Item_func_unix_timestamp :public Item_int_func
305
Item_func_unix_timestamp() :Item_int_func() {}
306
Item_func_unix_timestamp(Item *a) :Item_int_func(a) {}
308
const char *func_name() const { return "unix_timestamp"; }
309
void fix_length_and_dec()
312
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
317
class Item_func_time_to_sec :public Item_int_func
320
Item_func_time_to_sec(Item *item) :Item_int_func(item) {}
322
const char *func_name() const { return "time_to_sec"; }
323
void fix_length_and_dec()
326
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
332
This can't be a Item_str_func, because the val_real() functions are special
335
class Item_date :public Item_func
338
Item_date() :Item_func() {}
339
Item_date(Item *a) :Item_func(a) {}
340
enum Item_result result_type () const { return STRING_RESULT; }
341
enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDATE; }
342
String *val_str(String *str);
344
double val_real() { return val_real_from_decimal(); }
345
const char *func_name() const { return "date"; }
346
void fix_length_and_dec()
348
collation.set(&my_charset_bin);
350
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
352
Field *tmp_table_field(Table *table)
354
return tmp_table_field_from_field_type(table, 0);
356
bool result_as_int64_t() { return true; }
357
my_decimal *val_decimal(my_decimal *decimal_value)
360
return val_decimal_from_date(decimal_value);
362
int save_in_field(Field *field,
363
bool no_conversions __attribute__((unused)))
365
return save_date_in_field(field);
370
class Item_date_func :public Item_str_func
373
Item_date_func() :Item_str_func() {}
374
Item_date_func(Item *a) :Item_str_func(a) {}
375
Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {}
376
Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {}
377
enum_field_types field_type() const { return DRIZZLE_TYPE_DATETIME; }
378
Field *tmp_table_field(Table *table)
380
return tmp_table_field_from_field_type(table, 0);
382
bool result_as_int64_t() { return true; }
383
double val_real() { return (double) val_int(); }
384
my_decimal *val_decimal(my_decimal *decimal_value)
387
return val_decimal_from_date(decimal_value);
389
int save_in_field(Field *field,
390
bool no_conversions __attribute__((unused)))
392
return save_date_in_field(field);
397
class Item_str_timefunc :public Item_str_func
400
Item_str_timefunc() :Item_str_func() {}
401
Item_str_timefunc(Item *a) :Item_str_func(a) {}
402
Item_str_timefunc(Item *a,Item *b) :Item_str_func(a,b) {}
403
Item_str_timefunc(Item *a, Item *b, Item *c) :Item_str_func(a, b ,c) {}
404
enum_field_types field_type() const { return DRIZZLE_TYPE_TIME; }
405
void fix_length_and_dec()
407
decimals= DATETIME_DEC;
408
max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
410
Field *tmp_table_field(Table *table)
412
return tmp_table_field_from_field_type(table, 0);
414
double val_real() { return val_real_from_decimal(); }
415
my_decimal *val_decimal(my_decimal *decimal_value)
418
return val_decimal_from_time(decimal_value);
420
int save_in_field(Field *field,
421
bool no_conversions __attribute__((unused)))
423
return save_time_in_field(field);
428
/* Abstract CURTIME function. Children should define what time zone is used */
430
class Item_func_curtime :public Item_str_timefunc
434
uint32_t buff_length;
436
Item_func_curtime() :Item_str_timefunc() {}
437
Item_func_curtime(Item *a) :Item_str_timefunc(a) {}
438
double val_real() { assert(fixed == 1); return (double) value; }
439
int64_t val_int() { assert(fixed == 1); return value; }
440
String *val_str(String *str);
441
void fix_length_and_dec();
443
Abstract method that defines which time zone is used for conversion.
444
Converts time current time in my_time_t representation to broken-down
445
DRIZZLE_TIME representation using UTC-SYSTEM or per-thread time zone.
447
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
448
bool result_as_int64_t() { return true; }
452
class Item_func_curtime_local :public Item_func_curtime
455
Item_func_curtime_local() :Item_func_curtime() {}
456
Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
457
const char *func_name() const { return "curtime"; }
458
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
462
class Item_func_curtime_utc :public Item_func_curtime
465
Item_func_curtime_utc() :Item_func_curtime() {}
466
Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
467
const char *func_name() const { return "utc_time"; }
468
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
472
/* Abstract CURDATE function. See also Item_func_curtime. */
474
class Item_func_curdate :public Item_date
479
Item_func_curdate() :Item_date() {}
480
int64_t val_int() { assert(fixed == 1); return (value) ; }
481
String *val_str(String *str);
482
void fix_length_and_dec();
483
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
484
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
488
class Item_func_curdate_local :public Item_func_curdate
491
Item_func_curdate_local() :Item_func_curdate() {}
492
const char *func_name() const { return "curdate"; }
493
void store_now_in_TIME(DRIZZLE_TIME *now_time);
497
class Item_func_curdate_utc :public Item_func_curdate
500
Item_func_curdate_utc() :Item_func_curdate() {}
501
const char *func_name() const { return "utc_date"; }
502
void store_now_in_TIME(DRIZZLE_TIME *now_time);
506
/* Abstract CURRENT_TIMESTAMP function. See also Item_func_curtime */
508
class Item_func_now :public Item_date_func
512
char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy
513
uint32_t buff_length;
516
Item_func_now() :Item_date_func() {}
517
Item_func_now(Item *a) :Item_date_func(a) {}
518
enum Item_result result_type () const { return STRING_RESULT; }
519
int64_t val_int() { assert(fixed == 1); return value; }
520
int save_in_field(Field *to, bool no_conversions);
521
String *val_str(String *str);
522
void fix_length_and_dec();
523
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
524
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
528
class Item_func_now_local :public Item_func_now
531
Item_func_now_local() :Item_func_now() {}
532
Item_func_now_local(Item *a) :Item_func_now(a) {}
533
const char *func_name() const { return "now"; }
534
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
535
virtual enum Functype functype() const { return NOW_FUNC; }
539
class Item_func_now_utc :public Item_func_now
542
Item_func_now_utc() :Item_func_now() {}
543
Item_func_now_utc(Item *a) :Item_func_now(a) {}
544
const char *func_name() const { return "utc_timestamp"; }
545
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
550
This is like NOW(), but always uses the real current time, not the
551
query_start(). This matches the Oracle behavior.
553
class Item_func_sysdate_local :public Item_func_now
556
Item_func_sysdate_local() :Item_func_now() {}
557
Item_func_sysdate_local(Item *a) :Item_func_now(a) {}
558
bool const_item() const { return 0; }
559
const char *func_name() const { return "sysdate"; }
560
void store_now_in_TIME(DRIZZLE_TIME *now_time);
563
int save_in_field(Field *to, bool no_conversions);
564
String *val_str(String *str);
565
void fix_length_and_dec();
566
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
567
void update_used_tables()
569
Item_func_now::update_used_tables();
570
used_tables_cache|= RAND_TABLE_BIT;
575
class Item_func_from_days :public Item_date
578
Item_func_from_days(Item *a) :Item_date(a) {}
579
const char *func_name() const { return "from_days"; }
580
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
584
59
class Item_func_date_format :public Item_str_func