summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-03-19 13:33:46 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2021-03-19 13:33:46 +0200
commit93d8f887a0c4fd9b836c433c5cc482a7d64ef725 (patch)
treeda323854000bfa9bc9fceef94b164efa06e5fa88 /mysql-test
parent2944d7e69292999dbc0365cccf03efca4192967c (diff)
parent4e825b0e8ae07e1e847cbbc3c5b7203ae5b96a89 (diff)
downloadmariadb-git-93d8f887a0c4fd9b836c433c5cc482a7d64ef725.tar.gz
Merge 10.2 into 10.3
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/main/func_group.result36
-rw-r--r--mysql-test/main/func_group.test32
2 files changed, 66 insertions, 2 deletions
diff --git a/mysql-test/main/func_group.result b/mysql-test/main/func_group.result
index 62012c8067b..37d8e15e52d 100644
--- a/mysql-test/main/func_group.result
+++ b/mysql-test/main/func_group.result
@@ -2459,7 +2459,38 @@ count(*)+sleep(0)
2
drop table t1;
#
-# Start of 10.3 tests
+# MDEV-25112: MIN/MAX optimization for query containing BETWEEN in WHERE
+#
+create table t1 (a int) engine=myisam;
+insert into t1 values (267), (273), (287), (303), (308);
+select max(a) from t1 where a < 303 and (a between 267 AND 287);
+max(a)
+287
+explain select max(a) from t1 where a < 303 and (a between 267 AND 287);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
+select min(a) from t1 where a > 267 and (a between 273 AND 303);
+min(a)
+273
+explain select min(a) from t1 where a > 267 and (a between 273 AND 303);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
+create index idx on t1(a);
+select max(a) from t1 where a < 303 and (a between 267 AND 287);
+max(a)
+287
+explain select max(a) from t1 where a < 303 and (a between 267 AND 287);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+select min(a) from t1 where a > 267 and (a between 273 AND 303);
+min(a)
+273
+explain select min(a) from t1 where a > 267 and (a between 273 AND 303);
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE NULL NULL NULL NULL NULL NULL NULL Select tables optimized away
+drop table t1;
+#
+# End of 10.2 tests
#
#
# MDEV-9408 CREATE TABLE SELECT MAX(int_column) creates different columns for table vs view
@@ -2491,3 +2522,6 @@ t2 CREATE TABLE `t2` (
DROP TABLE t2;
DROP VIEW v1;
DROP TABLE t1;
+#
+# End of 10.3 tests
+#
diff --git a/mysql-test/main/func_group.test b/mysql-test/main/func_group.test
index d847f7cd5f7..fb2106ac3ae 100644
--- a/mysql-test/main/func_group.test
+++ b/mysql-test/main/func_group.test
@@ -1704,7 +1704,33 @@ select count(*)+sleep(0) from t1;
drop table t1;
--echo #
---echo # Start of 10.3 tests
+--echo # MDEV-25112: MIN/MAX optimization for query containing BETWEEN in WHERE
+--echo #
+
+create table t1 (a int) engine=myisam;
+insert into t1 values (267), (273), (287), (303), (308);
+
+let $q1=
+select max(a) from t1 where a < 303 and (a between 267 AND 287);
+let $q2=
+select min(a) from t1 where a > 267 and (a between 273 AND 303);
+
+eval $q1;
+eval explain $q1;
+eval $q2;
+eval explain $q2;
+
+create index idx on t1(a);
+
+eval $q1;
+eval explain $q1;
+eval $q2;
+eval explain $q2;
+
+drop table t1;
+
+--echo #
+--echo # End of 10.2 tests
--echo #
--echo #
@@ -1729,3 +1755,7 @@ DROP TABLE t2;
DROP VIEW v1;
DROP TABLE t1;
+
+--echo #
+--echo # End of 10.3 tests
+--echo #