Skip to content
Permalink
Browse files

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.
  • Loading branch information...
igorbabaev committed Jun 30, 2019
1 parent 8997f20 commit 8540fa83bb34df6a3d489a4e85c77692f36e3e26
Showing with 2,078 additions and 28 deletions.
  1. +1,384 −0 mysql-test/r/join.result
  2. +1 −1 mysql-test/r/join_outer_innodb.result
  3. +404 −0 mysql-test/t/join.test
  4. +1 −1 mysql-test/t/join_outer_innodb.test
  5. +4 −2 sql/sql_lex.h
  6. +235 −0 sql/sql_parse.cc
  7. +25 −24 sql/sql_yacc.yy
  8. +24 −0 sql/table.h

Large diffs are not rendered by default.

@@ -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;

0 comments on commit 8540fa8

Please sign in to comment.
You can’t perform that action at this time.