summaryrefslogtreecommitdiff
path: root/mysql-test/r/join.result
diff options
context:
space:
mode:
authorunknown <timour@mysql.com>2006-03-02 11:50:15 +0200
committerunknown <timour@mysql.com>2006-03-02 11:50:15 +0200
commitde1e87bbcd5ca4f830e7af42da34ef0d3228b28e (patch)
treecba6c500f38ff8c287a7cd3c153110cfa476108e /mysql-test/r/join.result
parentf095abaa4748c5ad2c302b8697c819d3fbd5de2a (diff)
downloadmariadb-git-de1e87bbcd5ca4f830e7af42da34ef0d3228b28e.tar.gz
Fix for BUG#15229.
The cause of this bug was a design flaw due to which the list of natural join columns was incorrectly computed and stored for nested joins that are not natural joins, but are operands (possibly indirect) of nested joins. The patch corrects the flaw in a such a way, that the result columns of a table reference are materialized only if it is a leaf table (that is, only if it is a view, stored table, or natural/using join). mysql-test/r/join.result: Added test for BUG#15229 and uncommented failing test cases of BUG#15357 (now fixed by this patch). mysql-test/t/join.test: Added test for BUG#15229 and uncommented failing test cases of BUG#15357 (now fixed by this patch). sql/sql_base.cc: - Do not materialize the result columns of regular nested joins (that are not natural/using joins). - Moved most of the code that creates/adds new natural join column references to the method 'get_or_create_column_ref', and simplified 'mark_common_columns'. - Replaced a call to 'get_or_create_column_ref' with 'get_natural_column_ref' where it is for sure all columns are alredy created. sql/table.cc: - Modified the method 'get_or_create_column_ref' so that it adds itself the newly created natural join columns to the respective table reference. sql/table.h: - Modified the method 'get_or_create_column_ref' so that it adds itself the newly created natural join columns to the respective table reference.
Diffstat (limited to 'mysql-test/r/join.result')
-rw-r--r--mysql-test/r/join.result47
1 files changed, 47 insertions, 0 deletions
diff --git a/mysql-test/r/join.result b/mysql-test/r/join.result
index 724d1b1e39f..bd86942072c 100644
--- a/mysql-test/r/join.result
+++ b/mysql-test/r/join.result
@@ -475,6 +475,22 @@ b c a c b y
1 10 2 3 1 2
1 3 2 3 1 11
1 3 2 3 1 2
+select * from t5 natural join ((t1 natural join t2), (t3 natural join t4));
+y z b c a c b
+11 4 1 10 2 3 1
+11 4 1 3 2 3 1
+select * from ((t1 natural join t2), (t3 natural join t4)) natural join t5;
+y b c a c b z
+11 1 10 2 3 1 4
+11 1 3 2 3 1 4
+select * from t5 natural join ((t1 natural join t2) cross join (t3 natural join t4));
+y z b c a c b
+11 4 1 10 2 3 1
+11 4 1 3 2 3 1
+select * from ((t1 natural join t2) cross join (t3 natural join t4)) natural join t5;
+y b c a c b z
+11 1 10 2 3 1 4
+11 1 3 2 3 1 4
select * from (t1 join t2 using (b)) join (t3 join t4 using (c)) using (c);
c b a b y
3 1 2 1 11
@@ -665,6 +681,8 @@ select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6;
ERROR 23000: Column 'c' in from clause is ambiguous
select * from ((t1 natural join t2), (t3 natural join t4)) natural join t6;
ERROR 23000: Column 'c' in from clause is ambiguous
+select * from t6 natural join ((t1 natural join t2), (t3 natural join t4));
+ERROR 23000: Column 'c' in from clause is ambiguous
select * from (t1 join t2 on t1.b=t2.b) natural join (t3 natural join t4);
ERROR 23000: Column 'b' in from clause is ambiguous
select * from (t3 natural join t4) natural join (t1 join t2 on t1.b=t2.b);
@@ -673,6 +691,8 @@ select * from (t3 join (t4 natural join t5) on (b < z))
natural join
(t1 natural join t2);
ERROR 23000: Column 'c' in from clause is ambiguous
+select * from (t1 natural join t2) natural join (t3 join (t4 natural join t5) on (b < z));
+ERROR 23000: Column 'c' in from clause is ambiguous
select t1.b from v1a;
ERROR 42S22: Unknown column 't1.b' in 'field list'
select * from v1a join v1b on t1.b = t2.b;
@@ -692,3 +712,30 @@ drop view v2b;
drop view v3a;
drop view v3b;
drop view v4;
+create table t1 (a1 int, a2 int);
+create table t2 (a1 int, b int);
+create table t3 (c1 int, c2 int);
+create table t4 (c2 int);
+insert into t1 values (1,1);
+insert into t2 values (1,1);
+insert into t3 values (1,1);
+insert into t4 values (1);
+select * from t1 join t2 using (a1) join t3 on b=c1 join t4 using (c2);
+c2 a1 a2 b c1
+1 1 1 1 1
+select * from t3 join (t1 join t2 using (a1)) on b=c1 join t4 using (c2);
+c2 c1 a1 a2 b
+1 1 1 1 1
+select a2 from t1 join t2 using (a1) join t3 on b=c1 join t4 using (c2);
+a2
+1
+select a2 from t3 join (t1 join t2 using (a1)) on b=c1 join t4 using (c2);
+a2
+1
+select a2 from ((t1 join t2 using (a1)) join t3 on b=c1) join t4 using (c2);
+a2
+1
+select a2 from ((t1 natural join t2) join t3 on b=c1) natural join t4;
+a2
+1
+drop table t1,t2,t3,t4;