summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_in.test
diff options
context:
space:
mode:
authorGeorgi Kodinov <joro@sun.com>2009-05-12 16:59:17 +0300
committerGeorgi Kodinov <joro@sun.com>2009-05-12 16:59:17 +0300
commitd7a22ed9a91313c709bc9362321568cdd9842d5e (patch)
treedb826f1eae2f5199991445ee47d3c1f2fb9f2279 /mysql-test/t/func_in.test
parentab99c2347b965b42160cd3c4b2937915c4df5bde (diff)
downloadmariadb-git-d7a22ed9a91313c709bc9362321568cdd9842d5e.tar.gz
Bug #44399: crash with statement using TEXT columns, aggregates, GROUP BY,
and HAVING When calculating GROUP BY the server caches some expressions. It does that by allocating a string slot (Item_copy_string) and assigning the value of the expression to it. This effectively means that the result type of the expression can be changed from whatever it was to a string. As this substitution takes place after the compile-time result type calculation for IN but before the run-time type calculations, it causes the type calculations in the IN function done at run time to get unexpected results different from what was prepared at compile time. In the CASE ... WHEN ... THEN ... statement there was a similar problem and it was solved by artificially adding a STRING argument to the matrix at compile time, so if any of the arguments of the CASE function changes its type to a string it will still be covered by the information prepared at compile time. Extended the CASE fix for cover the IN case. An alternative way of fixing this problem is by caching the result type of the arguments at compile time and using the cached information at run time instead of re-calculating the result types. Preferred the CASE approach for uniformity and fix localization. mysql-test/r/func_in.result: Bug #44399: test case mysql-test/t/func_in.test: Bug #44399: test case sql/item_cmpfunc.cc: Bug #44399: assume at compile time there's an extra string argument in the IN function (similar to CASE) to cater for possible string conversions in the process of calculating the GROUP BY/aggregates.
Diffstat (limited to 'mysql-test/t/func_in.test')
-rw-r--r--mysql-test/t/func_in.test10
1 files changed, 10 insertions, 0 deletions
diff --git a/mysql-test/t/func_in.test b/mysql-test/t/func_in.test
index 3fc1697f146..795a92180db 100644
--- a/mysql-test/t/func_in.test
+++ b/mysql-test/t/func_in.test
@@ -439,4 +439,14 @@ SELECT CASE c1 WHEN c1 + 1 THEN 1 END, ABS(AVG(c0)) FROM t1;
DROP TABLE t1;
+#
+# Bug #44399: crash with statement using TEXT columns, aggregates, GROUP BY,
+# and HAVING
+#
+
+CREATE TABLE t1(a TEXT);
+INSERT INTO t1 VALUES('iynfj');
+SELECT SUM( DISTINCT a ) FROM t1 GROUP BY a HAVING a IN ( AVG( 1 ), 1 + a );
+DROP TABLE t1;
+
--echo End of 5.1 tests