Commit graph

174189 commits

Author SHA1 Message Date
Igor Babaev
cb1e44219b Adjusted test results. 2016-08-30 11:13:25 -07:00
Igor Babaev
501fc1a9e2 Returned the test case that was removed by mistake. 2016-08-29 22:58:01 -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
c8f85bf263 mdev-9864: cleanup, re-factoring.
Added comments.
2016-08-26 16:09:22 -07:00
Igor Babaev
f33c35240d Adjusted test result. 2016-08-11 14:39:26 -07:00
Igor Babaev
2f9555c40f Removed the parameter from st_select_lex_unit::exec_recursive.
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.
2016-08-10 15:51:40 -07:00
Sergei Petrunia
e20e28bd2e Fix for the previous cset: make first_explain_order_tab handle degenerate joins 2016-08-10 01:13:09 +03:00
Sergei Petrunia
a2f245e49f MDEV-10372: EXPLAIN fixes for recursive CTEs, including FORMAT=JSON
- Tabular EXPLAIN now prints "RECURSIVE UNION".
- There is a basic implementation of EXPLAIN FORMAT=JSON.
- it produces "recursive_union" JSON struct
- No other details or ANALYZE support, yet.
2016-08-08 23:02:52 +03: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
Igor Babaev
f982d1074a Fixed the following problem:
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.
2016-07-26 22:58:33 -07:00
Igor Babaev
8c6a9aa30f Added a proper check for acceptable mutually recursive CTE. 2016-06-30 15:13:12 -07:00
Igor Babaev
22c37c1fcf Adjusted test results. 2016-06-29 15:20:24 -07:00
Igor Babaev
9606525666 Simplified the code that fills recursive tables. 2016-06-25 21:38:40 -07:00
Igor Babaev
0eec187153 A commit to force buildbot working. 2016-06-07 15:01:34 -07:00
Igor Babaev
096286c95f The method With_element::reset_for_exec was not called in non-debug
builds.
2016-06-07 11:06:54 -07:00
Igor Babaev
0a6e6d705b Fixed numerous problems for mutually recursive CTE.
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.
2016-06-06 10:01:16 -07:00
Galina Shalygina
6c6c3af6aa Merge branch '10.2' into 10.2-mdev9864 2016-05-25 00:34:13 +03:00
Galina Shalygina
c7c2f8d4a0 Merge branch '10.2' of github.com:MariaDB/server into 10.2 2016-05-25 00:29: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
Alexander Barkov
804b00e878 An sql_yacc.yy clean-up
- Moving opt_union_order_or_limit inside union_opt,
  as it's not used in other places any more.
- Changing union_opt to have no type.
  Earlier (before all MDEV-8909 dependency tasks) it had the <num> type,
  and it's return value was used to generate errors.
  Now union_opt does not need a return value because the grammar
  disallows ORDER and LIMIT clauses in wrong context.
2016-05-24 18:23:18 +04:00
Alexander Barkov
c80c3f6759 MDEV-10109 Disallow syntactically INSERT .. SELECT .. {ORDER BY ..| LIMIT ..} .. UNION .. 2016-05-24 18:05:38 +04:00
Alexander Barkov
ea9a393a86 MDEV-10103 Disallow syntactically UNION SELECT .. PROCEDURE ANALYSE() 2016-05-24 14:18:46 +04:00
Alexander Barkov
9a25c01f78 MDEV-10102 Disallow CREATE VIEW .. PROCEDURE ANALYSE() syntactically 2016-05-23 16:25:51 +04:00
Alexander Barkov
4c0e2960d4 MDEV-10051 Fix subselect to return a syntax error instead of "Incorrect usage of UNION and LIMIT" 2016-05-23 10:54:09 +04:00
Alexander Barkov
a999acf26e MDEV-10095 Fix derived tables to return a syntax error instead of "Illegal usage of UNION and LIMIT" 2016-05-21 16:52:12 +04:00
Alexander Barkov
349da1d643 sql_yacc.yy: Removing unnecessary init_nested_join() and end_nested_join()
from select_derived_init.
2016-05-21 00:27:57 +04:00
Alexander Barkov
c44b2e66a9 A derived_query_specification clean-up
(to simplify further MDEV-8909 changes)

1. Better semantic readability:
- Moving get_select_lex_derived inside select_derived_init
  and decomposing it into get_select_lex and
  $1->init_nested_join(lex->thd)
-  Moving DBUG_ASSERT($1 == Lex->current_select) inside
   select_derived_init

Now init_nested_join() and end_nested_join() reside inside
the same rule select_derived_init.
(It's very likely that they can be further removed,
 as there are no any joins in this rule).

3. Better grammar readability:
  Moving SELECT_SYM from select_derived_init to derived_query_specification.
  It's easier to read a rule when it starts from a terminal symbol.
2016-05-20 20:05:03 +04:00
Oleksandr Byelkin
485ece6da9 MDEV-8429: Change binlog_checksum default to match MySQL 5.6.6+ 2016-05-20 09:46:03 +02:00
Alexander Barkov
f6a7c1c75a MDEV-10080 Derived tables allow double LIMIT clause
1. Moving the "| get_select_lex_derived select_derived_init" part of
select_derived into a separate new rule derived_query_specification.
2. Using derived_query_specification directly in select_derived_union
rather than in select_derived.
3. Moving the sequence "opt_order_clause opt_limit_clause opt_select_lock_type"
from select_derived2 to select_derived_union,
after derived_query_specification.

Effectively, the parser now does not go through the sequence
"opt_order_clause opt_limit_clause ... opt_union_order_or_limit" any more.

This fixes the problem with double LIMIT clause and removes 2 shift/reduce
conflicts.
2016-05-20 09:21:07 +04:00
Galina Shalygina
0f7fe2a743 Changes in test files 2016-05-19 23:17:19 +03:00
Galina Shalygina
46a2e41398 Fixed many problems in the code of With_element::check_unrestricted_recursive().
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.
2016-05-19 22:07:53 +03:00
Alexander Barkov
c9629daa1e This patch is a cleanup simplifying upcoming
"MDEV-8909 union parser cleanup" changes.

When the server parses a query like
  SELECT * FROM (SELECT 1);
a sequence of calls
  st_select_lex::init_nested_join() ..
  st_select_lex::end_nested_join()
was performed two times (tested in gdb).
Both pairs of calls seem to be redundant for a query
like this, because there are actually no any joins here.

This patch moved "table_ref_select" inside "select_derived",
which revealed that one the pairs was definitely redundant:
After this transformation we got an init_nested_join()
immediately followed by end_nested_join() for the same st_select_lex,
which has no any sense. So this pair of calls was removed.
2016-05-19 18:57:23 +04:00
Oleksandr Byelkin
50a17de1ce MDEV-9947: COM_MULTI united response 2016-05-17 13:31:33 +02:00
Alexander Barkov
e7ff281d2e MDEV-6353 my_ismbchar() and my_mbcharlen() refactoring 2016-05-17 15:27:10 +04:00
Alexander Barkov
7e66a24dfb MDEV-10079 sql_yacc.yy: Remove non-parenthesized SELECT from table_ref 2016-05-17 13:41:39 +04:00
Alexander Barkov
971d777ac1 sql_yacc.yy: Adding a helper rule get_select_lex_derived,
to simplify further MDEV-8909 refactoring.
2016-05-17 11:18:59 +04:00
Alexander Barkov
c322e3fb4c MDEV-10078 sql_yacc.yy: Remove non-parenthesized SELECT from table_factor 2016-05-17 09:58:45 +04:00
Igor Babaev
a742f8e06b Merge branch '10.2' of github.com:MariaDB/server into 10.2 2016-05-16 20:19:48 -07: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
Alexander Barkov
1f4f7293fc sql_yacc.yy cleanup, to simplify further changes for MDEV-8909.
- Moving "SELECT_SYM select_init2_derived opt_table_expression"
  from query_term into a new separate rule query_specification,
  and using query_specification in the beginning of query_term.
- query_term now does not have a %type, query_specification has a %type
  instead. This removes duplicate code that returns
  Lex->current_select->master_unit()->first_select();
2016-05-16 14:50:21 +04:00
Galina Shalygina
3b47632bfc Fixed a bug that caused crashes for SHOW CREATE VIEW <view> when <view> was recursive. Added a test case to check the fix. 2016-05-14 23:33:50 +03:00
Vladislav Vaintroub
b79944950e attempt to fix debian build (gssapi plugins require 10.1 client or server instead of 10.2 2016-05-14 15:37:14 +00:00
Alexander Barkov
81b4c5335e sql_yacc.yy: adding a new rule union_head_non_top, to reuse some code
between select_derived_union and query_expression_body.
An upcoming patch for MDEV-10035 will also reuse union_head_non_top.
2016-05-13 16:26:07 +04:00
Oleksandr Byelkin
ba500853d1 Fix of PSI & COM_MULTI 2016-05-13 12:09:14 +02:00
Alexander Barkov
53775a97d7 sql_yacc.yy:
- Moving select_options_and_item_list from select_init2
  to select_init and view_select_aux
- Renaming select_init2 to select_init3
This will simplify upcoming sql_yacc.yy fixes (e.g. MDEV-10035, MDEV-8909).
2016-05-13 10:38:09 +04: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
Sergey Vojtovich
47a7c314ca close_open_tables() is not meaningful anymore 2016-05-10 16:18:03 +04:00
Sergey Vojtovich
1c68b9e9a4 MDEV-505 - feature request: add \H option for mysql client prompt
An addition to original patch:
- use FN_REFLEN instead of HOST_NAME_MAX (the latter can be undefined)
- avoid calling gethostname() on every prompt construction by caching it
2016-05-10 14:23:30 +04:00