mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
SCRUM Task 430: Allowing braces in joins by simply removing them.
Fixed the remaining join variations, (left, right, natural, etc). (Previous fix only solved "," and "[cross] join".) mysql-test/r/select.result: Added more test case results for more braced join fixes. mysql-test/t/select.test: Added more tests for braced join fixes. sql/sql_yacc.yy: Changed the remaining join_table_list cases to handle braces. Also added some precedence declaration to silence shift/reduce conflicts warnings that turned up after these fixes.
This commit is contained in:
@ -3292,4 +3292,179 @@ a a a
|
||||
1 3 3
|
||||
2 3 3
|
||||
3 3 3
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1;
|
||||
a a a
|
||||
1 1 1
|
||||
2 2 1
|
||||
3 3 1
|
||||
1 1 2
|
||||
2 2 2
|
||||
3 3 2
|
||||
1 1 3
|
||||
2 2 3
|
||||
3 3 3
|
||||
select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a));
|
||||
a a a
|
||||
1 1 1
|
||||
2 1 1
|
||||
3 1 1
|
||||
1 2 2
|
||||
2 2 2
|
||||
3 2 2
|
||||
1 3 3
|
||||
2 3 3
|
||||
3 3 3
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1;
|
||||
a a a
|
||||
1 1 2
|
||||
2 2 2
|
||||
3 3 2
|
||||
1 1 3
|
||||
2 2 3
|
||||
3 3 3
|
||||
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
|
||||
a a a
|
||||
1 1 NULL
|
||||
2 1 1
|
||||
3 1 1
|
||||
1 2 NULL
|
||||
2 2 2
|
||||
3 2 2
|
||||
1 3 NULL
|
||||
2 3 3
|
||||
3 3 3
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a );
|
||||
a a a
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a );
|
||||
a a a
|
||||
1 1 1
|
||||
2 1 NULL
|
||||
3 1 NULL
|
||||
1 2 NULL
|
||||
2 2 2
|
||||
3 2 NULL
|
||||
1 3 NULL
|
||||
2 3 NULL
|
||||
3 3 3
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1;
|
||||
a a a
|
||||
1 1 2
|
||||
1 1 3
|
||||
2 2 2
|
||||
2 2 3
|
||||
3 3 2
|
||||
3 3 3
|
||||
select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
|
||||
a a a
|
||||
1 1 NULL
|
||||
2 1 1
|
||||
3 1 1
|
||||
1 2 NULL
|
||||
2 2 2
|
||||
3 2 2
|
||||
1 3 NULL
|
||||
2 3 3
|
||||
3 3 3
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a );
|
||||
a a a
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a );
|
||||
a a a
|
||||
1 1 1
|
||||
2 1 NULL
|
||||
3 1 NULL
|
||||
1 2 NULL
|
||||
2 2 2
|
||||
3 2 NULL
|
||||
1 3 NULL
|
||||
2 3 NULL
|
||||
3 3 3
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
|
||||
a a a
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a));
|
||||
a a a
|
||||
1 1 1
|
||||
2 1 NULL
|
||||
3 1 NULL
|
||||
1 2 NULL
|
||||
2 2 2
|
||||
3 2 NULL
|
||||
1 3 NULL
|
||||
2 3 NULL
|
||||
3 3 3
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
|
||||
a a a
|
||||
1 NULL 1
|
||||
2 NULL 1
|
||||
3 NULL 1
|
||||
1 1 2
|
||||
2 2 2
|
||||
3 3 2
|
||||
1 1 3
|
||||
2 2 3
|
||||
3 3 3
|
||||
select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
|
||||
a a a
|
||||
2 1 1
|
||||
3 1 1
|
||||
2 2 2
|
||||
3 2 2
|
||||
2 3 3
|
||||
3 3 3
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a );
|
||||
a a a
|
||||
1 1 1
|
||||
2 NULL 1
|
||||
3 NULL 1
|
||||
1 NULL 2
|
||||
2 2 2
|
||||
3 NULL 2
|
||||
1 NULL 3
|
||||
2 NULL 3
|
||||
3 3 3
|
||||
select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a );
|
||||
a a a
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1;
|
||||
a a a
|
||||
1 1 1
|
||||
2 NULL 1
|
||||
3 NULL 1
|
||||
1 NULL 2
|
||||
2 2 2
|
||||
3 NULL 2
|
||||
1 NULL 3
|
||||
2 NULL 3
|
||||
3 3 3
|
||||
select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a));
|
||||
a a a
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
select * from t1 natural join (t1 as t2 left join t1 as t3 using (a));
|
||||
a a a
|
||||
1 1 1
|
||||
2 1 NULL
|
||||
3 1 NULL
|
||||
1 2 NULL
|
||||
2 2 2
|
||||
3 2 NULL
|
||||
1 3 NULL
|
||||
2 3 NULL
|
||||
3 3 3
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;
|
||||
a a a
|
||||
1 1 1
|
||||
2 2 2
|
||||
3 3 3
|
||||
drop table t1;
|
||||
|
@ -1754,13 +1754,46 @@ drop table t1;
|
||||
|
||||
#
|
||||
# Test of removing redundant braces in the FROM part
|
||||
# (The second case used to cause a syntax error)
|
||||
# (We test each construct with the braced join to the left and right;
|
||||
# the latter case used to cause a syntax errors.)
|
||||
#
|
||||
|
||||
create table t1 (a int not null auto_increment primary key);
|
||||
insert into t1 values ();
|
||||
insert into t1 values ();
|
||||
insert into t1 values ();
|
||||
# ,
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)), t1;
|
||||
select * from t1, (t1 as t2 left join t1 as t3 using (a));
|
||||
# stright_join
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) straight_join t1;
|
||||
select * from t1 straight_join (t1 as t2 left join t1 as t3 using (a));
|
||||
# inner join on
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 on t1.a>1;
|
||||
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
|
||||
# inner join using
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) inner join t1 using ( a );
|
||||
select * from t1 inner join (t1 as t2 left join t1 as t3 using (a)) using ( a );
|
||||
# left [outer] join on
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) left outer join t1 on t1.a>1;
|
||||
select * from t1 left outer join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
|
||||
# left join using
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) left join t1 using ( a );
|
||||
select * from t1 left join (t1 as t2 left join t1 as t3 using (a)) using ( a );
|
||||
# natural left join
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) natural left join t1;
|
||||
select * from t1 natural left join (t1 as t2 left join t1 as t3 using (a));
|
||||
# right join on
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) right join t1 on t1.a>1;
|
||||
select * from t1 right join (t1 as t2 left join t1 as t3 using (a)) on t1.a>1;
|
||||
# right [outer] joing using
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) right outer join t1 using ( a );
|
||||
select * from t1 right outer join (t1 as t2 left join t1 as t3 using (a)) using ( a );
|
||||
# natural right join
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) natural right join t1;
|
||||
select * from t1 natural right join (t1 as t2 left join t1 as t3 using (a));
|
||||
# natural join
|
||||
select * from t1 natural join (t1 as t2 left join t1 as t3 using (a));
|
||||
select * from (t1 as t2 left join t1 as t3 using (a)) natural join t1;
|
||||
|
||||
drop table t1;
|
||||
|
Reference in New Issue
Block a user