1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21
/* Function items used by mysql */
23
enum date_time_format_types
25
TIME_ONLY= 0, TIME_MICROSECOND, DATE_ONLY, DATE_TIME, DATE_TIME_MICROSECOND
28
bool get_interval_value(Item *args,interval_type int_type,
29
String *str_value, INTERVAL *interval);
31
class Item_func_period_add :public Item_int_func
34
Item_func_period_add(Item *a,Item *b) :Item_int_func(a,b) {}
36
const char *func_name() const { return "period_add"; }
37
void fix_length_and_dec()
39
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
44
class Item_func_period_diff :public Item_int_func
47
Item_func_period_diff(Item *a,Item *b) :Item_int_func(a,b) {}
49
const char *func_name() const { return "period_diff"; }
50
void fix_length_and_dec()
53
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
58
class Item_func_to_days :public Item_int_func
61
Item_func_to_days(Item *a) :Item_int_func(a) {}
63
const char *func_name() const { return "to_days"; }
64
void fix_length_and_dec()
67
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
70
enum_monotonicity_info get_monotonicity_info() const;
71
int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
72
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
77
class Item_func_dayofmonth :public Item_int_func
80
Item_func_dayofmonth(Item *a) :Item_int_func(a) {}
82
const char *func_name() const { return "dayofmonth"; }
83
void fix_length_and_dec()
86
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
89
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
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;
115
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
120
class Item_func_monthname :public Item_func_month
123
Item_func_monthname(Item *a) :Item_func_month(a) {}
124
const char *func_name() const { return "monthname"; }
125
String *val_str(String *str);
126
enum Item_result result_type () const { return STRING_RESULT; }
127
void fix_length_and_dec()
129
collation.set(&my_charset_bin);
131
max_length=10*my_charset_bin.mbmaxlen;
137
class Item_func_dayofyear :public Item_int_func
140
Item_func_dayofyear(Item *a) :Item_int_func(a) {}
142
const char *func_name() const { return "dayofyear"; }
143
void fix_length_and_dec()
146
max_length=3*MY_CHARSET_BIN_MB_MAXLEN;
152
class Item_func_hour :public Item_int_func
155
Item_func_hour(Item *a) :Item_int_func(a) {}
157
const char *func_name() const { return "hour"; }
158
void fix_length_and_dec()
161
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
167
class Item_func_minute :public Item_int_func
170
Item_func_minute(Item *a) :Item_int_func(a) {}
172
const char *func_name() const { return "minute"; }
173
void fix_length_and_dec()
176
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
182
class Item_func_quarter :public Item_int_func
185
Item_func_quarter(Item *a) :Item_int_func(a) {}
187
const char *func_name() const { return "quarter"; }
188
void fix_length_and_dec()
191
max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
197
class Item_func_second :public Item_int_func
200
Item_func_second(Item *a) :Item_int_func(a) {}
202
const char *func_name() const { return "second"; }
203
void fix_length_and_dec()
206
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
212
class Item_func_week :public Item_int_func
215
Item_func_week(Item *a,Item *b) :Item_int_func(a,b) {}
217
const char *func_name() const { return "week"; }
218
void fix_length_and_dec()
221
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
226
class Item_func_yearweek :public Item_int_func
229
Item_func_yearweek(Item *a,Item *b) :Item_int_func(a,b) {}
231
const char *func_name() const { return "yearweek"; }
232
void fix_length_and_dec()
235
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
241
class Item_func_year :public Item_int_func
244
Item_func_year(Item *a) :Item_int_func(a) {}
246
const char *func_name() const { return "year"; }
247
enum_monotonicity_info get_monotonicity_info() const;
248
int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
249
void fix_length_and_dec()
252
max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
258
class Item_func_weekday :public Item_func
262
Item_func_weekday(Item *a,bool type_arg)
263
:Item_func(a), odbc_type(type_arg) {}
265
double val_real() { assert(fixed == 1); return (double) val_int(); }
266
String *val_str(String *str)
269
str->set(val_int(), &my_charset_bin);
270
return null_value ? 0 : str;
272
const char *func_name() const
274
return (odbc_type ? "dayofweek" : "weekday");
276
enum Item_result result_type () const { return INT_RESULT; }
277
void fix_length_and_dec()
279
collation.set(&my_charset_bin);
281
max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
286
class Item_func_dayname :public Item_func_weekday
289
Item_func_dayname(Item *a) :Item_func_weekday(a,0) {}
290
const char *func_name() const { return "dayname"; }
291
String *val_str(String *str);
292
enum Item_result result_type () const { return STRING_RESULT; }
293
void fix_length_and_dec()
295
collation.set(&my_charset_bin);
297
max_length=9*MY_CHARSET_BIN_MB_MAXLEN;
303
class Item_func_unix_timestamp :public Item_int_func
307
Item_func_unix_timestamp() :Item_int_func() {}
308
Item_func_unix_timestamp(Item *a) :Item_int_func(a) {}
310
const char *func_name() const { return "unix_timestamp"; }
311
void fix_length_and_dec()
314
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
316
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
321
class Item_func_time_to_sec :public Item_int_func
324
Item_func_time_to_sec(Item *item) :Item_int_func(item) {}
326
const char *func_name() const { return "time_to_sec"; }
327
void fix_length_and_dec()
330
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
336
This can't be a Item_str_func, because the val_real() functions are special
339
class Item_date :public Item_func
342
Item_date() :Item_func() {}
343
Item_date(Item *a) :Item_func(a) {}
344
enum Item_result result_type () const { return STRING_RESULT; }
345
enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDATE; }
346
String *val_str(String *str);
348
double val_real() { return val_real_from_decimal(); }
349
const char *func_name() const { return "date"; }
350
void fix_length_and_dec()
352
collation.set(&my_charset_bin);
354
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
356
Field *tmp_table_field(Table *table)
358
return tmp_table_field_from_field_type(table, 0);
360
bool result_as_int64_t() { return true; }
361
my_decimal *val_decimal(my_decimal *decimal_value)
364
return val_decimal_from_date(decimal_value);
366
int save_in_field(Field *field,
367
bool no_conversions __attribute__((unused)))
369
return save_date_in_field(field);
374
class Item_date_func :public Item_str_func
377
Item_date_func() :Item_str_func() {}
378
Item_date_func(Item *a) :Item_str_func(a) {}
379
Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {}
380
Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {}
381
enum_field_types field_type() const { return DRIZZLE_TYPE_DATETIME; }
382
Field *tmp_table_field(Table *table)
384
return tmp_table_field_from_field_type(table, 0);
386
bool result_as_int64_t() { return true; }
387
double val_real() { return (double) val_int(); }
388
my_decimal *val_decimal(my_decimal *decimal_value)
391
return val_decimal_from_date(decimal_value);
393
int save_in_field(Field *field,
394
bool no_conversions __attribute__((unused)))
396
return save_date_in_field(field);
401
class Item_str_timefunc :public Item_str_func
404
Item_str_timefunc() :Item_str_func() {}
405
Item_str_timefunc(Item *a) :Item_str_func(a) {}
406
Item_str_timefunc(Item *a,Item *b) :Item_str_func(a,b) {}
407
Item_str_timefunc(Item *a, Item *b, Item *c) :Item_str_func(a, b ,c) {}
408
enum_field_types field_type() const { return DRIZZLE_TYPE_TIME; }
409
void fix_length_and_dec()
411
decimals= DATETIME_DEC;
412
max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
414
Field *tmp_table_field(Table *table)
416
return tmp_table_field_from_field_type(table, 0);
418
double val_real() { return val_real_from_decimal(); }
419
my_decimal *val_decimal(my_decimal *decimal_value)
422
return val_decimal_from_time(decimal_value);
424
int save_in_field(Field *field,
425
bool no_conversions __attribute__((unused)))
427
return save_time_in_field(field);
432
/* Abstract CURTIME function. Children should define what time zone is used */
434
class Item_func_curtime :public Item_str_timefunc
438
uint32_t buff_length;
440
Item_func_curtime() :Item_str_timefunc() {}
441
Item_func_curtime(Item *a) :Item_str_timefunc(a) {}
442
double val_real() { assert(fixed == 1); return (double) value; }
443
int64_t val_int() { assert(fixed == 1); return value; }
444
String *val_str(String *str);
445
void fix_length_and_dec();
447
Abstract method that defines which time zone is used for conversion.
448
Converts time current time in my_time_t representation to broken-down
449
DRIZZLE_TIME representation using UTC-SYSTEM or per-thread time zone.
451
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
452
bool result_as_int64_t() { return true; }
453
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
458
class Item_func_curtime_local :public Item_func_curtime
461
Item_func_curtime_local() :Item_func_curtime() {}
462
Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
463
const char *func_name() const { return "curtime"; }
464
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
468
class Item_func_curtime_utc :public Item_func_curtime
471
Item_func_curtime_utc() :Item_func_curtime() {}
472
Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
473
const char *func_name() const { return "utc_time"; }
474
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
478
/* Abstract CURDATE function. See also Item_func_curtime. */
480
class Item_func_curdate :public Item_date
485
Item_func_curdate() :Item_date() {}
486
int64_t val_int() { assert(fixed == 1); return (value) ; }
487
String *val_str(String *str);
488
void fix_length_and_dec();
489
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
490
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
491
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
496
class Item_func_curdate_local :public Item_func_curdate
499
Item_func_curdate_local() :Item_func_curdate() {}
500
const char *func_name() const { return "curdate"; }
501
void store_now_in_TIME(DRIZZLE_TIME *now_time);
505
class Item_func_curdate_utc :public Item_func_curdate
508
Item_func_curdate_utc() :Item_func_curdate() {}
509
const char *func_name() const { return "utc_date"; }
510
void store_now_in_TIME(DRIZZLE_TIME *now_time);
514
/* Abstract CURRENT_TIMESTAMP function. See also Item_func_curtime */
516
class Item_func_now :public Item_date_func
520
char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy
521
uint32_t buff_length;
524
Item_func_now() :Item_date_func() {}
525
Item_func_now(Item *a) :Item_date_func(a) {}
526
enum Item_result result_type () const { return STRING_RESULT; }
527
int64_t val_int() { assert(fixed == 1); return value; }
528
int save_in_field(Field *to, bool no_conversions);
529
String *val_str(String *str);
530
void fix_length_and_dec();
531
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
532
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
533
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
538
class Item_func_now_local :public Item_func_now
541
Item_func_now_local() :Item_func_now() {}
542
Item_func_now_local(Item *a) :Item_func_now(a) {}
543
const char *func_name() const { return "now"; }
544
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
545
virtual enum Functype functype() const { return NOW_FUNC; }
549
class Item_func_now_utc :public Item_func_now
552
Item_func_now_utc() :Item_func_now() {}
553
Item_func_now_utc(Item *a) :Item_func_now(a) {}
554
const char *func_name() const { return "utc_timestamp"; }
555
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
560
This is like NOW(), but always uses the real current time, not the
561
query_start(). This matches the Oracle behavior.
563
class Item_func_sysdate_local :public Item_func_now
566
Item_func_sysdate_local() :Item_func_now() {}
567
Item_func_sysdate_local(Item *a) :Item_func_now(a) {}
568
bool const_item() const { return 0; }
569
const char *func_name() const { return "sysdate"; }
570
void store_now_in_TIME(DRIZZLE_TIME *now_time);
573
int save_in_field(Field *to, bool no_conversions);
574
String *val_str(String *str);
575
void fix_length_and_dec();
576
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
577
void update_used_tables()
579
Item_func_now::update_used_tables();
580
used_tables_cache|= RAND_TABLE_BIT;
585
class Item_func_from_days :public Item_date
588
Item_func_from_days(Item *a) :Item_date(a) {}
589
const char *func_name() const { return "from_days"; }
590
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
591
bool check_vcol_func_processor(unsigned char *int_arg __attribute__((unused)))
596
class Item_func_date_format :public Item_str_func
599
const bool is_time_format;
602
Item_func_date_format(Item *a,Item *b,bool is_time_format_arg)
603
:Item_str_func(a,b),is_time_format(is_time_format_arg) {}
604
String *val_str(String *str);
605
const char *func_name() const
606
{ return is_time_format ? "time_format" : "date_format"; }
607
void fix_length_and_dec();
608
uint32_t format_length(const String *format);
609
bool eq(const Item *item, bool binary_cmp) const;
613
class Item_func_from_unixtime :public Item_date_func
617
Item_func_from_unixtime(Item *a) :Item_date_func(a) {}
619
String *val_str(String *str);
620
const char *func_name() const { return "from_unixtime"; }
621
void fix_length_and_dec();
622
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
627
We need Time_zone class declaration for storing pointers in
628
Item_func_convert_tz.
633
This class represents CONVERT_TZ() function.
634
The important fact about this function that it is handled in special way.
635
When such function is met in expression time_zone system tables are added
636
to global list of tables to open, so later those already opened and locked
637
tables can be used during this function calculation for loading time zone
640
class Item_func_convert_tz :public Item_date_func
643
If time zone parameters are constants we are caching objects that
644
represent them (we use separate from_tz_cached/to_tz_cached members
645
to indicate this fact, since NULL is legal value for from_tz/to_tz
648
bool from_tz_cached, to_tz_cached;
649
Time_zone *from_tz, *to_tz;
651
Item_func_convert_tz(Item *a, Item *b, Item *c):
652
Item_date_func(a, b, c), from_tz_cached(0), to_tz_cached(0) {}
654
String *val_str(String *str);
655
const char *func_name() const { return "convert_tz"; }
656
void fix_length_and_dec();
657
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
662
class Item_func_sec_to_time :public Item_str_timefunc
665
Item_func_sec_to_time(Item *item) :Item_str_timefunc(item) {}
669
return (double) Item_func_sec_to_time::val_int();
672
String *val_str(String *);
673
void fix_length_and_dec()
675
Item_str_timefunc::fix_length_and_dec();
676
collation.set(&my_charset_bin);
679
const char *func_name() const { return "sec_to_time"; }
680
bool result_as_int64_t() { return true; }
684
class Item_date_add_interval :public Item_date_func
687
enum_field_types cached_field_type;
690
const interval_type int_type; // keep it public
691
const bool date_sub_interval; // keep it public
692
Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg)
693
:Item_date_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
694
String *val_str(String *);
695
const char *func_name() const { return "date_add_interval"; }
696
void fix_length_and_dec();
697
enum_field_types field_type() const { return cached_field_type; }
699
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);
700
bool eq(const Item *item, bool binary_cmp) const;
701
virtual void print(String *str, enum_query_type query_type);
705
class Item_extract :public Item_int_func
710
const interval_type int_type; // keep it public
711
Item_extract(interval_type type_arg, Item *a)
712
:Item_int_func(a), int_type(type_arg) {}
714
enum Functype functype() const { return EXTRACT_FUNC; }
715
const char *func_name() const { return "extract"; }
716
void fix_length_and_dec();
717
bool eq(const Item *item, bool binary_cmp) const;
718
virtual void print(String *str, enum_query_type query_type);
722
class Item_typecast :public Item_str_func
725
Item_typecast(Item *a) :Item_str_func(a) {}
726
String *val_str(String *a)
729
String *tmp=args[0]->val_str(a);
730
null_value=args[0]->null_value;
732
tmp->set_charset(collation.collation);
735
void fix_length_and_dec()
737
collation.set(&my_charset_bin);
738
max_length=args[0]->max_length;
740
virtual const char* cast_type() const= 0;
741
virtual void print(String *str, enum_query_type query_type);
745
class Item_typecast_maybe_null :public Item_typecast
748
Item_typecast_maybe_null(Item *a) :Item_typecast(a) {}
749
void fix_length_and_dec()
751
collation.set(&my_charset_bin);
752
max_length=args[0]->max_length;
758
class Item_char_typecast :public Item_typecast
761
const CHARSET_INFO *cast_cs, *from_cs;
762
bool charset_conversion;
765
Item_char_typecast(Item *a, int length_arg, const CHARSET_INFO * const cs_arg)
766
:Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {}
767
enum Functype functype() const { return CHAR_TYPECAST_FUNC; }
768
bool eq(const Item *item, bool binary_cmp) const;
769
const char *func_name() const { return "cast_as_char"; }
770
const char* cast_type() const { return "char"; };
771
String *val_str(String *a);
772
void fix_length_and_dec();
773
virtual void print(String *str, enum_query_type query_type);
777
class Item_date_typecast :public Item_typecast_maybe_null
780
Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
781
const char *func_name() const { return "cast_as_date"; }
782
String *val_str(String *str);
783
bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date);
784
bool get_time(DRIZZLE_TIME *ltime);
785
const char *cast_type() const { return "date"; }
786
enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDATE; }
787
Field *tmp_table_field(Table *table)
789
return tmp_table_field_from_field_type(table, 0);
791
void fix_length_and_dec()
793
collation.set(&my_charset_bin);
797
bool result_as_int64_t() { return true; }
799
double val_real() { return (double) val_int(); }
800
my_decimal *val_decimal(my_decimal *decimal_value)
803
return val_decimal_from_date(decimal_value);
805
int save_in_field(Field *field,
806
bool no_conversions __attribute__((unused)))
808
return save_date_in_field(field);
813
class Item_time_typecast :public Item_typecast_maybe_null
816
Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
817
const char *func_name() const { return "cast_as_time"; }
818
String *val_str(String *str);
819
bool get_time(DRIZZLE_TIME *ltime);
820
const char *cast_type() const { return "time"; }
821
enum_field_types field_type() const { return DRIZZLE_TYPE_TIME; }
822
Field *tmp_table_field(Table *table)
824
return tmp_table_field_from_field_type(table, 0);
826
bool result_as_int64_t() { return true; }
828
double val_real() { return val_real_from_decimal(); }
829
my_decimal *val_decimal(my_decimal *decimal_value)
832
return val_decimal_from_time(decimal_value);
834
int save_in_field(Field *field,
835
bool no_conversions __attribute__((unused)))
837
return save_time_in_field(field);
842
class Item_datetime_typecast :public Item_typecast_maybe_null
845
Item_datetime_typecast(Item *a) :Item_typecast_maybe_null(a) {}
846
const char *func_name() const { return "cast_as_datetime"; }
847
String *val_str(String *str);
848
const char *cast_type() const { return "datetime"; }
849
enum_field_types field_type() const { return DRIZZLE_TYPE_DATETIME; }
850
Field *tmp_table_field(Table *table)
852
return tmp_table_field_from_field_type(table, 0);
854
void fix_length_and_dec()
856
collation.set(&my_charset_bin);
858
max_length= MAX_DATETIME_FULL_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
859
decimals= DATETIME_DEC;
861
bool result_as_int64_t() { return true; }
863
double val_real() { return val_real_from_decimal(); }
864
double val() { return (double) val_int(); }
865
my_decimal *val_decimal(my_decimal *decimal_value)
868
return val_decimal_from_date(decimal_value);
870
int save_in_field(Field *field,
871
bool no_conversions __attribute__((unused)))
873
return save_date_in_field(field);
877
class Item_func_makedate :public Item_date_func
880
Item_func_makedate(Item *a,Item *b) :Item_date_func(a,b) {}
881
String *val_str(String *str);
882
const char *func_name() const { return "makedate"; }
883
enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDATE; }
884
void fix_length_and_dec()
887
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
893
class Item_func_add_time :public Item_str_func
897
enum_field_types cached_field_type;
900
Item_func_add_time(Item *a, Item *b, bool type_arg, bool neg_arg)
901
:Item_str_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
902
String *val_str(String *str);
903
enum_field_types field_type() const { return cached_field_type; }
904
void fix_length_and_dec();
906
Field *tmp_table_field(Table *table)
908
return tmp_table_field_from_field_type(table, 0);
910
virtual void print(String *str, enum_query_type query_type);
911
const char *func_name() const { return "add_time"; }
912
double val_real() { return val_real_from_decimal(); }
913
my_decimal *val_decimal(my_decimal *decimal_value)
916
if (cached_field_type == DRIZZLE_TYPE_TIME)
917
return val_decimal_from_time(decimal_value);
918
if (cached_field_type == DRIZZLE_TYPE_DATETIME)
919
return val_decimal_from_date(decimal_value);
920
return Item_str_func::val_decimal(decimal_value);
922
int save_in_field(Field *field, bool no_conversions)
924
if (cached_field_type == DRIZZLE_TYPE_TIME)
925
return save_time_in_field(field);
926
if (cached_field_type == DRIZZLE_TYPE_DATETIME)
927
return save_date_in_field(field);
928
return Item_str_func::save_in_field(field, no_conversions);
932
class Item_func_timediff :public Item_str_timefunc
935
Item_func_timediff(Item *a, Item *b)
936
:Item_str_timefunc(a, b) {}
937
String *val_str(String *str);
938
const char *func_name() const { return "timediff"; }
939
void fix_length_and_dec()
941
Item_str_timefunc::fix_length_and_dec();
946
class Item_func_maketime :public Item_str_timefunc
949
Item_func_maketime(Item *a, Item *b, Item *c)
950
:Item_str_timefunc(a, b, c)
954
String *val_str(String *str);
955
const char *func_name() const { return "maketime"; }
958
class Item_func_microsecond :public Item_int_func
961
Item_func_microsecond(Item *a) :Item_int_func(a) {}
963
const char *func_name() const { return "microsecond"; }
964
void fix_length_and_dec()
972
class Item_func_timestamp_diff :public Item_int_func
974
const interval_type int_type;
976
Item_func_timestamp_diff(Item *a,Item *b,interval_type type_arg)
977
:Item_int_func(a,b), int_type(type_arg) {}
978
const char *func_name() const { return "timestampdiff"; }
980
void fix_length_and_dec()
985
virtual void print(String *str, enum_query_type query_type);
989
enum date_time_format
991
USA_FORMAT, JIS_FORMAT, ISO_FORMAT, EUR_FORMAT, INTERNAL_FORMAT
994
class Item_func_get_format :public Item_str_func
997
const enum enum_drizzle_timestamp_type type; // keep it public
998
Item_func_get_format(enum enum_drizzle_timestamp_type type_arg, Item *a)
999
:Item_str_func(a), type(type_arg)
1001
String *val_str(String *str);
1002
const char *func_name() const { return "get_format"; }
1003
void fix_length_and_dec()
1007
max_length=17*MY_CHARSET_BIN_MB_MAXLEN;
1009
virtual void print(String *str, enum_query_type query_type);
1013
class Item_func_str_to_date :public Item_str_func
1015
enum_field_types cached_field_type;
1016
date_time_format_types cached_format_type;
1017
enum enum_drizzle_timestamp_type cached_timestamp_type;
1020
Item_func_str_to_date(Item *a, Item *b)
1021
:Item_str_func(a, b), const_item(false)
1023
String *val_str(String *str);
1024
bool get_date(DRIZZLE_TIME *ltime, uint32_t fuzzy_date);
1025
const char *func_name() const { return "str_to_date"; }
1026
enum_field_types field_type() const { return cached_field_type; }
1027
void fix_length_and_dec();
1028
Field *tmp_table_field(Table *table)
1030
return tmp_table_field_from_field_type(table, 1);
1035
class Item_func_last_day :public Item_date
1038
Item_func_last_day(Item *a) :Item_date(a) {}
1039
const char *func_name() const { return "last_day"; }
1040
bool get_date(DRIZZLE_TIME *res, uint32_t fuzzy_date);