summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2014-07-22 15:52:49 +0400
committerSergey Petrunya <psergey@askmonty.org>2014-07-22 15:52:49 +0400
commit07c0b1d8d075ee5c95ceca98c88d914fff10a8ee (patch)
treeedd372ae61d122a6dbd9272ea176356846fe1b5d /mysql-test
parent71a596b90cc673f9c750d61fd70a4dc5d39d3244 (diff)
downloadmariadb-git-07c0b1d8d075ee5c95ceca98c88d914fff10a8ee.tar.gz
MDEV-6434: Wrong result (extra rows) with ORDER BY, multiple-column index, InnoDB
- Filesort has an optmization where it reads only columns that are needed before the sorting is done. - When ref(_or_null) is picked by the join optimizer, it may remove parts of WHERE clause that are guaranteed to be true. - However, if we use quick select, we must put all of the range columns into the read set. Not doing so will may cause us to fail to detect the end of the range.
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/order_by_innodb.result13
-rw-r--r--mysql-test/t/order_by_innodb.test23
2 files changed, 36 insertions, 0 deletions
diff --git a/mysql-test/r/order_by_innodb.result b/mysql-test/r/order_by_innodb.result
new file mode 100644
index 00000000000..3c6c4053741
--- /dev/null
+++ b/mysql-test/r/order_by_innodb.result
@@ -0,0 +1,13 @@
+drop table if exists t0,t1,t2,t3;
+#
+# MDEV-6434: Wrong result (extra rows) with ORDER BY, multiple-column index, InnoDB
+#
+CREATE TABLE t1 (a INT, b INT, c INT, d TEXT, KEY idx(a,b,c)) ENGINE=InnoDB;
+INSERT INTO t1 (a,c) VALUES
+(8, 9),(8, 10),(13, 15),(16, 17),(16, 18),(16, 19),(20, 21),
+(20, 22),(20, 24),(20, 25),(20, 26),(20, 27),(20, 28);
+SELECT * FROM t1 WHERE a = 8 AND (b = 1 OR b IS NULL) ORDER BY c;
+a b c d
+8 NULL 9 NULL
+8 NULL 10 NULL
+DROP TABLE t1;
diff --git a/mysql-test/t/order_by_innodb.test b/mysql-test/t/order_by_innodb.test
new file mode 100644
index 00000000000..c20eaceb053
--- /dev/null
+++ b/mysql-test/t/order_by_innodb.test
@@ -0,0 +1,23 @@
+#
+# ORDER BY handling (e.g. filesort) tests that require innodb
+#
+-- source include/have_innodb.inc
+
+--disable_warnings
+drop table if exists t0,t1,t2,t3;
+--enable_warnings
+
+--echo #
+--echo # MDEV-6434: Wrong result (extra rows) with ORDER BY, multiple-column index, InnoDB
+--echo #
+
+CREATE TABLE t1 (a INT, b INT, c INT, d TEXT, KEY idx(a,b,c)) ENGINE=InnoDB;
+
+INSERT INTO t1 (a,c) VALUES
+(8, 9),(8, 10),(13, 15),(16, 17),(16, 18),(16, 19),(20, 21),
+(20, 22),(20, 24),(20, 25),(20, 26),(20, 27),(20, 28);
+
+SELECT * FROM t1 WHERE a = 8 AND (b = 1 OR b IS NULL) ORDER BY c;
+
+DROP TABLE t1;
+