summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
authorunknown <sanja@askmonty.org>2014-11-15 22:18:33 +0100
committerunknown <sanja@askmonty.org>2014-11-15 22:18:33 +0100
commite7c356f7172cf0451eb4a1723623dfab54b8c3c3 (patch)
tree43583bbe16d9c60d666b27c789e1bbe4c30b2e77 /sql/sql_union.cc
parent665a7c83b90dc01bcca0a78fd0e84bd64e252d7f (diff)
downloadmariadb-git-e7c356f7172cf0451eb4a1723623dfab54b8c3c3.tar.gz
MDEV-6868: MariaDB server crash ( select with union and order by with subquery )
Excluding ORDER BY condition should be done after preparation it (even to catch syntax errors).
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc24
1 files changed, 12 insertions, 12 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 1bbd2eb6c29..6e2e6e06ff7 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -315,18 +315,6 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
can_skip_order_by= is_union_select && !(sl->braces && sl->explicit_limit);
- /*
- Remove all references from the select_lex_units to the subqueries that
- are inside the ORDER BY clause.
- */
- if (can_skip_order_by)
- {
- for (ORDER *ord= (ORDER *)sl->order_list.first; ord; ord= ord->next)
- {
- (*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL);
- }
- }
-
saved_error= join->prepare(&sl->ref_pointer_array,
sl->table_list.first,
sl->with_wild,
@@ -350,6 +338,18 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
if (saved_error || (saved_error= thd_arg->is_fatal_error))
goto err;
/*
+ Remove all references from the select_lex_units to the subqueries that
+ are inside the ORDER BY clause.
+ */
+ if (can_skip_order_by)
+ {
+ for (ORDER *ord= (ORDER *)sl->order_list.first; ord; ord= ord->next)
+ {
+ (*ord->item)->walk(&Item::eliminate_subselect_processor, FALSE, NULL);
+ }
+ }
+
+ /*
Use items list of underlaid select for derived tables to preserve
information about fields lengths and exact types
*/