[Commits] b7cc17b2734: postreview
revision-id: b7cc17b27340f1659165f2c9fbdf891355b98d33 (mariadb-5.5.63-8-gb7cc17b2734) parent(s): ae5bf0d6ada265d1158d108290555d9077e7580e author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2019-02-28 17:18:58 +0100 message: postreview --- sql/sql_delete.cc | 2 -- sql/sql_derived.cc | 1 + sql/sql_insert.cc | 2 -- sql/sql_lex.cc | 7 ++++--- sql/sql_lex.h | 13 +++++-------- sql/sql_load.cc | 2 -- sql/sql_prepare.cc | 20 ++++++++++---------- sql/sql_select.cc | 2 -- sql/sql_union.cc | 5 +++-- sql/sql_update.cc | 2 -- 10 files changed, 23 insertions(+), 33 deletions(-) diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 51300b27600..ab573df7992 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -474,8 +474,6 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) DBUG_ENTER("mysql_prepare_delete"); List<Item> all_fields; - select_lex->first_execution_attempt= FALSE; - thd->lex->allow_sum_func= 0; if (setup_tables_and_check_access(thd, &thd->lex->select_lex.context, &thd->lex->select_lex.top_join_list, diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index f5f6d52e793..1709669d8a2 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -90,6 +90,7 @@ mysql_handle_derived(LEX *lex, uint phases) sl= sl->next_select_in_list()) { TABLE_LIST *cursor= sl->get_table_list(); + sl->changed_elements|= TOUCHED_SEL_DERIVED; /* DT_MERGE_FOR_INSERT is not needed for views/derived tables inside subqueries. Views and derived tables of subqueries should be diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 71eb434201c..cc040508842 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1400,8 +1400,6 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list, /* INSERT should have a SELECT or VALUES clause */ DBUG_ASSERT (!select_insert || !values); - select_lex->first_execution_attempt= FALSE; - if (mysql_handle_derived(thd->lex, DT_INIT)) DBUG_RETURN(TRUE); if (table_list->handle_derived(thd->lex, DT_MERGE_FOR_INSERT)) diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index bf23a916056..7d694f90aa2 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1904,7 +1904,7 @@ void st_select_lex::init_query() n_child_sum_items= 0; subquery_in_having= explicit_limit= 0; is_item_list_lookup= 0; - first_execution_attempt= first_execution= 1; + changed_elements= 0; first_natural_join_processing= 1; first_cond_optimization= 1; parsing_place= NO_MATTER; @@ -3367,9 +3367,10 @@ void st_select_lex::fix_prepare_information(THD *thd, Item **conds, Item **having_conds) { DBUG_ENTER("st_select_lex::fix_prepare_information"); - if (!thd->stmt_arena->is_conventional() && first_execution) + if (!thd->stmt_arena->is_conventional() && + !(changed_elements & TOUCHED_SEL_COND)) { - first_execution= 0; + changed_elements|= TOUCHED_SEL_COND; if (group_list.first) { if (!group_list_ptrs) diff --git a/sql/sql_lex.h b/sql/sql_lex.h index e1b96b86249..abbfd901112 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -729,6 +729,10 @@ class st_select_lex_unit: public st_select_lex_node { typedef class st_select_lex_unit SELECT_LEX_UNIT; + +#define TOUCHED_SEL_COND 1/* WHERE/HAVING/ON should be reinited before use */ +#define TOUCHED_SEL_DERIVED 2/* derived should be reinited before use */ + /* SELECT_LEX - store information of parsed SELECT statment */ @@ -875,15 +879,8 @@ class st_select_lex: public st_select_lex_node variable to inidicate the optimization/execution state of every subquery. Prepared statements work OK in that regard, as in case of an error during prepare the PS is not created. - - TODO: make a bitmap with execution stages done for nest bool flags - */ - bool first_execution; // where/having saved - /* - False if we have started execution and so there is something to cleanup - in tables/derived tables */ - bool first_execution_attempt; + uint8 changed_elements; // see TOUCHED_SEL_* bool first_natural_join_processing; bool first_cond_optimization; /* do not wrap view fields with Item_ref */ diff --git a/sql/sql_load.cc b/sql/sql_load.cc index befa7a33478..850360c1dba 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -202,8 +202,6 @@ int mysql_load(THD *thd,sql_exchange *ex,TABLE_LIST *table_list, bool transactional_table __attribute__((unused)); DBUG_ENTER("mysql_load"); - thd->lex->select_lex.first_execution_attempt= FALSE; - /* Bug #34283 mysqlbinlog leaves tmpfile after termination if binlog contains diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 935ff29f6df..16923ee5a21 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2496,7 +2496,7 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) } for (; sl; sl= sl->next_select_in_list()) { - if (!sl->first_execution) + if (sl->changed_elements & TOUCHED_SEL_COND) { /* remove option which was put by mysql_explain_union() */ sl->options&= ~SELECT_DESCRIBE; @@ -2533,9 +2533,6 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) else sl->having= NULL; DBUG_ASSERT(sl->join == 0); - } - if (!sl->first_execution_attempt) - { ORDER *order; /* Fix GROUP list */ if (sl->group_list_ptrs && sl->group_list_ptrs->size() > 0) @@ -2546,6 +2543,9 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) order->next= sl->group_list_ptrs->at(ix+1); } } + } + { // no harm to do it (item_ptr set on parsing) + ORDER *order; for (order= sl->group_list.first; order; order= order->next) { order->item= &order->item_ptr; @@ -2555,14 +2555,14 @@ void reinit_stmt_before_use(THD *thd, LEX *lex) { order->item= &order->item_ptr; } - - { + } + if (sl->changed_elements & TOUCHED_SEL_DERIVED) + { #ifndef DBUG_OFF - bool res= + bool res= #endif - sl->handle_derived(lex, DT_REINIT); - DBUG_ASSERT(res == 0); - } + sl->handle_derived(lex, DT_REINIT); + DBUG_ASSERT(res == 0); } { diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 489851dce46..35937f0536f 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -638,8 +638,6 @@ JOIN::prepare(Item ***rref_pointer_array, join_list= &select_lex->top_join_list; union_part= unit_arg->is_union(); - select_lex->first_execution_attempt= FALSE; - // simple check that we got usable conds dbug_print_item(conds); diff --git a/sql/sql_union.cc b/sql/sql_union.cc index bbb4133417e..e855b64e600 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -215,8 +215,9 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg, called at the first execution of the statement, while first_execution shows whether this is called at the first execution of the union that may form just a subselect. - */ - if (!fake_select_lex->first_execution && first_execution) + */ + if ((fake_select_lex->changed_elements & TOUCHED_SEL_COND) && + first_execution) { for (ORDER *order= global_parameters->order_list.first; order; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index ef51e2070a3..fe007d5823d 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1010,8 +1010,6 @@ bool mysql_prepare_update(THD *thd, TABLE_LIST *table_list, SELECT_LEX *select_lex= &thd->lex->select_lex; DBUG_ENTER("mysql_prepare_update"); - select_lex->first_execution_attempt= FALSE; - #ifndef NO_EMBEDDED_ACCESS_CHECKS table_list->grant.want_privilege= table->grant.want_privilege= (SELECT_ACL & ~table->grant.privilege);
participants (1)
-
Oleksandr Byelkin