From a127820ae1602c9b119cc3b7528faedcb8223488 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 30 May 2005 20:54:37 +0400 Subject: 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 --- sql/sql_delete.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'sql/sql_delete.cc') diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 97830f7ec8f..4ec4258f412 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -300,8 +300,7 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) SELECT_LEX *select_lex= &thd->lex->select_lex; DBUG_ENTER("mysql_prepare_delete"); - if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, - FALSE, FALSE) || + if (setup_tables(thd, table_list, conds, &select_lex->leaf_tables, FALSE) || setup_conds(thd, table_list, select_lex->leaf_tables, conds) || setup_ftfuncs(select_lex)) DBUG_RETURN(TRUE); @@ -358,7 +357,7 @@ bool mysql_multi_delete_prepare(THD *thd) lex->query_tables also point on local list of DELETE SELECT_LEX */ if (setup_tables(thd, lex->query_tables, &lex->select_lex.where, - &lex->select_lex.leaf_tables, FALSE, FALSE)) + &lex->select_lex.leaf_tables, FALSE)) DBUG_RETURN(TRUE); -- cgit v1.2.1