summaryrefslogtreecommitdiff
path: root/mysql-test/t/select.test
diff options
context:
space:
mode:
authorunknown <timour@mysql.com>2005-09-10 15:01:54 +0300
committerunknown <timour@mysql.com>2005-09-10 15:01:54 +0300
commit0dec682f39d3e97d72b7d0620db218ba715dd13a (patch)
tree98a7941fe47548d74572b03910ae1e72b37964be /mysql-test/t/select.test
parent9ed942fe2c543ecbe3b23e9cca332b82c4fda745 (diff)
downloadmariadb-git-0dec682f39d3e97d72b7d0620db218ba715dd13a.tar.gz
Fix for BUG#12943.
The problem was that in the first production in rule 'join_table', that processes simple cross joins, the parser was processing the second join operand before the first one due to unspecified priorities of JOINs. As a result in the case of cross joins the parser constructed a tree with incorrect nesting: the expression "t1 join t2 join t3 on some_cond" was interpreted as "t1 join (t2 join t3 on some_cond)" instead of "(t1 join t2) join t3 on some_cond". Because of this incorrect nesting the method make_join_on_context picked an incorrect table as the first table of the name resolution context. The solution assignes correct priorities to the related production. mysql-test/r/select.result: Added test for BUG#12943. mysql-test/t/select.test: Added test for BUG#12943. sql/sql_parse.cc: Fixed typo. sql/sql_yacc.yy: Provide explicit priorities of the JOIN operator and the 'table_ref' rule, to enforce left-associativity of [INNER | CROSS] JOIN.
Diffstat (limited to 'mysql-test/t/select.test')
-rw-r--r--mysql-test/t/select.test23
1 files changed, 23 insertions, 0 deletions
diff --git a/mysql-test/t/select.test b/mysql-test/t/select.test
index fad01ac9acf..37fbd7a296e 100644
--- a/mysql-test/t/select.test
+++ b/mysql-test/t/select.test
@@ -2465,3 +2465,26 @@ insert into t2 values ('b'),('c'),('d');
select a from t1 natural join t2;
select * from t1 natural join t2 where a = 'b';
drop table t1, t2;
+
+#
+# Bug #12943 Incorrect nesting of [INNER| CROSS] JOIN due to unspecified
+# associativity in the parser.
+#
+
+create table t1 (a int, c int);
+create table t2 (b int);
+create table t3 (b int, a int);
+create table t4 (c int);
+insert into t1 values (1,1);
+insert into t2 values (1);
+insert into t3 values (1,1);
+insert into t4 values (1);
+
+select * from t1 join t2 join t3 on (t2.b = t3.b and t1.a = t3.a);
+# Notice that ',' has lower priority than 'join', thus we have that:
+# t1, t2 join t3 <==> t1, (t2 join t3).
+-- error 1054
+select * from t1, t2 join t3 on (t2.b = t3.b and t1.a = t3.a);
+select * from t1 join t2 join t3 join t4 on (t1.a = t4.c and t2.b = t4.c);
+select * from t1 join t2 join t4 using (c);
+drop table t1, t2, t3, t4;