diff options
author | Alexander Barkov <bar@mariadb.com> | 2019-04-02 09:13:16 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2019-04-02 09:13:16 +0400 |
commit | 1b4bb3b5bb2df01bd7ce1c8499d9cb79a62201c9 (patch) | |
tree | a38c6ea3a8d2c735739cdcc774ba03b32616ecca | |
parent | 884004502134d881af0bcb59f97a838784ab5bbe (diff) | |
download | mariadb-git-1b4bb3b5bb2df01bd7ce1c8499d9cb79a62201c9.tar.gz |
MDEV-19124 Assertion `0' failed in Item::val_native
-rw-r--r-- | mysql-test/main/type_timestamp.result | 24 | ||||
-rw-r--r-- | mysql-test/main/type_timestamp.test | 15 | ||||
-rw-r--r-- | sql/item_windowfunc.cc | 8 | ||||
-rw-r--r-- | sql/item_windowfunc.h | 10 |
4 files changed, 57 insertions, 0 deletions
diff --git a/mysql-test/main/type_timestamp.result b/mysql-test/main/type_timestamp.result index 019bfb6289f..c25adf492c7 100644 --- a/mysql-test/main/type_timestamp.result +++ b/mysql-test/main/type_timestamp.result @@ -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 # diff --git a/mysql-test/main/type_timestamp.test b/mysql-test/main/type_timestamp.test index b76dd1b0c89..2af7f8994ab 100644 --- a/mysql-test/main/type_timestamp.test +++ b/mysql-test/main/type_timestamp.test @@ -787,5 +787,20 @@ 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 # diff --git a/sql/item_windowfunc.cc b/sql/item_windowfunc.cc index aa2c7756ab7..adff1c3612b 100644 --- a/sql/item_windowfunc.cc +++ b/sql/item_windowfunc.cc @@ -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); diff --git a/sql/item_windowfunc.h b/sql/item_windowfunc.h index ea9f0147f83..8c6a661366f 100644 --- a/sql/item_windowfunc.h +++ b/sql/item_windowfunc.h @@ -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 @@ public: 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; |