summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
authorunknown <timour@askmonty.org>2010-09-05 18:43:47 +0300
committerunknown <timour@askmonty.org>2010-09-05 18:43:47 +0300
commit18ad3bdc2fa3bbe1bfd7e433adb0bc6b3dbce8c8 (patch)
tree6c257aff7c14aa611fc2a7f76149dc830c7ed9e8 /sql/sql_union.cc
parentaa195b25704b4e67423654422ce0b601b54f809d (diff)
downloadmariadb-git-18ad3bdc2fa3bbe1bfd7e433adb0bc6b3dbce8c8.tar.gz
MWL#89: Cost-based choice between Materialization and IN->EXISTS transformation
Fixes for multiple problems/bugs/test failures that resulted from moving subquery optimization from the execution phase to the optimization phase.
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 374e92c6a52..d91bdc069e8 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -186,6 +186,8 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg)
{
(*order->item)->walk(&Item::change_context_processor, 0,
(uchar*) &fake_select_lex->context);
+ (*order->item)->walk(&Item::set_fake_select_as_master_processor, 0,
+ (uchar*) fake_select_lex);
}
}
@@ -271,6 +273,18 @@ 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,
(TABLE_LIST*) sl->table_list.first,
sl->with_wild,