Browse Source
MDEV-17154 Multiple selects from parametrized CTE fails with syntax error
MDEV-17154 Multiple selects from parametrized CTE fails with syntax error
This patch fills a serious flaw in the implementation of common table expressions. Before this patch an attempt to prepare a statement from a query with a parameter marker in a CTE that was used more than once in the query ended up with a bogus error message. Similarly if a statement in a stored procedure contained a CTE whose specification used a local variables and this CTE was referred to more than once in the statement then the server failed to execute the stored procedure returning a bogus error message on a non-existing field. The problems appeared due to incorrect handling of parameter markers / local variables in CTEs that were referred more than once. This patch fixes the problems by differentiating between the original occurrences of a parameter marker / local variable used in the specification of a CTE and the corresponding occurrences used in copies of this specification. These copies are substituted instead of non-first references to the CTE. The idea of the fix and even some code were taken from the MySQL implementation of the common table expressions.pull/871/head
10 changed files with 387 additions and 20 deletions
-
129mysql-test/r/cte_nonrecursive.result
-
90mysql-test/t/cte_nonrecursive.test
-
53sql/item.cc
-
11sql/item.h
-
37sql/sql_cte.cc
-
8sql/sql_cte.h
-
1sql/sql_lex.cc
-
5sql/sql_lex.h
-
12sql/sql_prepare.cc
-
61sql/sql_yacc.yy
Write
Preview
Loading…
Cancel
Save
Reference in new issue