summaryrefslogtreecommitdiff
path: root/sql/sql_cte.h
Commit message (Collapse)AuthorAgeFilesLines
* MDEV-17154 Multiple selects from parametrized CTE fails with syntax errorIgor Babaev2018-09-141-1/+7
| | | | | | | | | | | | | | | | | | | | | | | 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.
* MDEV-17024 Crash on large queryIgor Babaev2018-09-071-2/+9
| | | | | | | | | | | | | | This problem manifested itself when a join query used two or more materialized CTE such that each of them employed the same recursive CTE. The bug caused a crash. The crash happened because the cleanup() function was performed premature for recursive CTE. This clean up was induced by the cleanup of the first CTE referenced the recusrsive CTE. This cleanup destroyed the structures that would allow to read from the temporary table containing the rows of the recursive CTE and an attempt to read these rows for the second CTE referencing the recursive CTE triggered a crash. The clean up for a recursive CTE R should be performed after the cleanup of the last materialized CTE that uses R.
* Corrected the patch for mdev-15119 that caused a failure forIgor Babaev2018-02-081-1/+1
| | | | | | | cte_nonrecursive.test with --embedded. This also fixed some problems for embedded CTEs. Adjusted test results accordingly.
* Fixed the bug mdev-12563.Igor Babaev2017-04-281-1/+19
| | | | | | | | | | | | | The bug happened when the specification of a recursive CTE had no recursive references at the top level of the specification. In this case the regular processing of derived table references of the select containing a non-recursive reference to this recursive CTE misses handling the specification unit. At the preparation stage any non-recursive reference to a recursive CTE must be handled after the preparation of the specification unit for this CTE. So we have to force this preparation when regular handling of derived tables does not do it.
* Fixed the bug mdev-12519.Igor Babaev2017-04-211-0/+3
| | | | | | | | | | | | | | | | | | | | This patch fixed some problems that occurred with subqueries that contained directly or indirectly recursive references to recursive CTEs. 1. A [NOT] IN predicate with a constant left operand and a non-correlated subquery as the right operand used in the specification of a recursive CTE was considered as a constant predicate and was evaluated only once. Now such a predicate is re-evaluated after every iteration of the process that produces the records of the recursive CTE. 2. The Exists-To-IN transformation could be applied to [NOT] IN predicates with recursive references. This opened a possibility of materialization for the subqueries used as right operands. Yet, materialization is prohibited for the subqueries if they contain a recursive reference. Now the Exists-To-IN transformation cannot be applied for subquery predicates with recursive references. The function st_select_lex::check_subqueries_with_recursive_references() is called now only for the first execution of the SELECT.
* Fixed bug mdev-10883.Igor Babaev2016-09-241-0/+1
| | | | | | When a prepared statement uses a CTE definition with a column list renaming of columns of the CTE expression must be performed for every execution of the prepared statement.
* Fixed a failure with --valgrind for cte_recursive.test.Igor Babaev2016-09-191-1/+0
|
* Merge 10.2 into 10.2-mdev9864.Igor Babaev2016-08-301-1/+1
|\
| * Fixed compiler warnings and test failures found by buildbotMonty2016-06-241-1/+1
| | | | | | | | Fixed ccfilter to detect errors where the column is included in the error message
* | mdev-9864: cleanup, re-factoring.Igor Babaev2016-08-291-9/+3
| | | | | | | | | | | | | | | | Added comments. Added reaction for exceeding maximum number of elements in with clause. Added a test case to check this reaction. Added a test case where the specification of a recursive table uses two non-recursive with tables.
* | mdev-9864: cleanup, re-factoring.Igor Babaev2016-08-261-42/+72
| | | | | | | | Added comments.
* | Removed the parameter from st_select_lex_unit::exec_recursive.Igor Babaev2016-08-101-0/+16
| | | | | | | | | | | | | | | | | | Moved checking whether the limit set for the number of iterations when executing a recursive query has been reached from st_select_lex_unit::exec_recursive to TABLE_LIST::fill_recursive. Changed the name of the system variable max_recursion_level for max_recursive_iterations. Adjusted test cases.
* | Fixed the following problem:Igor Babaev2016-07-261-16/+18
| | | | | | | | | | | | | | | | Temporary tables created for recursive CTE were instantiated at the prepare phase. As a result these temporary tables missed indexes for look-ups and optimizer could not use them.
* | Simplified the code that fills recursive tables.Igor Babaev2016-06-251-79/+12
| |
* | A commit to force buildbot working.Igor Babaev2016-06-071-0/+1
| |
* | Fixed numerous problems for mutually recursive CTE.Igor Babaev2016-06-061-2/+121
| | | | | | | | | | | | | | Actually mutually recursive CTE were not functional. Now the code for mutually recursive CTE looks like functional, but still needs re-writing. Added many new test cases for mutually recursive CTE.
* | Fixed the problem of wrong identification of WITH tables defined in WITH ↵Galina Shalygina2016-05-241-17/+42
| | | | | | | | | | | | | | | | | | | | | | clauses without RECURSIVE. Added test cases to check the fix. Fixed the problem of wrong types of recursive tables when the type of anchor part does not coincide with the type of recursive part. Prevented usage of marerialization and subquery cache for subqueries with recursive references. Introduced system variables 'max_recursion_level'. Added a test case to test usage of this variable.
* | Fixed many problems in the code of With_element::check_unrestricted_recursive().Galina Shalygina2016-05-191-4/+8
| | | | | | | | | | | | | | Added the check whether there are set functions in the specifications of recursive CTE. Added the check whether there are recursive references in subqueries. Introduced boolean system variable 'standards_compliant_cte'. By default it's set to 'on'. When it's set to 'off' non-standard compliant CTE can be executed.
* | Made prepared statement, explain and views working with recursuve CTE.Galina Shalygina2016-05-121-9/+14
| |
* | Main patch for mdev-9864Galina Shalygina2016-05-091-15/+124
|/
* Addressed the issues raised in the review for the main patchbb-10.2-mdev8789Igor Babaev2016-02-171-5/+3
| | | | | | | | of mdev-8789. Fixed a bug in TABLE_LIST::print. Fixed another bug for the case when the definition of a WITH table contained column list while the join in the main query used two instances of this table.
* Fixed compile errors of the merge of the patch for mdev-8789 with 10.2.Igor Babaev2015-12-211-1/+1
|
* MDEV-8789 Implement non-recursive common table expressionsGalina Shalygina2015-12-181-0/+180
Initial implementation