mirror of
https://github.com/MariaDB/server.git
synced 2025-08-31 22:22:30 +03:00
Clumsy but working fix for bug #11973 "SELECT .. INTO var_name; in trigger
cause crash on update". Let us update "thd" pointer in LEX, all its units and in LEX::result before executing statement in trigger body, since triggers are associated with TABLE object and because of this can be used in different threads. mysql-test/r/trigger.result: Added test case for bug #11973 "SELECT .. INTO var_name; in trigger cause crash on update". mysql-test/t/trigger.test: Added test case for bug #11973 "SELECT .. INTO var_name; in trigger cause crash on update". sql/item_subselect.cc: subselect_engine: Moved implementation of set_thd() method to item_subselect.cc, since now it also sets "thd" for subselect_engine::result. sql/item_subselect.h: subselect_engine: Moved implementation of set_thd() method to item_subselect.cc, since now it also sets "thd" for subselect_engine::result. sql/sql_class.h: select_result: Added set_thd() method for updating select_result::thd value (we need this in cases when statement to which this select_result belongs will be used in different threads, as it happens for statements in trigger body). multi_delete/multi_update: Got rid of redundant "thd" member (we already have it in select_result). sql/sql_delete.cc: multi_delete: Got rid of redundant "thd" member (we already have it in select_result). sql/sql_lex.h: st_select_lex_unit: Added set_thd() method for updating st_select_lex_unit::thd value (we need this in cases when statement to which this unit belongs will be used in different threads, as it happens for statements in trigger body). We don't update thd of select_result pointed by st_select_lex_unit::result in this method, since it is either have too short lifetime (i.e. created for each execution) or is accessible via Item_subquery or LEX::result and thus already taken care of. sql/sql_parse.cc: multi_delete: Got rid of redundant "thd" member (we already have it in select_result). sql/sql_prepare.cc: reinit_stmt_before_use(): We have to update "thd" pointer in LEX, all its units and in LEX::result, since statements which belong to trigger body are associated with TABLE object and because of this can be used in different threads. sql/sql_update.cc: multi_update: Got rid of redundant "thd" member (we already have it in select_result).
This commit is contained in:
@@ -1560,6 +1560,7 @@ public:
|
||||
statement/stored procedure.
|
||||
*/
|
||||
virtual void cleanup();
|
||||
void set_thd(THD *thd_arg) { thd= thd_arg; }
|
||||
};
|
||||
|
||||
|
||||
@@ -1915,14 +1916,13 @@ class multi_delete :public select_result_interceptor
|
||||
{
|
||||
TABLE_LIST *delete_tables, *table_being_deleted;
|
||||
Unique **tempfiles;
|
||||
THD *thd;
|
||||
ha_rows deleted, found;
|
||||
uint num_of_tables;
|
||||
int error;
|
||||
bool do_delete, transactional_tables, normal_tables, delete_while_scanning;
|
||||
|
||||
public:
|
||||
multi_delete(THD *thd, TABLE_LIST *dt, uint num_of_tables);
|
||||
multi_delete(TABLE_LIST *dt, uint num_of_tables);
|
||||
~multi_delete();
|
||||
int prepare(List<Item> &list, SELECT_LEX_UNIT *u);
|
||||
bool send_data(List<Item> &items);
|
||||
@@ -1938,7 +1938,6 @@ class multi_update :public select_result_interceptor
|
||||
TABLE_LIST *all_tables; /* query/update command tables */
|
||||
TABLE_LIST *leaves; /* list of leves of join table tree */
|
||||
TABLE_LIST *update_tables, *table_being_updated;
|
||||
THD *thd;
|
||||
TABLE **tmp_tables, *main_table, *table_to_update;
|
||||
TMP_TABLE_PARAM *tmp_table_param;
|
||||
ha_rows updated, found;
|
||||
@@ -1950,7 +1949,7 @@ class multi_update :public select_result_interceptor
|
||||
bool do_update, trans_safe, transactional_tables, ignore;
|
||||
|
||||
public:
|
||||
multi_update(THD *thd_arg, TABLE_LIST *ut, TABLE_LIST *leaves_list,
|
||||
multi_update(TABLE_LIST *ut, TABLE_LIST *leaves_list,
|
||||
List<Item> *fields, List<Item> *values,
|
||||
enum_duplicates handle_duplicates, bool ignore);
|
||||
~multi_update();
|
||||
|
Reference in New Issue
Block a user