From 0ad598a00b17008b0c0702db40948b14d7eee0d5 Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Thu, 28 Feb 2019 18:13:28 +0400 Subject: A cleanup in derived table handling: removing duplicate code from st_select_lex::handle_derived() st_select_lex::handle_derived() and mysql_handle_list_of_derived() had exactly the same implementations. - Adding a new method LEX::handle_list_of_derived() instead - Removing public function mysql_handle_list_of_derived() - Reusing LEX::handle_list_of_derived() in st_select_lex::handle_derived() --- sql/sql_derived.cc | 30 ------------------------------ 1 file changed, 30 deletions(-) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 2e947ecba16..e990eba8e54 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -199,36 +199,6 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases) } -/** - Run specified phases for derived tables/views in the given list - - @param lex LEX for this thread - @param table_list list of derived tables/view to handle - @param phase_map phases to process tables/views through - - @details - This function runs phases specified by the 'phases_map' on derived - tables/views found in the 'dt_list' with help of the - TABLE_LIST::handle_derived function. - 'lex' is passed as an argument to the TABLE_LIST::handle_derived. - - @return FALSE ok - @return TRUE error -*/ - -bool -mysql_handle_list_of_derived(LEX *lex, TABLE_LIST *table_list, uint phases) -{ - for (TABLE_LIST *tl= table_list; tl; tl= tl->next_local) - { - if (tl->is_view_or_derived() && - tl->handle_derived(lex, phases)) - return TRUE; - } - return FALSE; -} - - /** Merge a derived table/view into the embedding select -- cgit v1.2.1 From cb11b3fbe9d4dde776cb8f2c0d6f83a569655efc Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Wed, 27 Feb 2019 15:53:25 +0100 Subject: MDEV-17055: Server crashes in find_order_in_list upon 2nd (3rd) execution of SP with UPDATE 1. Always drop merged_for_insert flag on cleanup (there could be errors which prevent TABLE to be assigned) 2. Make more precise cleanup of select parts which was touched --- sql/sql_derived.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_derived.cc') diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index e990eba8e54..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 @@ -1002,8 +1003,7 @@ bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived) derived->get_unit())); st_select_lex_unit *unit= derived->get_unit(); - if (derived->table) - derived->merged_for_insert= FALSE; + derived->merged_for_insert= FALSE; unit->unclean(); unit->types.empty(); /* for derived tables & PS (which can't be reset by Item_subquery) */ -- cgit v1.2.1