summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <kaa@polly.(none)>2007-11-12 11:26:31 +0300
committerunknown <kaa@polly.(none)>2007-11-12 11:26:31 +0300
commit84fbbf4d7d937df5d0cb9081ea73e9342b0ceae6 (patch)
treecc66ec5612ca32f597bbf2824e503533c1d725ad /mysql-test
parent07219e4d44a33a8455353c1ddbd85d84884f3abd (diff)
parentf6686659551be614c835ff5f3730e87f41e06d84 (diff)
downloadmariadb-git-84fbbf4d7d937df5d0cb9081ea73e9342b0ceae6.tar.gz
Merge polly.(none):/home/kaa/src/opt/bug30666/my50-bug29131
into polly.(none):/home/kaa/src/opt/bug30666/my51-bug29131 mysql-test/r/select.result: Auto merged mysql-test/t/select.test: Auto merged sql/sql_select.cc: Auto merged
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/select.result39
-rw-r--r--mysql-test/t/select.test36
2 files changed, 75 insertions, 0 deletions
diff --git a/mysql-test/r/select.result b/mysql-test/r/select.result
index d1d85aef0ec..48aa9479a70 100644
--- a/mysql-test/r/select.result
+++ b/mysql-test/r/select.result
@@ -4081,6 +4081,45 @@ SELECT `x` FROM v3;
x
1
DROP VIEW v1, v2, v3;
+CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
+CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL,
+c22 INT DEFAULT NULL,
+KEY(c21, c22));
+CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0,
+c32 INT DEFAULT NULL,
+c33 INT NOT NULL,
+c34 INT UNSIGNED DEFAULT 0,
+KEY (c33, c34, c32));
+INSERT INTO t1 values (),(),(),(),();
+INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b;
+INSERT INTO t3 VALUES (1, 1, 1, 0),
+(2, 2, 0, 0),
+(3, 3, 1, 0),
+(4, 4, 0, 0),
+(5, 5, 1, 0);
+SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND
+t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND
+t3.c33 = 1 AND t2.c22 in (1, 3)
+ORDER BY c32;
+c32
+1
+1
+3
+3
+5
+5
+SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND
+t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND
+t3.c33 = 1 AND t2.c22 in (1, 3)
+ORDER BY c32 DESC;
+c32
+5
+5
+3
+3
+1
+1
+DROP TABLE t1, t2, t3;
End of 5.0 tests
create table t1(a INT, KEY (a));
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index 76a66cc4783..9a3eef85994 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -3473,6 +3473,42 @@ DROP VIEW v1, v2, v3;
--enable_ps_protocol
+#
+# Bug #30666: Incorrect order when using range conditions on 2 tables or more
+#
+
+CREATE TABLE t1 (c11 INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY);
+CREATE TABLE t2 (c21 INT UNSIGNED NOT NULL,
+ c22 INT DEFAULT NULL,
+ KEY(c21, c22));
+CREATE TABLE t3 (c31 INT UNSIGNED NOT NULL DEFAULT 0,
+ c32 INT DEFAULT NULL,
+ c33 INT NOT NULL,
+ c34 INT UNSIGNED DEFAULT 0,
+ KEY (c33, c34, c32));
+
+INSERT INTO t1 values (),(),(),(),();
+INSERT INTO t2 SELECT a.c11, b.c11 FROM t1 a, t1 b;
+INSERT INTO t3 VALUES (1, 1, 1, 0),
+ (2, 2, 0, 0),
+ (3, 3, 1, 0),
+ (4, 4, 0, 0),
+ (5, 5, 1, 0);
+
+# Show that ORDER BY produces the correct results order
+SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND
+ t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND
+ t3.c33 = 1 AND t2.c22 in (1, 3)
+ ORDER BY c32;
+
+# Show that ORDER BY DESC produces the correct results order
+SELECT c32 FROM t1, t2, t3 WHERE t1.c11 IN (1, 3, 5) AND
+ t3.c31 = t1.c11 AND t2.c21 = t1.c11 AND
+ t3.c33 = 1 AND t2.c22 in (1, 3)
+ ORDER BY c32 DESC;
+
+DROP TABLE t1, t2, t3;
+
--echo End of 5.0 tests
#