@@ -495,7 +495,6 @@ class Item_temporal_func: public Item_func
495
495
Item_temporal_func (THD *thd, Item *a, Item *b): Item_func(thd, a, b) {}
496
496
Item_temporal_func (THD *thd, Item *a, Item *b, Item *c): Item_func(thd, a, b, c) {}
497
497
enum Item_result result_type () const { return STRING_RESULT; }
498
- enum_field_types field_type () const { return MYSQL_TYPE_DATETIME; }
499
498
Item_result cmp_type () const { return TIME_RESULT; }
500
499
String *val_str (String *str);
501
500
longlong val_int () { return val_int_from_date (); }
@@ -515,20 +514,20 @@ class Item_temporal_func: public Item_func
515
514
Abstract class for functions returning TIME, DATE, DATETIME or string values,
516
515
whose data type depends on parameters and is set at fix_fields time.
517
516
*/
518
- class Item_temporal_hybrid_func : public Item_temporal_func
517
+ class Item_temporal_hybrid_func : public Item_temporal_func ,
518
+ public Type_handler_hybrid_field_type
519
519
{
520
520
protected:
521
- enum_field_types cached_field_type; // TIME, DATE, DATETIME or STRING
522
521
String ascii_buf; // Conversion buffer
523
522
public:
524
523
Item_temporal_hybrid_func (THD *thd, Item *a, Item *b):
525
524
Item_temporal_func (thd, a, b) {}
526
- enum_field_types field_type () const { return cached_field_type; }
527
- Item_result cmp_type () const
528
- {
529
- return cached_field_type == MYSQL_TYPE_STRING ?
530
- STRING_RESULT : TIME_RESULT;
531
- }
525
+ enum_field_types field_type () const
526
+ { return Type_handler_hybrid_field_type::field_type (); }
527
+ enum Item_result result_type () const
528
+ { return Type_handler_hybrid_field_type::result_type (); }
529
+ enum Item_result cmp_type () const
530
+ { return Type_handler_hybrid_field_type::cmp_type (); }
532
531
CHARSET_INFO *charset_for_protocol () const
533
532
{
534
533
/*
@@ -538,7 +537,7 @@ class Item_temporal_hybrid_func: public Item_temporal_func
538
537
(which is fixed from @@collation_connection in fix_length_and_dec).
539
538
*/
540
539
DBUG_ASSERT (fixed == 1 );
541
- return cached_field_type == MYSQL_TYPE_STRING ?
540
+ return Item_temporal_hybrid_func::field_type () == MYSQL_TYPE_STRING ?
542
541
collation.collation : &my_charset_bin;
543
542
}
544
543
/* *
@@ -581,6 +580,17 @@ class Item_timefunc :public Item_temporal_func
581
580
};
582
581
583
582
583
+ class Item_datetimefunc :public Item_temporal_func
584
+ {
585
+ public:
586
+ Item_datetimefunc (THD *thd): Item_temporal_func(thd) {}
587
+ Item_datetimefunc (THD *thd, Item *a): Item_temporal_func(thd, a) {}
588
+ Item_datetimefunc (THD *thd, Item *a, Item *b, Item *c):
589
+ Item_temporal_func (thd, a, b ,c) {}
590
+ enum_field_types field_type () const { return MYSQL_TYPE_DATETIME; }
591
+ };
592
+
593
+
584
594
/* Abstract CURTIME function. Children should define what time zone is used */
585
595
586
596
class Item_func_curtime :public Item_timefunc
@@ -665,11 +675,11 @@ class Item_func_curdate_utc :public Item_func_curdate
665
675
/* Abstract CURRENT_TIMESTAMP function. See also Item_func_curtime */
666
676
667
677
668
- class Item_func_now :public Item_temporal_func
678
+ class Item_func_now :public Item_datetimefunc
669
679
{
670
680
MYSQL_TIME ltime;
671
681
public:
672
- Item_func_now (THD *thd, uint dec): Item_temporal_func (thd) { decimals= dec; }
682
+ Item_func_now (THD *thd, uint dec): Item_datetimefunc (thd) { decimals= dec; }
673
683
bool fix_fields (THD *, Item **);
674
684
void fix_length_and_dec ()
675
685
{
@@ -759,11 +769,11 @@ class Item_func_date_format :public Item_str_func
759
769
};
760
770
761
771
762
- class Item_func_from_unixtime :public Item_temporal_func
772
+ class Item_func_from_unixtime :public Item_datetimefunc
763
773
{
764
774
Time_zone *tz;
765
775
public:
766
- Item_func_from_unixtime (THD *thd, Item *a): Item_temporal_func (thd, a) {}
776
+ Item_func_from_unixtime (THD *thd, Item *a): Item_datetimefunc (thd, a) {}
767
777
const char *func_name () const { return " from_unixtime" ; }
768
778
void fix_length_and_dec ();
769
779
bool get_date (MYSQL_TIME *res, ulonglong fuzzy_date);
@@ -784,7 +794,7 @@ class Time_zone;
784
794
tables can be used during this function calculation for loading time zone
785
795
descriptions.
786
796
*/
787
- class Item_func_convert_tz :public Item_temporal_func
797
+ class Item_func_convert_tz :public Item_datetimefunc
788
798
{
789
799
/*
790
800
If time zone parameters are constants we are caching objects that
@@ -796,7 +806,7 @@ class Item_func_convert_tz :public Item_temporal_func
796
806
Time_zone *from_tz, *to_tz;
797
807
public:
798
808
Item_func_convert_tz (THD *thd, Item *a, Item *b, Item *c):
799
- Item_temporal_func (thd, a, b, c), from_tz_cached(0 ), to_tz_cached(0 ) {}
809
+ Item_datetimefunc (thd, a, b, c), from_tz_cached(0 ), to_tz_cached(0 ) {}
800
810
const char *func_name () const { return " convert_tz" ; }
801
811
void fix_length_and_dec ();
802
812
bool get_date (MYSQL_TIME *res, ulonglong fuzzy_date);
0 commit comments