1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
Igor Babaev
2019-06-30 13:16:12 -07:00
parent 8997f20f12
commit 8540fa83bb
8 changed files with 2078 additions and 28 deletions

View File

@ -957,6 +957,8 @@ public:
TABLE_LIST *end_nested_join(THD *thd);
TABLE_LIST *nest_last_join(THD *thd);
void add_joined_table(TABLE_LIST *table);
bool add_cross_joined_table(TABLE_LIST *left_op, TABLE_LIST *right_op,
bool straight_fl);
TABLE_LIST *convert_right_join();
List<Item>* get_item_list();
ulong get_table_join_options();
@ -2745,9 +2747,9 @@ struct LEX: public Query_tables_list
return context_stack.push_front(context);
}
void pop_context()
Name_resolution_context *pop_context()
{
context_stack.pop();
return context_stack.pop();
}
bool copy_db_to(char **p_db, size_t *p_db_length) const;