summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2019-05-08 00:08:09 -0700
committerIgor Babaev <igor@askmonty.org>2019-05-08 09:45:24 -0700
commit09aa5d3f6988e92f869adfd13a925bfead6f040d (patch)
tree6e487e5d025573d3d638be0d07b52cb6210609f0 /sql/sql_union.cc
parent9d805004d8e7913a98d25142d22627a4a6e39063 (diff)
downloadmariadb-git-09aa5d3f6988e92f869adfd13a925bfead6f040d.tar.gz
MDEV-17894 Assertion `(thd->lex)->current_select' failed in MYSQLparse(),
query with VALUES() A table value constructor can be used in all contexts where a select can be used. In particular an ORDER BY clause or a LIMIT clause or both of them can be attached to a table value constructor to produce a new query. Unfortunately execution of such queries was not supported. This patch fixes the problem.
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc21
1 files changed, 19 insertions, 2 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 3fb5552c77a..c591e49d58a 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -831,7 +831,8 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg,
bool is_union_select;
bool have_except= FALSE, have_intersect= FALSE;
bool instantiate_tmp_table= false;
- bool single_tvc= !first_sl->next_select() && first_sl->tvc;
+ bool single_tvc= !first_sl->next_select() && first_sl->tvc &&
+ !fake_select_lex;
DBUG_ENTER("st_select_lex_unit::prepare");
DBUG_ASSERT(thd == current_thd);
@@ -986,7 +987,23 @@ bool st_select_lex_unit::prepare(TABLE_LIST *derived_arg,
{
if (sl->tvc)
{
- if (sl->tvc->prepare(thd, sl, tmp_result, this))
+ if (sl->tvc->to_be_wrapped_as_with_tail() &&
+ !(thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW))
+
+ {
+ st_select_lex *wrapper_sl= wrap_tvc_with_tail(thd, sl);
+ if (!wrapper_sl)
+ goto err;
+
+ if (sl == first_sl)
+ first_sl= wrapper_sl;
+ sl= wrapper_sl;
+
+ if (prepare_join(thd, sl, tmp_result, additional_options,
+ is_union_select))
+ goto err;
+ }
+ else if (sl->tvc->prepare(thd, sl, tmp_result, this))
goto err;
}
else if (prepare_join(thd, sl, tmp_result, additional_options,