summaryrefslogtreecommitdiff
path: root/mysql-test/t/join_nested.test
diff options
context:
space:
mode:
authorunknown <igor@rurik.mysql.com>2006-01-27 21:20:28 -0800
committerunknown <igor@rurik.mysql.com>2006-01-27 21:20:28 -0800
commit6bfbba34c7ebee4ee21547afd648d6da1ed7966f (patch)
treed8a03661d0344875d2ebcc3232738ac0f404bd4c /mysql-test/t/join_nested.test
parentae951e0f72bb3474eaaa282342f17b645d64ac87 (diff)
downloadmariadb-git-6bfbba34c7ebee4ee21547afd648d6da1ed7966f.tar.gz
Fixed bug #16260.
The problem has manifested itself in the cases when we have a nested outer join for which it can be inferred that one of the inner tables is a single row table. mysql-test/r/join_nested.result: Added a test case for bug #16260. mysql-test/t/join_nested.test: Added a test case for bug #16260. sql/sql_select.cc: Fixed bug #16260. The problem has manifested itself in the cases when we have a nested outer join for which it can be inferred that one of the inner tables is a single row table. A table is never considered as a const table if it is used in a nested join that serves as an inner operand of an outer join.
Diffstat (limited to 'mysql-test/t/join_nested.test')
-rw-r--r--mysql-test/t/join_nested.test28
1 files changed, 28 insertions, 0 deletions
diff --git a/mysql-test/t/join_nested.test b/mysql-test/t/join_nested.test
index 145edded486..8adcf05be93 100644
--- a/mysql-test/t/join_nested.test
+++ b/mysql-test/t/join_nested.test
@@ -914,3 +914,31 @@ explain select * from t1 left join
on (t1.a = t2.a);
drop table t1, t2, t3;
+#
+# Bug #16260: single row table in the inner nest of an outer join
+#
+
+CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, type varchar(10));
+CREATE TABLE t2 (pid int NOT NULL PRIMARY KEY, type varchar(10));
+CREATE TABLE t3 (cid int NOT NULL PRIMARY KEY,
+ id int NOT NULL,
+ pid int NOT NULL);
+
+INSERT INTO t1 VALUES (1, 'A'), (3, 'C');
+INSERT INTO t2 VALUES (1, 'A'), (3, 'C');
+INSERT INTO t3 VALUES (1, 1, 1), (3, 3, 3);
+
+SELECT * FROM t1 p LEFT JOIN (t3 JOIN t1)
+ ON (t1.id=t3.id AND t1.type='B' AND p.id=t3.id)
+ LEFT JOIN t2 ON (t3.pid=t2.pid)
+ WHERE p.id=1;
+
+CREATE VIEW v1 AS
+ SELECT t3.* FROM t3 JOIN t1 ON t1.id=t3.id AND t1.type='B';
+
+SELECT * FROM t1 p LEFT JOIN v1 ON p.id=v1.id
+ LEFT JOIN t2 ON v1.pid=t2.pid
+ WHERE p.id=1;
+
+DROP VIEW v1;
+DROP TABLE t1,t2,t3;