summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
authorunknown <hf@deer.(none)>2003-12-12 21:26:20 +0400
committerunknown <hf@deer.(none)>2003-12-12 21:26:20 +0400
commit4f90f2fc6734aa920d2c6a2252c7b7c8d29ebd67 (patch)
treeba27c057d64a301e15acd992f4117e0d62eb5108 /mysql-test
parent429675f446d125c4a25575a6f806e4d8d9e27423 (diff)
downloadmariadb-git-4f90f2fc6734aa920d2c6a2252c7b7c8d29ebd67.tar.gz
Proposed fix for #2093
it happens because of the LEFT JOINT optimization in add_key_part() This optimization does exactly the same in JOIN and in WHERE conditions Not right. I moved that optimization one level upper. mysql-test/r/join_outer.result: appropriate test result mysql-test/t/join_outer.test: test case sql/sql_select.cc: optimizing of the left_join now only for WHERE conditions and for first table in list
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/join_outer.result17
-rw-r--r--mysql-test/t/join_outer.test13
2 files changed, 30 insertions, 0 deletions
diff --git a/mysql-test/r/join_outer.result b/mysql-test/r/join_outer.result
index debec01fbdc..ae4d99e6241 100644
--- a/mysql-test/r/join_outer.result
+++ b/mysql-test/r/join_outer.result
@@ -667,3 +667,20 @@ left outer join t2 using (f2)
left outer join t3 using (f3);
Unknown column 'test.t2.f3' in 'on clause'
drop table t1,t2,t3;
+create table t1 (a1 int, a2 int);
+create table t2 (b1 int not null, b2 int);
+create table t3 (c1 int, c2 int);
+insert into t1 values (1,2), (2,2), (3,2);
+insert into t2 values (1,3), (2,3);
+insert into t3 values (2,4), (3,4);
+select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null;
+a1 a2 b1 b2 c1 c2
+1 2 1 3 NULL NULL
+2 2 2 3 NULL NULL
+3 2 NULL NULL 3 4
+explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null;
+table type possible_keys key key_len ref rows Extra
+t1 ALL NULL NULL NULL NULL 3
+t2 ALL NULL NULL NULL NULL 2
+t3 ALL NULL NULL NULL NULL 2
+drop table t1, t2, t3;
diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test
index ee7d55d2a4e..bed4d4b033b 100644
--- a/mysql-test/t/join_outer.test
+++ b/mysql-test/t/join_outer.test
@@ -437,3 +437,16 @@ select * from t1
left outer join t2 using (f2)
left outer join t3 using (f3);
drop table t1,t2,t3;
+
+create table t1 (a1 int, a2 int);
+create table t2 (b1 int not null, b2 int);
+create table t3 (c1 int, c2 int);
+
+insert into t1 values (1,2), (2,2), (3,2);
+insert into t2 values (1,3), (2,3);
+insert into t3 values (2,4), (3,4);
+
+select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null;
+explain select * from t1 left join t2 on b1 = a1 left join t3 on c1 = a1 and b1 is null;
+
+drop table t1, t2, t3;