summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2019-03-07 11:30:06 +0100
committerSergei Golubchik <serg@mariadb.org>2019-03-12 13:10:48 +0100
commitbc8ae50e7c1dd56ceb7fc39e05f87a104d3ce632 (patch)
tree8295a052dc5efd8bd29bfe5305df3280d193a150 /sql/sql_union.cc
parent83123412f00d9b69f1c5ea39b160d1d27be701a9 (diff)
downloadmariadb-git-bc8ae50e7c1dd56ceb7fc39e05f87a104d3ce632.tar.gz
Fix of prepared CREATE VIEW with global ORDER/GROUP
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc31
1 files changed, 21 insertions, 10 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 56d6cecadf6..72926a26e13 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -661,16 +661,6 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
allocation in setup_ref_array().
*/
fake_select_lex->n_child_sum_items+= global_parameters()->n_sum_items;
-
- saved_error= fake_select_lex->join->
- prepare(&fake_select_lex->ref_pointer_array,
- fake_select_lex->table_list.first,
- 0, 0,
- global_parameters()->order_list.elements, // og_num
- global_parameters()->order_list.first, // order
- false, NULL, NULL, NULL,
- fake_select_lex, this);
- fake_select_lex->table_list.empty();
}
}
else
@@ -681,6 +671,27 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
*/
table->reset_item_list(&item_list);
}
+ if (fake_select_lex != NULL &&
+ (thd->stmt_arena->is_stmt_prepare() ||
+ (thd->lex->context_analysis_only & CONTEXT_ANALYSIS_ONLY_VIEW)))
+ {
+ if (!fake_select_lex->join &&
+ !(fake_select_lex->join=
+ new JOIN(thd, item_list, thd->variables.option_bits, result)))
+ {
+ fake_select_lex->table_list.empty();
+ DBUG_RETURN(TRUE);
+ }
+ saved_error= fake_select_lex->join->
+ prepare(&fake_select_lex->ref_pointer_array,
+ fake_select_lex->table_list.first,
+ 0, 0,
+ global_parameters()->order_list.elements, // og_num
+ global_parameters()->order_list.first, // order
+ false, NULL, NULL, NULL,
+ fake_select_lex, this);
+ fake_select_lex->table_list.empty();
+ }
}
thd_arg->lex->current_select= lex_select_save;