Commit graph

26 commits

Author SHA1 Message Date
Igor Babaev
13221b1eb2 Fixed a failure of the test case for the bug mdev-13107 in --ps-protocol.
The fix was in the call the open_normal_and_derived_tables() from
the function mysql_test_select() and it was similar to those from
the patch for mdev-13107.

Added explicit PREPARE statements that failed in --ps-protocol.
2017-06-28 22:40:27 -07:00
Igor Babaev
e608023947 Fixed the bug mdev-13107 and some similar unreported bugs.
The problems were in the code of sql_show.cc. There the tables
could be opened in such a way that mysql_derived_init() never
worked for CTE tables. As a result they were not marked as
derived and mysql_handle_derived() were not called for derived
tables used in their specifications.
2017-06-28 11:39:33 -07:00
Marko Mäkelä
8f643e2063 Merge 10.1 into 10.2 2017-05-23 11:09:47 +03:00
Igor Babaev
a287bfa09a Fixed the bug mdev-12558.
In the current code temporary tables we identified and opened before
other tables. CTE tables are identified in the same procedure as
regular tables. When a temporary table and a CTE table have the same
name T any reference to T that is in the scope of the CTE declaration
must be associated with this CTE. Yet it was not done properly.
When a reference to T was found in the scope of the declaration
of CTE T a pointer to this CTE was set in the reference. No check
that the reference had been already associated with a temporary table
was done. As a result, if the temporary table T  had been created then
the reference to T was considered simultaneously as reference to the CTE
named T and as a reference to the temporary table named T. This
confused the code that were executed later and caused a crash of
the server.
Now when a table reference is associated with a CTE any previous
association with a temporary table is dropped.

This problem could be easily avoided if the temporary tables were
not identified prematurely.
as reference to CTE named T and
2017-04-25 19:34:39 -07:00
Igor Babaev
428a922cd0 Fixed the bug mdev-12440.
When a CTE referring to another CTE from the same with clause
was used twice then the server could not find the second CTE and
reported a bogus error message.
This happened because for any unit that was created as a clone of
a CTE specification the pointer to the WITH clause that owned this CTE
was not set.
2017-04-06 12:08:58 -07:00
Igor Babaev
2d948ebd19 Fixed bug mdev-12185.
The bug was caused by a wrong order of statements in With_clause::print().
As a result any view definition containing WITH clause with several
CTE specifications was put the frm file in a syntactically incorrect
form.
2017-03-07 21:12:59 -08:00
Igor Babaev
833aa97cec Fixed bug mdev-11818.
When a query containing a WITH clause is printed by EXPLAIN
EXTENDED command there should not be any data expansion in
the query specifications of the WITH elements of this WITH
clause.
2017-01-18 21:03:01 -08:00
Sergei Golubchik
180065ebb0 Item::print(): remove redundant parentheses
by introducing new Item::precedence() method and using it
to decide whether parentheses are required
2016-12-12 20:44:41 +01:00
Igor Babaev
061d28207d Fixed bug mdev-10923.
The code for st_select_lex::find_table_def_in_with_clauses()
did not take into account the fact that the specs for mergeable
CTEs were cloned and were not processed by the function
With_element::check_dependencies_in_spec().
2016-09-30 17:40:42 -07:00
Sergei Petrunia
95b8dcbd43 MDEV-10729: Server crashes in st_select_lex::set_explain_type
Make the new (CTE-related) code in set_explain_type to take into
account that some JOIN_TABs are non-merged semi-joins, and do not
have a TABLE object.
2016-09-07 17:14:30 +03:00
Sergei Petrunia
e305054f31 MDEV-10058: Suspicious EXPLAIN output for a derived table + WITH + joined tabl
Add a testcase
2016-09-07 12:22:41 +03:00
Sergei Petrunia
4c39f75c73 MDEV-10057: Crash with EXPLAIN + WITH + constant query
Add the testcase
2016-09-07 11:35:06 +03:00
Igor Babaev
2250e9ea26 Merge 10.2 into 10.2-mdev9864. 2016-08-30 16:14:51 -07:00
Igor Babaev
9ac235ab7d mdev-9864: cleanup, re-factoring.
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.
2016-08-29 22:45:17 -07:00
Igor Babaev
e1c92a6ca9 Fixed a problem with unreferenced CTE:
explain for the query containing WITH clause
with an unreferenced CTE caused a crash.
Added a test covered this case.

Also added a test for usage CTE in different parts of union.
2016-08-05 14:12:01 -07:00
Igor Babaev
247632e67e Fixed bug mdev-10344.
The patch for bug mdev-9937 actually did not fix the problem
of name resolution for tables used in views referred in queries
with WITH clauses. This fix corrects the patch.
2016-07-29 01:10:00 -07:00
Oleksandr Byelkin
7166069537 MDEV-3944: Allow derived tables in VIEWS 2016-05-28 14:44:21 +02:00
Galina Shalygina
6c6c3af6aa Merge branch '10.2' into 10.2-mdev9864 2016-05-25 00:34:13 +03:00
Galina Shalygina
b4f1f42062 Fixed the problem of wrong identification of WITH tables defined in WITH 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.
2016-05-24 21:29:52 +03:00
Igor Babaev
4a8d377171 Fixed bug mdev-10058.
This was a bug in the parser. As a result it could accept queries
with invalid derived tables if they used With clauses.
2016-05-16 20:19:04 -07:00
Galina Shalygina
d9b332bd20 Made prepared statement, explain and views working with recursuve CTE. 2016-05-12 23:23:12 +03:00
Galina Shalygina
d0e973a3b0 Fixed merge problems to allow mysql-test suite 'main' to pass 2016-05-10 22:32:02 +03:00
Galina Shalygina
be1d06c8a5 Merge branch '10.2' into 10.2-mdev9864 2016-05-08 23:04:41 +03:00
Igor Babaev
3b6a64c247 Fixed bug mdev-9937.
When the specification of a WITH table referred to a view
that used a based table with the same name as the WITH table
the server went into an infinite loop because it erroneously
resolved the reference to the base table as the reference to
the WITH table.

With tables used in a view cannot be searched for beyond the
scope the view.
2016-04-20 10:55:53 -07:00
Igor Babaev
f340aaeb52 Addressed the issues raised in the review for the main patch
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.
2016-02-17 14:30:25 -08:00
Galina Shalygina
dfc4772f83 MDEV-8789 Implement non-recursive common table expressions
Initial implementation
2015-12-18 10:01:42 -08:00