Commit 1b4bb3b5 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-19124 Assertion `0' failed in Item::val_native

parent 88400450
......@@ -1194,5 +1194,29 @@ CREATE TABLE t2 SELECT 1 AS f FROM t1 GROUP BY FROM_DAYS(d);
ERROR 22007: Truncated incorrect date value: '0000-00-00'
DROP TABLE t1;
#
# MDEV-19124 Assertion `0' failed in Item::val_native
#
CREATE TABLE t1 (d1 TIMESTAMP(5));
INSERT INTO t1 VALUES ('2018-10-14 15:31:01');
SELECT LEAD(d1,1) OVER(ORDER BY d1) FROM t1;
LEAD(d1,1) OVER(ORDER BY d1)
NULL
SELECT LAG(d1,1) OVER(ORDER BY d1) FROM t1;
LAG(d1,1) OVER(ORDER BY d1)
NULL
INSERT INTO t1 VALUES ('2018-10-14 15:31:02');
INSERT INTO t1 VALUES ('2018-10-14 15:31:03');
SELECT LEAD(d1,1) OVER(ORDER BY d1) FROM t1;
LEAD(d1,1) OVER(ORDER BY d1)
2018-10-14 15:31:02.00000
2018-10-14 15:31:03.00000
NULL
SELECT LAG(d1,1) OVER(ORDER BY d1) FROM t1;
LAG(d1,1) OVER(ORDER BY d1)
NULL
2018-10-14 15:31:01.00000
2018-10-14 15:31:02.00000
DROP TABLE t1;
#
# End of 10.4 tests
#
......@@ -786,6 +786,21 @@ CREATE TABLE t2 SELECT 1 AS f FROM t1 GROUP BY FROM_DAYS(d);
DROP TABLE t1;
--echo #
--echo # MDEV-19124 Assertion `0' failed in Item::val_native
--echo #
CREATE TABLE t1 (d1 TIMESTAMP(5));
INSERT INTO t1 VALUES ('2018-10-14 15:31:01');
SELECT LEAD(d1,1) OVER(ORDER BY d1) FROM t1;
SELECT LAG(d1,1) OVER(ORDER BY d1) FROM t1;
INSERT INTO t1 VALUES ('2018-10-14 15:31:02');
INSERT INTO t1 VALUES ('2018-10-14 15:31:03');
SELECT LEAD(d1,1) OVER(ORDER BY d1) FROM t1;
SELECT LAG(d1,1) OVER(ORDER BY d1) FROM t1;
DROP TABLE t1;
--echo #
--echo # End of 10.4 tests
--echo #
......@@ -439,6 +439,14 @@ Item_sum_hybrid_simple::val_str(String *str)
return retval;
}
bool Item_sum_hybrid_simple::val_native(THD *thd, Native *to)
{
DBUG_ASSERT(fixed == 1);
if (null_value)
return true;
return val_native_from_item(thd, value, to);
}
bool Item_sum_hybrid_simple::get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate)
{
DBUG_ASSERT(fixed == 1);
......
......@@ -318,6 +318,7 @@ class Item_sum_hybrid_simple : public Item_sum,
my_decimal *val_decimal(my_decimal *);
void reset_field();
String *val_str(String *);
bool val_native(THD *thd, Native *to);
bool get_date(THD *thd, MYSQL_TIME *ltime, date_mode_t fuzzydate);
const Type_handler *type_handler() const
{ return Type_handler_hybrid_field_type::type_handler(); }
......@@ -1250,6 +1251,15 @@ class Item_window_func : public Item_func_or_sum
return res;
}
bool val_native(THD *thd, Native *to)
{
if (force_return_blank)
return null_value= true;
if (read_value_from_result_field)
return val_native_from_field(result_field, to);
return val_native_from_item(thd, window_func(), to);
}
my_decimal* val_decimal(my_decimal* dec)
{
my_decimal *res;
......
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