diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 0eb494b5fd01940925c6376dc9c93850027c6a2e..d4d9f832a3dcdf9ed5e2ffc97466ecb43a0758de 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -883,9 +883,7 @@ subselect_single_select_engine(st_select_lex *select, { select_lex= select; SELECT_LEX_UNIT *unit= select_lex->master_unit(); - unit->set_limit(unit->global_parameters->select_limit, - unit->global_parameters->offset_limit, - select_lex); + unit->set_limit(unit->global_parameters, select_lex); unit->item= item; this->select_lex= select_lex; } diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index f668f053442ece9ac213a460bfe7e656ecc5174f..d0ed71ecfdd6bf91650efa288a14c1937c71d012 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -154,8 +154,7 @@ static int mysql_derived(THD *thd, LEX *lex, SELECT_LEX_UNIT *unit, res= mysql_union(thd, lex, derived_result, unit); else { - unit->set_limit(first_select->select_limit, first_select->offset_limit, - first_select); + unit->set_limit(first_select, first_select); lex->current_select= first_select; res= mysql_select(thd, &first_select->ref_pointer_array, diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index ef0ee753eb2e0a9968624dcd35145f545fdc5d3b..1b2457724dee6df87319b88dd837af2899d5ae07 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1635,12 +1635,20 @@ void st_select_lex::print_limit(THD *thd, String *str) } } -void st_select_lex_unit::set_limit(ha_rows limit, ha_rows offset, +/* + initialize limit counters + + SYNOPSIS + st_select_lex_unit::set_limit() + values - SELECT_LEX with initial values for counters + sl - SELECT_LEX for options set +*/ +void st_select_lex_unit::set_limit(SELECT_LEX *values, SELECT_LEX *sl) { - offset_limit_cnt= offset; - select_limit_cnt= limit+offset; - if (select_limit_cnt < limit) + offset_limit_cnt= values->offset_limit; + select_limit_cnt= values->select_limit+values->offset_limit; + if (select_limit_cnt < values->select_limit) select_limit_cnt= HA_POS_ERROR; // no limit if (select_limit_cnt == HA_POS_ERROR) sl->options&= ~OPTION_FOUND_ROWS; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index a35cf99bc918d0c18eb4881896e57f98aa6e8cb6..43d9b0132390ef1c17f03b02aa901bdf51f35078 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -371,7 +371,7 @@ class st_select_lex_unit: public st_select_lex_node { bool check_updateable(char *db, char *table); void print(String *str); - void set_limit(ha_rows limit, ha_rows offset, st_select_lex *sl); + void set_limit(st_select_lex *values, st_select_lex *sl); friend void mysql_init_query(THD *thd, bool lexonly); friend int subselect_union_engine::exec(); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 682699a22865777e3a4656a40457780ada907109..53405eb6fcd782a207aed433e4d34f176cd7b16b 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2179,8 +2179,7 @@ mysql_execute_command(THD *thd) if (tables && check_table_access(thd, SELECT_ACL, tables,0)) goto error; // Error message is given select_lex->options|= SELECT_NO_UNLOCK; - unit->set_limit(select_lex->select_limit, select_lex->offset_limit, - select_lex); + unit->set_limit(select_lex, select_lex); if (!(res=open_and_lock_tables(thd,tables))) { @@ -2580,8 +2579,7 @@ mysql_execute_command(THD *thd) select_lex->options|= SELECT_NO_UNLOCK; select_result *result; - unit->set_limit(select_lex->select_limit, select_lex->offset_limit, - select_lex); + unit->set_limit(select_lex, select_lex); if (find_real_table_in_list(tables->next, tables->db, tables->real_name)) { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a4d2ab97bc0a3c772d779f402240e8f7bb3700fa..8ee0601eb796dc7931a3960a023af4b8aad41002 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -179,9 +179,7 @@ int handle_select(THD *thd, LEX *lex, select_result *result) else { SELECT_LEX_UNIT *unit= &lex->unit; - unit->set_limit(unit->global_parameters->select_limit, - unit->global_parameters->offset_limit, - select_lex); + unit->set_limit(unit->global_parameters, select_lex); res= mysql_select(thd, &select_lex->ref_pointer_array, (TABLE_LIST*) select_lex->table_list.first, select_lex->with_wild, select_lex->item_list, @@ -1015,8 +1013,7 @@ JOIN::reinit() { DBUG_ENTER("JOIN::reinit"); /* TODO move to unit reinit */ - unit->set_limit(select_lex->select_limit, select_lex->offset_limit, - select_lex); + unit->set_limit(select_lex, select_lex); if (setup_tables(tables_list, 1)) DBUG_RETURN(1); @@ -9267,8 +9264,7 @@ int mysql_explain_select(THD *thd, SELECT_LEX *select_lex, char const *type, unit->select_limit_cnt= HA_POS_ERROR; } else - unit->set_limit(select_lex->select_limit, select_lex->offset_limit, - select_lex); + unit->set_limit(select_lex, select_lex); int res= mysql_select(thd, &select_lex->ref_pointer_array, (TABLE_LIST*) select_lex->table_list.first, select_lex->with_wild, select_lex->item_list, diff --git a/sql/sql_union.cc b/sql/sql_union.cc index d0e176b68cadd3a08f1d70b5069d52d8327ee1e3..303b0990cf7555efb7b2854954ea11779252bd79 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -151,7 +151,7 @@ int st_select_lex_unit::prepare(THD *thd_arg, select_result *sel_result, sl->options | thd_arg->options | additional_options, tmp_result); thd_arg->lex->current_select= sl; - set_limit(sl->select_limit, sl->offset_limit, sl); + set_limit(sl, sl); if (sl->braces) sl->options&= ~OPTION_FOUND_ROWS; @@ -375,9 +375,7 @@ int st_select_lex_unit::exec() { thd->lex->current_select= fake_select_lex; fake_select_lex->options= thd->options; - set_limit(global_parameters->select_limit, - global_parameters->offset_limit, - fake_select_lex); + set_limit(global_parameters, fake_select_lex); if (found_rows_for_union && !thd->lex->describe && select_limit_cnt != HA_POS_ERROR)