1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

limit initialization moved to method of SELECT_LEX_UNIT (WL#695)

(SCRUM)
counters was not moved to SELECT_LEX because it used in methods inherited from select_result which should be applied to whole union results


mysql-test/r/union.result:
  this is results is true
sql/item_subselect.cc:
  limit initialization moved to method of SELECT_LEX_UNIT
sql/sql_derived.cc:
  limit initialization moved to method of SELECT_LEX_UNIT
sql/sql_lex.cc:
  limit initialization moved to method of SELECT_LEX_UNIT
sql/sql_lex.h:
  limit initialization moved to method of SELECT_LEX_UNIT
sql/sql_parse.cc:
  limit initialization moved to handle_select for single select (UNIONs already have it)
sql/sql_select.cc:
  limit initialization moved to method of SELECT_LEX_UNIT
sql/sql_union.cc:
  layout fixed
  limit initialization moved to method of SELECT_LEX_UNIT
This commit is contained in:
unknown
2003-11-21 21:19:56 +02:00
parent afe2186e3b
commit f28b5e6e91
8 changed files with 58 additions and 59 deletions

View File

@@ -130,11 +130,13 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result,
prepared= 1;
res= 0;
found_rows_for_union= first_select_in_union()->options & OPTION_FOUND_ROWS;
TMP_TABLE_PARAM tmp_table_param;
t_and_f= tables_and_fields_initied;
bzero((char *)&tmp_table_param,sizeof(TMP_TABLE_PARAM));
thd->lex->current_select= sl= select_cursor= first_select_in_union();
/* Global option */
if (t_and_f)
{
@@ -198,11 +200,8 @@ int st_select_lex_unit::prepare(THD *thd, select_result *sel_result,
sl->options | thd->options | SELECT_NO_UNLOCK,
union_result);
thd->lex->current_select= sl;
offset_limit_cnt= sl->offset_limit;
select_limit_cnt= sl->select_limit+sl->offset_limit;
if (select_limit_cnt < sl->select_limit)
select_limit_cnt= HA_POS_ERROR; // no limit
if (select_limit_cnt == HA_POS_ERROR || sl->braces)
set_limit(sl->select_limit, sl->offset_limit, sl);
if (sl->braces)
sl->options&= ~OPTION_FOUND_ROWS;
res= join->prepare(&sl->ref_pointer_array,
@@ -372,18 +371,15 @@ int st_select_lex_unit::exec()
if (!thd->is_fatal_error) // Check if EOM
{
ulong options= thd->options;
thd->lex->current_select= fake_select_lex;
offset_limit_cnt= global_parameters->offset_limit;
select_limit_cnt= global_parameters->select_limit +
global_parameters->offset_limit;
fake_select_lex->options= thd->options;
set_limit(global_parameters->select_limit,
global_parameters->offset_limit,
fake_select_lex);
if (select_limit_cnt < global_parameters->select_limit)
select_limit_cnt= HA_POS_ERROR; // no limit
if (select_limit_cnt == HA_POS_ERROR)
options&= ~OPTION_FOUND_ROWS;
else if (found_rows_for_union && !thd->lex->describe)
options|= OPTION_FOUND_ROWS;
if (found_rows_for_union && !thd->lex->describe &&
select_limit_cnt != HA_POS_ERROR)
fake_select_lex->options|= OPTION_FOUND_ROWS;
fake_select_lex->ftfunc_list= &empty_list;
fake_select_lex->table_list.link_in_list((byte *)&result_table_list,
(byte **)
@@ -395,7 +391,8 @@ int st_select_lex_unit::exec()
allocate JOIN for fake select only once (privent
mysql_select automatic allocation)
*/
fake_select_lex->join= new JOIN(thd, item_list, thd->options, result);
fake_select_lex->join= new JOIN(thd, item_list,
fake_select_lex->options, result);
/*
Fake st_select_lex should have item list for correctref_array
allocation.
@@ -410,7 +407,7 @@ int st_select_lex_unit::exec()
delete tab->select;
delete tab->quick;
}
join->init(thd, item_list, thd->options, result);
join->init(thd, item_list, fake_select_lex->options, result);
}
res= mysql_select(thd, &fake_select_lex->ref_pointer_array,
&result_table_list,
@@ -418,7 +415,7 @@ int st_select_lex_unit::exec()
global_parameters->order_list.elements,
(ORDER*)global_parameters->order_list.first,
(ORDER*) NULL, NULL, (ORDER*) NULL,
options | SELECT_NO_UNLOCK,
fake_select_lex->options | SELECT_NO_UNLOCK,
result, this, fake_select_lex, 0);
if (!res)
thd->limit_found_rows = (ulonglong)table->file->records + add_rows;