summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2007-10-01 20:03:50 +0000
committerunknown <evgen@moonbone.local>2007-10-01 20:03:50 +0000
commit11a54ec9d0979ab8601ddb8d99c0defe7761fa26 (patch)
tree3c4a4aa0e3f4fa2b03ba29f3884b7b21184c62ac
parent0cf6a9f842205883da7e1e5b8f448db337f5cb85 (diff)
downloadmariadb-git-11a54ec9d0979ab8601ddb8d99c0defe7761fa26.tar.gz
Bug#31095: Unexpected NULL constant caused server crash.
The Item_func_rollup_const class is used for wrapping constants to avoid wrong result for ROLLUP queries with DISTINCT and a constant in the select list. This class is also used to wrap up a NULL constant but its null_value wasn't set accordingly. This led to a server crash. Now the null_value of an object of the Item_func_rollup_const class is set by its fix_length_and_dec member function. mysql-test/t/olap.test: Added a test case for the bug#31095: Unexpected NULL constant caused server crash. mysql-test/r/olap.result: Added a test case for the bug#31095: Unexpected NULL constant caused server crash. sql/item_func.h: Bug#31095: Unexpected NULL constant caused server crash. Now the null_value of an object of the Item_func_rollup_const class is set by its fix_length_and_dec member function.
-rw-r--r--mysql-test/r/olap.result11
-rw-r--r--mysql-test/t/olap.test9
-rw-r--r--sql/item_func.h2
3 files changed, 22 insertions, 0 deletions
diff --git a/mysql-test/r/olap.result b/mysql-test/r/olap.result
index 4a54b17316d..a1d66b11f58 100644
--- a/mysql-test/r/olap.result
+++ b/mysql-test/r/olap.result
@@ -715,3 +715,14 @@ a SUM(a)
4 4
NULL 14
DROP TABLE t1;
+#
+# Bug#31095: Unexpected NULL constant caused server crash.
+#
+create table t1(a int);
+insert into t1 values (1),(2),(3);
+select count(a) from t1 group by null with rollup;
+count(a)
+3
+3
+drop table t1;
+##############################################################
diff --git a/mysql-test/t/olap.test b/mysql-test/t/olap.test
index 05934bff492..1ac99d9c39f 100644
--- a/mysql-test/t/olap.test
+++ b/mysql-test/t/olap.test
@@ -358,3 +358,12 @@ SELECT * FROM (SELECT a, SUM(a) FROM t1 GROUP BY a WITH ROLLUP) as t;
DROP TABLE t1;
+--echo #
+--echo # Bug#31095: Unexpected NULL constant caused server crash.
+--echo #
+create table t1(a int);
+insert into t1 values (1),(2),(3);
+select count(a) from t1 group by null with rollup;
+drop table t1;
+--echo ##############################################################
+
diff --git a/sql/item_func.h b/sql/item_func.h
index 57e33daf0c4..87c9e016df2 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -749,6 +749,8 @@ public:
collation= args[0]->collation;
max_length= args[0]->max_length;
decimals=args[0]->decimals;
+ /* The item could be a NULL constant. */
+ null_value= args[0]->null_value;
}
};