Commit fff7fc50 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-10817 CAST(MAX(DATE'2001-01-01') AS TIME) returns a wrong result

parent 8128ae48
...@@ -1245,5 +1245,19 @@ a b c ...@@ -1245,5 +1245,19 @@ a b c
2070 00:00:00 00:00:00 2070 00:00:00 00:00:00
DROP TABLE t1,t2; DROP TABLE t1,t2;
# #
# MDEV-10817 CAST(MAX(DATE'2001-01-01') AS TIME) returns a wrong result
#
SELECT CAST(DATE'2001-01-01' AS TIME);
CAST(DATE'2001-01-01' AS TIME)
00:00:00
SELECT CAST(MAX(DATE'2001-01-01') AS TIME);
CAST(MAX(DATE'2001-01-01') AS TIME)
00:00:00
CREATE FUNCTION f1() RETURNS DATE RETURN DATE'2001-01-01';
SELECT CAST(f1() AS TIME);
CAST(f1() AS TIME)
00:00:00
DROP FUNCTION f1;
#
# End of 10.2 tests # End of 10.2 tests
# #
...@@ -746,6 +746,17 @@ SELECT * FROM t1; ...@@ -746,6 +746,17 @@ SELECT * FROM t1;
DROP TABLE t1,t2; DROP TABLE t1,t2;
--echo #
--echo # MDEV-10817 CAST(MAX(DATE'2001-01-01') AS TIME) returns a wrong result
--echo #
SELECT CAST(DATE'2001-01-01' AS TIME);
SELECT CAST(MAX(DATE'2001-01-01') AS TIME);
CREATE FUNCTION f1() RETURNS DATE RETURN DATE'2001-01-01';
SELECT CAST(f1() AS TIME);
DROP FUNCTION f1;
--echo # --echo #
--echo # End of 10.2 tests --echo # End of 10.2 tests
--echo # --echo #
...@@ -2367,6 +2367,13 @@ class Item_func_sp :public Item_func ...@@ -2367,6 +2367,13 @@ class Item_func_sp :public Item_func
return sp_result_field->val_decimal(dec_buf); return sp_result_field->val_decimal(dec_buf);
} }
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
if (execute())
return true;
return sp_result_field->get_date(ltime, fuzzydate);
}
String *val_str(String *str) String *val_str(String *str)
{ {
String buf; String buf;
......
...@@ -2065,6 +2065,18 @@ void Item_sum_hybrid::clear() ...@@ -2065,6 +2065,18 @@ void Item_sum_hybrid::clear()
null_value= 1; null_value= 1;
} }
bool
Item_sum_hybrid::get_date(MYSQL_TIME *ltime, ulonglong fuzzydate)
{
DBUG_ASSERT(fixed == 1);
if (null_value)
return 0;
bool retval= value->get_date(ltime, fuzzydate);
if ((null_value= value->null_value))
DBUG_ASSERT(retval == true);
return retval;
}
double Item_sum_hybrid::val_real() double Item_sum_hybrid::val_real()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
......
...@@ -1037,6 +1037,7 @@ class Item_sum_hybrid :public Item_sum, public Type_handler_hybrid_field_type ...@@ -1037,6 +1037,7 @@ class Item_sum_hybrid :public Item_sum, public Type_handler_hybrid_field_type
double val_real(); double val_real();
longlong val_int(); longlong val_int();
my_decimal *val_decimal(my_decimal *); my_decimal *val_decimal(my_decimal *);
bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate);
void reset_field(); void reset_field();
String *val_str(String *); String *val_str(String *);
bool keep_field_type(void) const { return 1; } bool keep_field_type(void) const { return 1; }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment