@@ -871,7 +871,7 @@ void Item_func_num1::fix_length_and_dec()
871
871
String *Item_func_hybrid_field_type::val_str (String *str)
872
872
{
873
873
DBUG_ASSERT (fixed == 1 );
874
- switch (Item_func_hybrid_field_type::result_type ()) {
874
+ switch (Item_func_hybrid_field_type::cmp_type ()) {
875
875
case DECIMAL_RESULT:
876
876
{
877
877
my_decimal decimal_value, *val;
@@ -898,24 +898,23 @@ String *Item_func_hybrid_field_type::val_str(String *str)
898
898
str->set_real (nr, decimals, collation.collation );
899
899
break ;
900
900
}
901
- case STRING_RESULT:
902
- if (is_temporal_type (field_type ()))
901
+ case TIME_RESULT:
902
+ {
903
+ MYSQL_TIME ltime;
904
+ if (date_op (<ime,
905
+ field_type () == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ) ||
906
+ str->alloc (MAX_DATE_STRING_REP_LENGTH))
903
907
{
904
- MYSQL_TIME ltime;
905
- if (date_op (<ime,
906
- field_type () == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ) ||
907
- str->alloc (MAX_DATE_STRING_REP_LENGTH))
908
- {
909
- null_value= 1 ;
910
- return (String *) 0 ;
911
- }
912
- ltime.time_type = mysql_type_to_time_type (field_type ());
913
- str->length (my_TIME_to_str (<ime, const_cast <char *>(str->ptr ()), decimals));
914
- str->set_charset (&my_charset_bin);
915
- return str;
908
+ null_value= 1 ;
909
+ return (String *) 0 ;
916
910
}
911
+ ltime.time_type = mysql_type_to_time_type (field_type ());
912
+ str->length (my_TIME_to_str (<ime, const_cast <char *>(str->ptr ()), decimals));
913
+ str->set_charset (&my_charset_bin);
914
+ return str;
915
+ }
916
+ case STRING_RESULT:
917
917
return str_op (&str_value);
918
- case TIME_RESULT:
919
918
case ROW_RESULT:
920
919
DBUG_ASSERT (0 );
921
920
}
@@ -926,7 +925,7 @@ String *Item_func_hybrid_field_type::val_str(String *str)
926
925
double Item_func_hybrid_field_type::val_real ()
927
926
{
928
927
DBUG_ASSERT (fixed == 1 );
929
- switch (Item_func_hybrid_field_type::result_type ()) {
928
+ switch (Item_func_hybrid_field_type::cmp_type ()) {
930
929
case DECIMAL_RESULT:
931
930
{
932
931
my_decimal decimal_value, *val;
@@ -943,24 +942,23 @@ double Item_func_hybrid_field_type::val_real()
943
942
}
944
943
case REAL_RESULT:
945
944
return real_op ();
946
- case STRING_RESULT :
945
+ case TIME_RESULT :
947
946
{
948
- if (is_temporal_type (field_type ()))
947
+ MYSQL_TIME ltime;
948
+ if (date_op (<ime,
949
+ field_type () == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ))
949
950
{
950
- MYSQL_TIME ltime;
951
- if (date_op (<ime,
952
- field_type () == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ))
953
- {
954
- null_value= 1 ;
955
- return 0 ;
956
- }
957
- ltime.time_type = mysql_type_to_time_type (field_type ());
958
- return TIME_to_double (<ime);
951
+ null_value= 1 ;
952
+ return 0 ;
959
953
}
954
+ ltime.time_type = mysql_type_to_time_type (field_type ());
955
+ return TIME_to_double (<ime);
956
+ }
957
+ case STRING_RESULT:
958
+ {
960
959
String *res= str_op (&str_value);
961
960
return res ? double_from_string_with_check (res) : 0.0 ;
962
961
}
963
- case TIME_RESULT:
964
962
case ROW_RESULT:
965
963
DBUG_ASSERT (0 );
966
964
}
@@ -971,7 +969,7 @@ double Item_func_hybrid_field_type::val_real()
971
969
longlong Item_func_hybrid_field_type::val_int ()
972
970
{
973
971
DBUG_ASSERT (fixed == 1 );
974
- switch (Item_func_hybrid_field_type::result_type ()) {
972
+ switch (Item_func_hybrid_field_type::cmp_type ()) {
975
973
case DECIMAL_RESULT:
976
974
{
977
975
my_decimal decimal_value, *val;
@@ -985,24 +983,23 @@ longlong Item_func_hybrid_field_type::val_int()
985
983
return int_op ();
986
984
case REAL_RESULT:
987
985
return (longlong) rint (real_op ());
988
- case STRING_RESULT :
986
+ case TIME_RESULT :
989
987
{
990
- if (is_temporal_type (field_type ()))
988
+ MYSQL_TIME ltime;
989
+ if (date_op (<ime,
990
+ field_type () == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ))
991
991
{
992
- MYSQL_TIME ltime;
993
- if (date_op (<ime,
994
- field_type () == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ))
995
- {
996
- null_value= 1 ;
997
- return 0 ;
998
- }
999
- ltime.time_type = mysql_type_to_time_type (field_type ());
1000
- return TIME_to_ulonglong (<ime);
992
+ null_value= 1 ;
993
+ return 0 ;
1001
994
}
995
+ ltime.time_type = mysql_type_to_time_type (field_type ());
996
+ return TIME_to_ulonglong (<ime);
997
+ }
998
+ case STRING_RESULT:
999
+ {
1002
1000
String *res= str_op (&str_value);
1003
1001
return res ? longlong_from_string_with_check (res) : 0 ;
1004
1002
}
1005
- case TIME_RESULT:
1006
1003
case ROW_RESULT:
1007
1004
DBUG_ASSERT (0 );
1008
1005
}
@@ -1014,7 +1011,7 @@ my_decimal *Item_func_hybrid_field_type::val_decimal(my_decimal *decimal_value)
1014
1011
{
1015
1012
my_decimal *val= decimal_value;
1016
1013
DBUG_ASSERT (fixed == 1 );
1017
- switch (Item_func_hybrid_field_type::result_type ()) {
1014
+ switch (Item_func_hybrid_field_type::cmp_type ()) {
1018
1015
case DECIMAL_RESULT:
1019
1016
val= decimal_op (decimal_value);
1020
1017
break ;
@@ -1030,26 +1027,25 @@ my_decimal *Item_func_hybrid_field_type::val_decimal(my_decimal *decimal_value)
1030
1027
double2my_decimal (E_DEC_FATAL_ERROR, result, decimal_value);
1031
1028
break ;
1032
1029
}
1033
- case STRING_RESULT :
1030
+ case TIME_RESULT :
1034
1031
{
1035
- if (is_temporal_type (field_type ()))
1032
+ MYSQL_TIME ltime;
1033
+ if (date_op (<ime,
1034
+ field_type () == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ))
1036
1035
{
1037
- MYSQL_TIME ltime;
1038
- if (date_op (<ime,
1039
- field_type () == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ))
1040
- {
1041
- my_decimal_set_zero (decimal_value);
1042
- null_value= 1 ;
1043
- return 0 ;
1044
- }
1045
- ltime.time_type = mysql_type_to_time_type (field_type ());
1046
- return date2my_decimal (<ime, decimal_value);
1036
+ my_decimal_set_zero (decimal_value);
1037
+ null_value= 1 ;
1038
+ return 0 ;
1047
1039
}
1040
+ ltime.time_type = mysql_type_to_time_type (field_type ());
1041
+ return date2my_decimal (<ime, decimal_value);
1042
+ }
1043
+ case STRING_RESULT:
1044
+ {
1048
1045
String *res= str_op (&str_value);
1049
1046
return res ? decimal_from_string_with_check (decimal_value, res) : 0 ;
1050
1047
}
1051
1048
case ROW_RESULT:
1052
- case TIME_RESULT:
1053
1049
DBUG_ASSERT (0 );
1054
1050
}
1055
1051
return val;
@@ -1060,7 +1056,7 @@ bool Item_func_hybrid_field_type::get_date(MYSQL_TIME *ltime,
1060
1056
ulonglong fuzzydate)
1061
1057
{
1062
1058
DBUG_ASSERT (fixed == 1 );
1063
- switch (Item_func_hybrid_field_type::result_type ()) {
1059
+ switch (Item_func_hybrid_field_type::cmp_type ()) {
1064
1060
case DECIMAL_RESULT:
1065
1061
{
1066
1062
my_decimal value, *res;
@@ -1088,23 +1084,21 @@ bool Item_func_hybrid_field_type::get_date(MYSQL_TIME *ltime,
1088
1084
goto err;
1089
1085
break ;
1090
1086
}
1087
+ case TIME_RESULT:
1088
+ return date_op (ltime,
1089
+ fuzzydate |
1090
+ (field_type () == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ));
1091
1091
case STRING_RESULT:
1092
1092
{
1093
- if (is_temporal_type (field_type ()))
1094
- return date_op (ltime,
1095
- fuzzydate |
1096
- (field_type () == MYSQL_TYPE_TIME ? TIME_TIME_ONLY : 0 ));
1097
1093
char buff[40 ];
1098
1094
String tmp (buff,sizeof (buff), &my_charset_bin),*res;
1099
1095
if (!(res= str_op (&tmp)) ||
1100
1096
str_to_datetime_with_warn (res->charset (), res->ptr (), res->length (),
1101
1097
ltime, fuzzydate))
1102
1098
goto err;
1103
1099
break ;
1104
- break ;
1105
1100
}
1106
1101
case ROW_RESULT:
1107
- case TIME_RESULT:
1108
1102
DBUG_ASSERT (0 );
1109
1103
}
1110
1104
0 commit comments