revision-id: eae5844ca04c89823cc9ee88095cf89aa45cdb69 (mariadb-10.3.6-127-geae5844ca04) parent(s): 4513de3127df61fa2030690110bb34b7e1c40849 author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2018-05-09 13:39:13 +0200 message: MDEV-15576: Server crashed in Cached_item_str::cmp / sortcmp or Assertion `item->null_value' failed in Type_handler_temporal_result::make_sort_key upon SELECT with NULLIF and ROLLUP Fix Item_func_rollup_const::get_date to process correctly NULL value. --- mysql-test/main/olap.result | 14 ++++++++++++++ mysql-test/main/olap.test | 17 +++++++++++++++++ sql/item_func.h | 4 +++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/mysql-test/main/olap.result b/mysql-test/main/olap.result index bcc96d4951d..6fdbe008016 100644 --- a/mysql-test/main/olap.result +++ b/mysql-test/main/olap.result @@ -816,3 +816,17 @@ a int(11) YES 0 b int(20) YES 0 DROP VIEW v1; DROP TABLE t1; +# +# MDEV-15576: Server crashed in Cached_item_str::cmp / sortcmp or +# Assertion `item->null_value' failed in +# Type_handler_temporal_result::make_sort_key upon SELECT with NULLIF +# and ROLLUP +# +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); +SELECT NULLIF( CAST( 'foo' AS DATE ), NULL & 'bar' ) AS f FROM t1 GROUP BY f WITH ROLLUP; +f +NULL +NULL +DROP TABLE t1; +# End of 10.3 Tests diff --git a/mysql-test/main/olap.test b/mysql-test/main/olap.test index 3da08581a87..74dbe8ba10b 100644 --- a/mysql-test/main/olap.test +++ b/mysql-test/main/olap.test @@ -447,3 +447,20 @@ DESC v1; DROP VIEW v1; DROP TABLE t1; + +--echo # +--echo # MDEV-15576: Server crashed in Cached_item_str::cmp / sortcmp or +--echo # Assertion `item->null_value' failed in +--echo # Type_handler_temporal_result::make_sort_key upon SELECT with NULLIF +--echo # and ROLLUP +--echo # + +CREATE TABLE t1 (i INT); +INSERT INTO t1 VALUES (1),(2); +--disable_warnings +SELECT NULLIF( CAST( 'foo' AS DATE ), NULL & 'bar' ) AS f FROM t1 GROUP BY f WITH ROLLUP; +--enable_warnings +DROP TABLE t1; + + +--echo # End of 10.3 Tests diff --git a/sql/item_func.h b/sql/item_func.h index 29ff14f7b39..c203a21cc2b 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -1613,7 +1613,9 @@ class Item_func_rollup_const :public Item_func my_decimal *val_decimal(my_decimal *dec) { return args[0]->val_decimal(dec); } bool get_date(MYSQL_TIME *ltime, ulonglong fuzzydate) { - return args[0]->get_date(ltime, fuzzydate); + bool rc= args[0]->get_date(ltime, fuzzydate); + null_value= rc; + return rc; } const char *func_name() const { return "rollup_const"; } bool const_item() const { return 0; }