summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_group.test
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2006-06-02 14:14:57 -0700
committerunknown <igor@rurik.mysql.com>2006-06-02 14:14:57 -0700
commite3e0658779bffacd5323efb54ecb7f42ded19231 (patch)
tree73c42f8475188528c843bc2d2a7f64fa2f122d1e /mysql-test/t/func_group.test
parenta9824f263dcaedaabfbbc9e398eb55117f19a41f (diff)
downloadmariadb-git-e3e0658779bffacd5323efb54ecb7f42ded19231.tar.gz
Fixed bug #18206.
The bug report revealed two problems related to min/max optimization: 1. If the length of a constant key used in a SARGable condition for for the MIN/MAX fields is greater than the length of the field an unwanted warning on key truncation is issued; 2. If MIN/MAX optimization is applied to a partial index, like INDEX(b(4)) than can lead to returning a wrong result set. mysql-test/r/func_group.result: Added test cases for bug #18206. mysql-test/t/func_group.test: Added test cases for bug #18206. sql/opt_sum.cc: Fixed bug #18206. Suppressed the warning about data truncation when store_val_in_field was used to store keys for the field used in MIN/MAX optimization. Blocked MIN/MAX optimization for partial keys, such as in INDEX(b(4)). sql/sql_select.cc: Fixed bug #18206. Added a parameter for the function store_val_in_field allowing to control setting warnings about data truncation in the function. sql/sql_select.h: Fixed bug #18206. Added a parameter for the function store_val_in_field allowing to control setting warnings about data truncation in the function.
Diffstat (limited to 'mysql-test/t/func_group.test')
-rw-r--r--mysql-test/t/func_group.test19
1 files changed, 19 insertions, 0 deletions
diff --git a/mysql-test/t/func_group.test b/mysql-test/t/func_group.test
index dc647dbcfeb..f8a3ed0f25e 100644
--- a/mysql-test/t/func_group.test
+++ b/mysql-test/t/func_group.test
@@ -598,4 +598,23 @@ select count(*), min(7), max(7) from t2m, t1i;
drop table t1m, t1i, t2m, t2i;
+#
+# Bug #18206: min/max optimization cannot be applied to partial index
+#
+
+CREATE TABLE t1 (id int PRIMARY KEY, b char(3), INDEX(b));
+INSERT INTO t1 VALUES (1,'xx'), (2,'aa');
+SELECT * FROM t1;
+
+SELECT MAX(b) FROM t1 WHERE b < 'ppppp';
+SHOW WARNINGS;
+SELECT MAX(b) FROM t1 WHERE b < 'pp';
+DROP TABLE t1;
+
+CREATE TABLE t1 (id int PRIMARY KEY, b char(16), INDEX(b(4)));
+INSERT INTO t1 VALUES (1, 'xxxxbbbb'), (2, 'xxxxaaaa');
+SELECT MAX(b) FROM t1;
+EXPLAIN SELECT MAX(b) FROM t1;
+DROP TABLE t1;
+
# End of 4.1 tests