Skip to content

Commit

Permalink
MDEV-19421 Basic 3-way join queries are not parsed.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
igorbabaev committed Jul 11, 2019
1 parent 8997f20 commit 8540fa8
Show file tree
Hide file tree
Showing 8 changed files with 2,078 additions and 28 deletions.
1,384 changes: 1,384 additions & 0 deletions mysql-test/r/join.result

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion mysql-test/r/join_outer_innodb.result
Expand Up @@ -486,7 +486,7 @@ Note 1051 Unknown table 't2'
Note 1051 Unknown table 't3'
create table t2(a int,unique key (a)) engine=innodb;
create table t3(b int) engine=innodb;
create table t1(a int,b int)engine=innodb;
create table t1(c int,b int)engine=innodb;
set @mdev4270_opl= @@optimizer_prune_level;
set @mdev4270_osd= @@optimizer_search_depth;
set optimizer_prune_level=0;
Expand Down

0 comments on commit 8540fa8

Please sign in to comment.