From ee8860169cbf5c3cf0c8270e6e21f9efb8f01b5a Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Nov 2007 20:53:44 +0400 Subject: Fix for bug #32558: group by null-returning expression with rollup causes crash Problem: setting Item_func_rollup_const::null_value property to argument's null_value before (without) the argument evaluation may result in a crash due to wrong null_value. Fix: use is_null() to set Item_func_rollup_const::null_value instead as it evaluates the argument if necessary and returns a proper value. mysql-test/r/olap.result: Fix for bug #32558: group by null-returning expression with rollup causes crash - test result. mysql-test/t/olap.test: Fix for bug #32558: group by null-returning expression with rollup causes crash - test case. sql/item_func.h: Fix for bug #32558: group by null-returning expression with rollup causes crash - use args[0]->is_null() to obtain Item_func_rollup_const::null_value instead of args[0]->null_value as it's not set in advance in case of constant functions. --- mysql-test/r/olap.result | 8 ++++++++ mysql-test/t/olap.test | 9 +++++++++ sql/item_func.h | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result index a1d66b11f58..ad04e7304c9 100644 --- a/mysql-test/r/olap.result +++ b/mysql-test/r/olap.result @@ -726,3 +726,11 @@ count(a) 3 drop table t1; ############################################################## +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(0); +SELECT 1 FROM t1 GROUP BY (DATE(NULL)) WITH ROLLUP; +1 +1 +1 +DROP TABLE t1; +End of 5.0 tests diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test index 1ac99d9c39f..d1e40024733 100644 --- a/mysql-test/t/olap.test +++ b/mysql-test/t/olap.test @@ -367,3 +367,12 @@ select count(a) from t1 group by null with rollup; drop table t1; --echo ############################################################## +# +# Bug #32558: group by null-returning expression with rollup causes crash +# +CREATE TABLE t1(a INT); +INSERT INTO t1 VALUES(0); +SELECT 1 FROM t1 GROUP BY (DATE(NULL)) WITH ROLLUP; +DROP TABLE t1; + +--echo End of 5.0 tests diff --git a/sql/item_func.h b/sql/item_func.h index a31294c0395..a5e162f344f 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -782,7 +782,7 @@ public: max_length= args[0]->max_length; decimals=args[0]->decimals; /* The item could be a NULL constant. */ - null_value= args[0]->null_value; + null_value= args[0]->is_null(); } }; -- cgit v1.2.1