summaryrefslogtreecommitdiff
path: root/sql/sql_union.cc
diff options
context:
space:
mode:
authorunknown <ramil@mysql.com>2005-03-03 14:29:37 +0400
committerunknown <ramil@mysql.com>2005-03-03 14:29:37 +0400
commit0abf1f6d3f6c1d287e083c9e75da20ae70012364 (patch)
treefa61b1ad2630dd81411a79456d348eb56a704ca7 /sql/sql_union.cc
parent17ff0a138a2b14f4368aa0838a46fca9027c57cc (diff)
parent90eed6566b306eb048efeb9612500e4f6658b44c (diff)
downloadmariadb-git-0abf1f6d3f6c1d287e083c9e75da20ae70012364.tar.gz
manual merge
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r--sql/sql_union.cc33
1 files changed, 12 insertions, 21 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc
index 455c83e1718..13c7f0a40b7 100644
--- a/sql/sql_union.cc
+++ b/sql/sql_union.cc
@@ -217,8 +217,6 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
thd_arg->lex->current_select= sl;
set_limit(sl, sl);
- if (sl->braces)
- sl->options&= ~OPTION_FOUND_ROWS;
can_skip_order_by= is_union &&
(!sl->braces || select_limit_cnt == HA_POS_ERROR);
@@ -342,10 +340,9 @@ bool st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result,
if (arena->is_stmt_prepare())
{
/* prepare fake select to initialize it correctly */
- ulong options_tmp= init_prepare_fake_select_lex(thd);
+ (void) init_prepare_fake_select_lex(thd);
/*
- it should be done only once (because item_list builds only onece
- per statement)
+ Should be done only once (the only item_list per statement).
*/
DBUG_ASSERT(fake_select_lex->join == 0);
if (!(fake_select_lex->join= new JOIN(thd, item_list, thd->options,
@@ -452,21 +449,14 @@ bool st_select_lex_unit::exec()
if (select_limit_cnt < sl->select_limit)
select_limit_cnt= HA_POS_ERROR; // no limit
- /*
- When using braces, SQL_CALC_FOUND_ROWS affects the whole query.
- We don't calculate found_rows() per union part
- */
- if (select_limit_cnt == HA_POS_ERROR || sl->braces)
- sl->options&= ~OPTION_FOUND_ROWS;
- else
- {
- /*
- We are doing an union without braces. In this case
- SQL_CALC_FOUND_ROWS should be done on all sub parts
- */
- sl->options|= found_rows_for_union;
- }
- sl->join->select_options=sl->options;
+ /*
+ When using braces, SQL_CALC_FOUND_ROWS affects the whole query:
+ we don't calculate found_rows() per union part.
+ Otherwise, SQL_CALC_FOUND_ROWS should be done on all sub parts.
+ */
+ sl->join->select_options=
+ (select_limit_cnt == HA_POS_ERROR || sl->braces) ?
+ sl->options & ~OPTION_FOUND_ROWS : sl->options | found_rows_for_union;
res= sl->join->optimize();
}
if (!res)
@@ -498,7 +488,8 @@ bool st_select_lex_unit::exec()
}
/* Needed for the following test and for records_at_start in next loop */
table->file->info(HA_STATUS_VARIABLE);
- if (found_rows_for_union & sl->options)
+ if (found_rows_for_union && !sl->braces &&
+ select_limit_cnt != HA_POS_ERROR)
{
/*
This is a union without braces. Remember the number of rows that