Skip to content

Commit 8540fa8

Browse files
committed
MDEV-19421 Basic 3-way join queries are not parsed.
The parser returned a syntax error message for the queries with join expressions like this t1 JOIN t2 [LEFT | RIGHT] JOIN t3 ON ... ON ... when the second operand of the outer JOIN operation with ON clause was another join expression with ON clause. In this expression the JOIN operator is right-associative, i.e. expression has to be parsed as the expression t1 JOIN (t2 [LEFT | RIGHT] JOIN t3 ON ... ) ON ... Such join expressions are hard to parse because the outer JOIN is left-associative if there is no ON clause for the first outer JOIN operator. The patch implements the solution when the JOIN operator is always parsed as right-associative and builds first the right-associative tree. If it happens that there is no corresponding ON clause for this operator the tree is converted to left-associative. The idea of the solution was taken from the patch by Martin Hansson "WL#8083: Fixed the join_table rule" from MySQL-8.0 code line. As the grammar rules related to join expressions in MySQL-8.0 and MariaDB-5.5+ are quite different MariaDB solution could not borrow any code from the MySQL-8.0 solution.
1 parent 8997f20 commit 8540fa8

File tree

8 files changed

+2078
-28
lines changed

8 files changed

+2078
-28
lines changed

mysql-test/r/join.result

Lines changed: 1384 additions & 0 deletions
Large diffs are not rendered by default.

mysql-test/r/join_outer_innodb.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ Note 1051 Unknown table 't2'
486486
Note 1051 Unknown table 't3'
487487
create table t2(a int,unique key (a)) engine=innodb;
488488
create table t3(b int) engine=innodb;
489-
create table t1(a int,b int)engine=innodb;
489+
create table t1(c int,b int)engine=innodb;
490490
set @mdev4270_opl= @@optimizer_prune_level;
491491
set @mdev4270_osd= @@optimizer_search_depth;
492492
set optimizer_prune_level=0;

0 commit comments

Comments
 (0)