diff options
author | unknown <konstantin@mysql.com> | 2005-05-30 20:54:37 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2005-05-30 20:54:37 +0400 |
commit | 78422442df581b736862bd090ab3c18d92e7d324 (patch) | |
tree | ddaffe242bb9f478a3e4a88598acfcc20bfa0700 /sql/item_subselect.cc | |
parent | 9ae4241994817853a514970b2e05293fba63c851 (diff) | |
download | mariadb-git-78422442df581b736862bd090ab3c18d92e7d324.tar.gz |
Preparatory (and the most problematic) patch for Bug#7306
"the server side preparedStatement error for LIMIT placeholder",
which moves all uses of LIMIT clause from PREPARE to OPTIMIZE
and later steps.
After-review fixes.
mysql-test/r/group_min_max.result:
Test results fixed for EXPLAINs when using GROUP_MIN_MAX access plan.
sql/item_subselect.cc:
Move setting of the internal LIMIT used for IN/ALL/ANY/EXISTS
subqueries to one place: Item_exists_subselect::fix_length_and_dec().
This implies that unit->select_limit_cnt is not set until the item is
fixed. This is OK, as now LIMIT values are not used until JOIN::optimize.
sql/mysql_priv.h:
setup_tables no longer needs a special flag for the case when
it's called from JOIN::reinit() (we don't need to call setup_tables
between two executions of a correlated subquery).
sql/opt_range.cc:
Fix a glitch in GROUP_MIN_MAX access plan: we should use table metadata,
not field data, to evaluate max_used_key_length, which is then
used for explain.
sql/sp.cc:
- setup_tables signature changed.
sql/sql_base.cc:
- setup_tables no longer needs a special mode for subqueries.
Unused checks were removed.
sql/sql_delete.cc:
- setup_tables signature changed
sql/sql_help.cc:
- setup_tables signature changed
sql/sql_insert.cc:
- setup_tables signature changed
sql/sql_lex.cc:
Consolidate setting of internal LIMIT for IN/ALL/ANY/EXISTS subqeries
in one place, and hence remove it from st_select_lex::test_limit().
sql/sql_lex.h:
Cleanup signature of st_select_lex_unit::init_prepare_fake_select_lex().
sql/sql_load.cc:
- setup_tables signature changed
sql/sql_olap.cc:
- setup_tables signature changed
sql/sql_parse.cc:
- st_select_lex_unit::set_limit() signature changed
sql/sql_select.cc:
Move setting of JOIN::select_limit from JOIN::prepare
to JOIN::optimize. At prepare, limit is unknown yet.
Remove excessive cleanups from JOIN::reinit which were overwriting
join->join_tab[i]->table->used_keys. This fixes the bug which was triggered
by the change in item_subselect.cc.
sql/sql_union.cc:
Class st_select_lex_unit was changed to avoid calls to
st_select_lex_unit::set_limit from places where it may be unknown.
Now unit->select_limit_cnt is set at ::exec().
st_select_lex_unit::init_prepare_fake_select_lex():
- move out set_limit functionality
- remove a few lines of dead code.
st_select_lex_unit::prepare():
- now we don't call set_limit at the time of prepare, so the value
of unit->select_limit_cnt may be unknown here. Use sl->select_limit
instead.
st_select_lex_unit::exec():
- cleanup
- call set_limit explicitly as it has been moved out of
init_prepare_fake_select_lex.
sql/sql_update.cc:
- setup_tables signature changed
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 0fbcf32a83c..8e5ae7c6a42 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -537,8 +537,6 @@ Item_exists_subselect::Item_exists_subselect(st_select_lex *select_lex): null_value= 0; //can't be NULL maybe_null= 0; //can't be NULL value= 0; - // We need only 1 row to determinate existence - select_lex->master_unit()->global_parameters->select_limit= 1; DBUG_VOID_RETURN; } @@ -605,6 +603,8 @@ void Item_exists_subselect::fix_length_and_dec() decimals= 0; max_length= 1; max_columns= engine->cols(); + /* We need only 1 row to determinate existence */ + unit->global_parameters->select_limit= 1; } double Item_exists_subselect::val_real() @@ -854,9 +854,6 @@ Item_in_subselect::single_value_transformer(JOIN *join, else { Item_maxmin_subselect *item; - // remove LIMIT placed by ALL/ANY subquery - select_lex->master_unit()->global_parameters->select_limit= - HA_POS_ERROR; subs= item= new Item_maxmin_subselect(thd, this, select_lex, func->l_op()); if (upper_item) upper_item->set_sub_test(item); @@ -1286,13 +1283,10 @@ subselect_single_select_engine(st_select_lex *select, select_subselect *result, Item_subselect *item) :subselect_engine(item, result), - prepared(0), optimized(0), executed(0), join(0) + prepared(0), optimized(0), executed(0), + select_lex(select), join(0) { - select_lex= select; - SELECT_LEX_UNIT *unit= select_lex->master_unit(); - unit->set_limit(unit->global_parameters, select_lex); - unit->item= item; - this->select_lex= select_lex; + select_lex->master_unit()->item= item; } @@ -1440,7 +1434,10 @@ int subselect_single_select_engine::exec() thd->lex->current_select= select_lex; if (!optimized) { - optimized=1; + SELECT_LEX_UNIT *unit= select_lex->master_unit(); + + optimized= 1; + unit->set_limit(unit->global_parameters); if (join->optimize()) { thd->where= save_where; |