1
/* Copyright (C) 2000-2006 MySQL AB
3
This program is free software; you can redistribute it and/or modify
4
it under the terms of the GNU General Public License as published by
5
the Free Software Foundation; version 2 of the License.
7
This program is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU General Public License for more details.
12
You should have received a copy of the GNU General Public License
13
along with this program; if not, write to the Free Software
14
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
17
/* Function items used by mysql */
19
#ifdef USE_PRAGMA_INTERFACE
20
#pragma interface /* gcc class implementation */
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);
75
class Item_func_dayofmonth :public Item_int_func
78
Item_func_dayofmonth(Item *a) :Item_int_func(a) {}
80
const char *func_name() const { return "dayofmonth"; }
81
void fix_length_and_dec()
84
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
90
class Item_func_month :public Item_func
93
Item_func_month(Item *a) :Item_func(a) {}
96
{ assert(fixed == 1); return (double) Item_func_month::val_int(); }
97
String *val_str(String *str)
99
str->set(val_int(), &my_charset_bin);
100
return null_value ? 0 : str;
102
const char *func_name() const { return "month"; }
103
enum Item_result result_type () const { return INT_RESULT; }
104
void fix_length_and_dec()
106
collation.set(&my_charset_bin);
108
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
114
class Item_func_monthname :public Item_func_month
117
Item_func_monthname(Item *a) :Item_func_month(a) {}
118
const char *func_name() const { return "monthname"; }
119
String *val_str(String *str);
120
enum Item_result result_type () const { return STRING_RESULT; }
121
void fix_length_and_dec()
123
collation.set(&my_charset_bin);
125
max_length=10*my_charset_bin.mbmaxlen;
131
class Item_func_dayofyear :public Item_int_func
134
Item_func_dayofyear(Item *a) :Item_int_func(a) {}
136
const char *func_name() const { return "dayofyear"; }
137
void fix_length_and_dec()
140
max_length=3*MY_CHARSET_BIN_MB_MAXLEN;
146
class Item_func_hour :public Item_int_func
149
Item_func_hour(Item *a) :Item_int_func(a) {}
151
const char *func_name() const { return "hour"; }
152
void fix_length_and_dec()
155
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
161
class Item_func_minute :public Item_int_func
164
Item_func_minute(Item *a) :Item_int_func(a) {}
166
const char *func_name() const { return "minute"; }
167
void fix_length_and_dec()
170
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
176
class Item_func_quarter :public Item_int_func
179
Item_func_quarter(Item *a) :Item_int_func(a) {}
181
const char *func_name() const { return "quarter"; }
182
void fix_length_and_dec()
185
max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
191
class Item_func_second :public Item_int_func
194
Item_func_second(Item *a) :Item_int_func(a) {}
196
const char *func_name() const { return "second"; }
197
void fix_length_and_dec()
200
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
206
class Item_func_week :public Item_int_func
209
Item_func_week(Item *a,Item *b) :Item_int_func(a,b) {}
211
const char *func_name() const { return "week"; }
212
void fix_length_and_dec()
215
max_length=2*MY_CHARSET_BIN_MB_MAXLEN;
220
class Item_func_yearweek :public Item_int_func
223
Item_func_yearweek(Item *a,Item *b) :Item_int_func(a,b) {}
225
const char *func_name() const { return "yearweek"; }
226
void fix_length_and_dec()
229
max_length=6*MY_CHARSET_BIN_MB_MAXLEN;
235
class Item_func_year :public Item_int_func
238
Item_func_year(Item *a) :Item_int_func(a) {}
240
const char *func_name() const { return "year"; }
241
enum_monotonicity_info get_monotonicity_info() const;
242
int64_t val_int_endpoint(bool left_endp, bool *incl_endp);
243
void fix_length_and_dec()
246
max_length=4*MY_CHARSET_BIN_MB_MAXLEN;
252
class Item_func_weekday :public Item_func
256
Item_func_weekday(Item *a,bool type_arg)
257
:Item_func(a), odbc_type(type_arg) {}
259
double val_real() { assert(fixed == 1); return (double) val_int(); }
260
String *val_str(String *str)
263
str->set(val_int(), &my_charset_bin);
264
return null_value ? 0 : str;
266
const char *func_name() const
268
return (odbc_type ? "dayofweek" : "weekday");
270
enum Item_result result_type () const { return INT_RESULT; }
271
void fix_length_and_dec()
273
collation.set(&my_charset_bin);
275
max_length=1*MY_CHARSET_BIN_MB_MAXLEN;
280
class Item_func_dayname :public Item_func_weekday
283
Item_func_dayname(Item *a) :Item_func_weekday(a,0) {}
284
const char *func_name() const { return "dayname"; }
285
String *val_str(String *str);
286
enum Item_result result_type () const { return STRING_RESULT; }
287
void fix_length_and_dec()
289
collation.set(&my_charset_bin);
291
max_length=9*MY_CHARSET_BIN_MB_MAXLEN;
297
class Item_func_unix_timestamp :public Item_int_func
301
Item_func_unix_timestamp() :Item_int_func() {}
302
Item_func_unix_timestamp(Item *a) :Item_int_func(a) {}
304
const char *func_name() const { return "unix_timestamp"; }
305
void fix_length_and_dec()
308
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
313
class Item_func_time_to_sec :public Item_int_func
316
Item_func_time_to_sec(Item *item) :Item_int_func(item) {}
318
const char *func_name() const { return "time_to_sec"; }
319
void fix_length_and_dec()
322
max_length=10*MY_CHARSET_BIN_MB_MAXLEN;
328
This can't be a Item_str_func, because the val_real() functions are special
331
class Item_date :public Item_func
334
Item_date() :Item_func() {}
335
Item_date(Item *a) :Item_func(a) {}
336
enum Item_result result_type () const { return STRING_RESULT; }
337
enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDATE; }
338
String *val_str(String *str);
340
double val_real() { return val_real_from_decimal(); }
341
const char *func_name() const { return "date"; }
342
void fix_length_and_dec()
344
collation.set(&my_charset_bin);
346
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
348
Field *tmp_table_field(TABLE *table)
350
return tmp_table_field_from_field_type(table, 0);
352
bool result_as_int64_t() { return true; }
353
my_decimal *val_decimal(my_decimal *decimal_value)
356
return val_decimal_from_date(decimal_value);
358
int save_in_field(Field *field,
359
bool no_conversions __attribute__((unused)))
361
return save_date_in_field(field);
366
class Item_date_func :public Item_str_func
369
Item_date_func() :Item_str_func() {}
370
Item_date_func(Item *a) :Item_str_func(a) {}
371
Item_date_func(Item *a,Item *b) :Item_str_func(a,b) {}
372
Item_date_func(Item *a,Item *b, Item *c) :Item_str_func(a,b,c) {}
373
enum_field_types field_type() const { return DRIZZLE_TYPE_DATETIME; }
374
Field *tmp_table_field(TABLE *table)
376
return tmp_table_field_from_field_type(table, 0);
378
bool result_as_int64_t() { return true; }
379
double val_real() { return (double) val_int(); }
380
my_decimal *val_decimal(my_decimal *decimal_value)
383
return val_decimal_from_date(decimal_value);
385
int save_in_field(Field *field,
386
bool no_conversions __attribute__((unused)))
388
return save_date_in_field(field);
393
class Item_str_timefunc :public Item_str_func
396
Item_str_timefunc() :Item_str_func() {}
397
Item_str_timefunc(Item *a) :Item_str_func(a) {}
398
Item_str_timefunc(Item *a,Item *b) :Item_str_func(a,b) {}
399
Item_str_timefunc(Item *a, Item *b, Item *c) :Item_str_func(a, b ,c) {}
400
enum_field_types field_type() const { return DRIZZLE_TYPE_TIME; }
401
void fix_length_and_dec()
403
decimals= DATETIME_DEC;
404
max_length=MAX_TIME_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
406
Field *tmp_table_field(TABLE *table)
408
return tmp_table_field_from_field_type(table, 0);
410
double val_real() { return val_real_from_decimal(); }
411
my_decimal *val_decimal(my_decimal *decimal_value)
414
return val_decimal_from_time(decimal_value);
416
int save_in_field(Field *field,
417
bool no_conversions __attribute__((unused)))
419
return save_time_in_field(field);
424
/* Abstract CURTIME function. Children should define what time zone is used */
426
class Item_func_curtime :public Item_str_timefunc
432
Item_func_curtime() :Item_str_timefunc() {}
433
Item_func_curtime(Item *a) :Item_str_timefunc(a) {}
434
double val_real() { assert(fixed == 1); return (double) value; }
435
int64_t val_int() { assert(fixed == 1); return value; }
436
String *val_str(String *str);
437
void fix_length_and_dec();
439
Abstract method that defines which time zone is used for conversion.
440
Converts time current time in my_time_t representation to broken-down
441
DRIZZLE_TIME representation using UTC-SYSTEM or per-thread time zone.
443
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
444
bool result_as_int64_t() { return true; }
448
class Item_func_curtime_local :public Item_func_curtime
451
Item_func_curtime_local() :Item_func_curtime() {}
452
Item_func_curtime_local(Item *a) :Item_func_curtime(a) {}
453
const char *func_name() const { return "curtime"; }
454
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
458
class Item_func_curtime_utc :public Item_func_curtime
461
Item_func_curtime_utc() :Item_func_curtime() {}
462
Item_func_curtime_utc(Item *a) :Item_func_curtime(a) {}
463
const char *func_name() const { return "utc_time"; }
464
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
468
/* Abstract CURDATE function. See also Item_func_curtime. */
470
class Item_func_curdate :public Item_date
475
Item_func_curdate() :Item_date() {}
476
int64_t val_int() { assert(fixed == 1); return (value) ; }
477
String *val_str(String *str);
478
void fix_length_and_dec();
479
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
480
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
484
class Item_func_curdate_local :public Item_func_curdate
487
Item_func_curdate_local() :Item_func_curdate() {}
488
const char *func_name() const { return "curdate"; }
489
void store_now_in_TIME(DRIZZLE_TIME *now_time);
493
class Item_func_curdate_utc :public Item_func_curdate
496
Item_func_curdate_utc() :Item_func_curdate() {}
497
const char *func_name() const { return "utc_date"; }
498
void store_now_in_TIME(DRIZZLE_TIME *now_time);
502
/* Abstract CURRENT_TIMESTAMP function. See also Item_func_curtime */
504
class Item_func_now :public Item_date_func
508
char buff[20*2+32]; // +32 to make my_snprintf_{8bit|ucs2} happy
512
Item_func_now() :Item_date_func() {}
513
Item_func_now(Item *a) :Item_date_func(a) {}
514
enum Item_result result_type () const { return STRING_RESULT; }
515
int64_t val_int() { assert(fixed == 1); return value; }
516
int save_in_field(Field *to, bool no_conversions);
517
String *val_str(String *str);
518
void fix_length_and_dec();
519
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
520
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time)=0;
524
class Item_func_now_local :public Item_func_now
527
Item_func_now_local() :Item_func_now() {}
528
Item_func_now_local(Item *a) :Item_func_now(a) {}
529
const char *func_name() const { return "now"; }
530
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
531
virtual enum Functype functype() const { return NOW_FUNC; }
535
class Item_func_now_utc :public Item_func_now
538
Item_func_now_utc() :Item_func_now() {}
539
Item_func_now_utc(Item *a) :Item_func_now(a) {}
540
const char *func_name() const { return "utc_timestamp"; }
541
virtual void store_now_in_TIME(DRIZZLE_TIME *now_time);
546
This is like NOW(), but always uses the real current time, not the
547
query_start(). This matches the Oracle behavior.
549
class Item_func_sysdate_local :public Item_func_now
552
Item_func_sysdate_local() :Item_func_now() {}
553
Item_func_sysdate_local(Item *a) :Item_func_now(a) {}
554
bool const_item() const { return 0; }
555
const char *func_name() const { return "sysdate"; }
556
void store_now_in_TIME(DRIZZLE_TIME *now_time);
559
int save_in_field(Field *to, bool no_conversions);
560
String *val_str(String *str);
561
void fix_length_and_dec();
562
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
563
void update_used_tables()
565
Item_func_now::update_used_tables();
566
used_tables_cache|= RAND_TABLE_BIT;
571
class Item_func_from_days :public Item_date
574
Item_func_from_days(Item *a) :Item_date(a) {}
575
const char *func_name() const { return "from_days"; }
576
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
580
class Item_func_date_format :public Item_str_func
583
const bool is_time_format;
586
Item_func_date_format(Item *a,Item *b,bool is_time_format_arg)
587
:Item_str_func(a,b),is_time_format(is_time_format_arg) {}
588
String *val_str(String *str);
589
const char *func_name() const
590
{ return is_time_format ? "time_format" : "date_format"; }
591
void fix_length_and_dec();
592
uint format_length(const String *format);
593
bool eq(const Item *item, bool binary_cmp) const;
597
class Item_func_from_unixtime :public Item_date_func
601
Item_func_from_unixtime(Item *a) :Item_date_func(a) {}
603
String *val_str(String *str);
604
const char *func_name() const { return "from_unixtime"; }
605
void fix_length_and_dec();
606
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
611
We need Time_zone class declaration for storing pointers in
612
Item_func_convert_tz.
617
This class represents CONVERT_TZ() function.
618
The important fact about this function that it is handled in special way.
619
When such function is met in expression time_zone system tables are added
620
to global list of tables to open, so later those already opened and locked
621
tables can be used during this function calculation for loading time zone
624
class Item_func_convert_tz :public Item_date_func
627
If time zone parameters are constants we are caching objects that
628
represent them (we use separate from_tz_cached/to_tz_cached members
629
to indicate this fact, since NULL is legal value for from_tz/to_tz
632
bool from_tz_cached, to_tz_cached;
633
Time_zone *from_tz, *to_tz;
635
Item_func_convert_tz(Item *a, Item *b, Item *c):
636
Item_date_func(a, b, c), from_tz_cached(0), to_tz_cached(0) {}
638
String *val_str(String *str);
639
const char *func_name() const { return "convert_tz"; }
640
void fix_length_and_dec();
641
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
646
class Item_func_sec_to_time :public Item_str_timefunc
649
Item_func_sec_to_time(Item *item) :Item_str_timefunc(item) {}
653
return (double) Item_func_sec_to_time::val_int();
656
String *val_str(String *);
657
void fix_length_and_dec()
659
Item_str_timefunc::fix_length_and_dec();
660
collation.set(&my_charset_bin);
663
const char *func_name() const { return "sec_to_time"; }
664
bool result_as_int64_t() { return true; }
668
class Item_date_add_interval :public Item_date_func
671
enum_field_types cached_field_type;
674
const interval_type int_type; // keep it public
675
const bool date_sub_interval; // keep it public
676
Item_date_add_interval(Item *a,Item *b,interval_type type_arg,bool neg_arg)
677
:Item_date_func(a,b),int_type(type_arg), date_sub_interval(neg_arg) {}
678
String *val_str(String *);
679
const char *func_name() const { return "date_add_interval"; }
680
void fix_length_and_dec();
681
enum_field_types field_type() const { return cached_field_type; }
683
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);
684
bool eq(const Item *item, bool binary_cmp) const;
685
virtual void print(String *str, enum_query_type query_type);
689
class Item_extract :public Item_int_func
694
const interval_type int_type; // keep it public
695
Item_extract(interval_type type_arg, Item *a)
696
:Item_int_func(a), int_type(type_arg) {}
698
enum Functype functype() const { return EXTRACT_FUNC; }
699
const char *func_name() const { return "extract"; }
700
void fix_length_and_dec();
701
bool eq(const Item *item, bool binary_cmp) const;
702
virtual void print(String *str, enum_query_type query_type);
706
class Item_typecast :public Item_str_func
709
Item_typecast(Item *a) :Item_str_func(a) {}
710
String *val_str(String *a)
713
String *tmp=args[0]->val_str(a);
714
null_value=args[0]->null_value;
716
tmp->set_charset(collation.collation);
719
void fix_length_and_dec()
721
collation.set(&my_charset_bin);
722
max_length=args[0]->max_length;
724
virtual const char* cast_type() const= 0;
725
virtual void print(String *str, enum_query_type query_type);
729
class Item_typecast_maybe_null :public Item_typecast
732
Item_typecast_maybe_null(Item *a) :Item_typecast(a) {}
733
void fix_length_and_dec()
735
collation.set(&my_charset_bin);
736
max_length=args[0]->max_length;
742
class Item_char_typecast :public Item_typecast
745
const CHARSET_INFO *cast_cs, *from_cs;
746
bool charset_conversion;
749
Item_char_typecast(Item *a, int length_arg, const CHARSET_INFO * const cs_arg)
750
:Item_typecast(a), cast_length(length_arg), cast_cs(cs_arg) {}
751
enum Functype functype() const { return CHAR_TYPECAST_FUNC; }
752
bool eq(const Item *item, bool binary_cmp) const;
753
const char *func_name() const { return "cast_as_char"; }
754
const char* cast_type() const { return "char"; };
755
String *val_str(String *a);
756
void fix_length_and_dec();
757
virtual void print(String *str, enum_query_type query_type);
761
class Item_date_typecast :public Item_typecast_maybe_null
764
Item_date_typecast(Item *a) :Item_typecast_maybe_null(a) {}
765
const char *func_name() const { return "cast_as_date"; }
766
String *val_str(String *str);
767
bool get_date(DRIZZLE_TIME *ltime, uint fuzzy_date);
768
bool get_time(DRIZZLE_TIME *ltime);
769
const char *cast_type() const { return "date"; }
770
enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDATE; }
771
Field *tmp_table_field(TABLE *table)
773
return tmp_table_field_from_field_type(table, 0);
775
void fix_length_and_dec()
777
collation.set(&my_charset_bin);
781
bool result_as_int64_t() { return true; }
783
double val_real() { return (double) val_int(); }
784
my_decimal *val_decimal(my_decimal *decimal_value)
787
return val_decimal_from_date(decimal_value);
789
int save_in_field(Field *field,
790
bool no_conversions __attribute__((unused)))
792
return save_date_in_field(field);
797
class Item_time_typecast :public Item_typecast_maybe_null
800
Item_time_typecast(Item *a) :Item_typecast_maybe_null(a) {}
801
const char *func_name() const { return "cast_as_time"; }
802
String *val_str(String *str);
803
bool get_time(DRIZZLE_TIME *ltime);
804
const char *cast_type() const { return "time"; }
805
enum_field_types field_type() const { return DRIZZLE_TYPE_TIME; }
806
Field *tmp_table_field(TABLE *table)
808
return tmp_table_field_from_field_type(table, 0);
810
bool result_as_int64_t() { return true; }
812
double val_real() { return val_real_from_decimal(); }
813
my_decimal *val_decimal(my_decimal *decimal_value)
816
return val_decimal_from_time(decimal_value);
818
int save_in_field(Field *field,
819
bool no_conversions __attribute__((unused)))
821
return save_time_in_field(field);
826
class Item_datetime_typecast :public Item_typecast_maybe_null
829
Item_datetime_typecast(Item *a) :Item_typecast_maybe_null(a) {}
830
const char *func_name() const { return "cast_as_datetime"; }
831
String *val_str(String *str);
832
const char *cast_type() const { return "datetime"; }
833
enum_field_types field_type() const { return DRIZZLE_TYPE_DATETIME; }
834
Field *tmp_table_field(TABLE *table)
836
return tmp_table_field_from_field_type(table, 0);
838
void fix_length_and_dec()
840
collation.set(&my_charset_bin);
842
max_length= MAX_DATETIME_FULL_WIDTH * MY_CHARSET_BIN_MB_MAXLEN;
843
decimals= DATETIME_DEC;
845
bool result_as_int64_t() { return true; }
847
double val_real() { return val_real_from_decimal(); }
848
double val() { return (double) val_int(); }
849
my_decimal *val_decimal(my_decimal *decimal_value)
852
return val_decimal_from_date(decimal_value);
854
int save_in_field(Field *field,
855
bool no_conversions __attribute__((unused)))
857
return save_date_in_field(field);
861
class Item_func_makedate :public Item_date_func
864
Item_func_makedate(Item *a,Item *b) :Item_date_func(a,b) {}
865
String *val_str(String *str);
866
const char *func_name() const { return "makedate"; }
867
enum_field_types field_type() const { return DRIZZLE_TYPE_NEWDATE; }
868
void fix_length_and_dec()
871
max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
877
class Item_func_add_time :public Item_str_func
881
enum_field_types cached_field_type;
884
Item_func_add_time(Item *a, Item *b, bool type_arg, bool neg_arg)
885
:Item_str_func(a, b), is_date(type_arg) { sign= neg_arg ? -1 : 1; }
886
String *val_str(String *str);
887
enum_field_types field_type() const { return cached_field_type; }
888
void fix_length_and_dec();
890
Field *tmp_table_field(TABLE *table)
892
return tmp_table_field_from_field_type(table, 0);
894
virtual void print(String *str, enum_query_type query_type);
895
const char *func_name() const { return "add_time"; }
896
double val_real() { return val_real_from_decimal(); }
897
my_decimal *val_decimal(my_decimal *decimal_value)
900
if (cached_field_type == DRIZZLE_TYPE_TIME)
901
return val_decimal_from_time(decimal_value);
902
if (cached_field_type == DRIZZLE_TYPE_DATETIME)
903
return val_decimal_from_date(decimal_value);
904
return Item_str_func::val_decimal(decimal_value);
906
int save_in_field(Field *field, bool no_conversions)
908
if (cached_field_type == DRIZZLE_TYPE_TIME)
909
return save_time_in_field(field);
910
if (cached_field_type == DRIZZLE_TYPE_DATETIME)
911
return save_date_in_field(field);
912
return Item_str_func::save_in_field(field, no_conversions);
916
class Item_func_timediff :public Item_str_timefunc
919
Item_func_timediff(Item *a, Item *b)
920
:Item_str_timefunc(a, b) {}
921
String *val_str(String *str);
922
const char *func_name() const { return "timediff"; }
923
void fix_length_and_dec()
925
Item_str_timefunc::fix_length_and_dec();
930
class Item_func_maketime :public Item_str_timefunc
933
Item_func_maketime(Item *a, Item *b, Item *c)
934
:Item_str_timefunc(a, b, c)
938
String *val_str(String *str);
939
const char *func_name() const { return "maketime"; }
942
class Item_func_microsecond :public Item_int_func
945
Item_func_microsecond(Item *a) :Item_int_func(a) {}
947
const char *func_name() const { return "microsecond"; }
948
void fix_length_and_dec()
956
class Item_func_timestamp_diff :public Item_int_func
958
const interval_type int_type;
960
Item_func_timestamp_diff(Item *a,Item *b,interval_type type_arg)
961
:Item_int_func(a,b), int_type(type_arg) {}
962
const char *func_name() const { return "timestampdiff"; }
964
void fix_length_and_dec()
969
virtual void print(String *str, enum_query_type query_type);
973
enum date_time_format
975
USA_FORMAT, JIS_FORMAT, ISO_FORMAT, EUR_FORMAT, INTERNAL_FORMAT
978
class Item_func_get_format :public Item_str_func
981
const timestamp_type type; // keep it public
982
Item_func_get_format(timestamp_type type_arg, Item *a)
983
:Item_str_func(a), type(type_arg)
985
String *val_str(String *str);
986
const char *func_name() const { return "get_format"; }
987
void fix_length_and_dec()
991
max_length=17*MY_CHARSET_BIN_MB_MAXLEN;
993
virtual void print(String *str, enum_query_type query_type);
997
class Item_func_str_to_date :public Item_str_func
999
enum_field_types cached_field_type;
1000
date_time_format_types cached_format_type;
1001
timestamp_type cached_timestamp_type;
1004
Item_func_str_to_date(Item *a, Item *b)
1005
:Item_str_func(a, b), const_item(false)
1007
String *val_str(String *str);
1008
bool get_date(DRIZZLE_TIME *ltime, uint fuzzy_date);
1009
const char *func_name() const { return "str_to_date"; }
1010
enum_field_types field_type() const { return cached_field_type; }
1011
void fix_length_and_dec();
1012
Field *tmp_table_field(TABLE *table)
1014
return tmp_table_field_from_field_type(table, 1);
1019
class Item_func_last_day :public Item_date
1022
Item_func_last_day(Item *a) :Item_date(a) {}
1023
const char *func_name() const { return "last_day"; }
1024
bool get_date(DRIZZLE_TIME *res, uint fuzzy_date);