diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 978589eb7991a..b789acec465b7 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -801,12 +801,6 @@ sp_head::init(LEX *lex) if (!lex->spcont) DBUG_VOID_RETURN; - /* - Altough trg_table_fields list is used only in triggers we init for all - types of stored procedures to simplify reset_lex()/restore_lex() code. - */ - lex->trg_table_fields.empty(); - DBUG_VOID_RETURN; } @@ -2492,8 +2486,6 @@ sp_head::merge_lex(THD *thd, LEX *oldlex, LEX *sublex) sublex->set_trg_event_type_for_tables(); - oldlex->trg_table_fields.push_back(&sublex->trg_table_fields); - /* If this substatement is unsafe, the entire routine is too. */ DBUG_PRINT("info", ("sublex->get_stmt_unsafe_flags: 0x%x", sublex->get_stmt_unsafe_flags())); diff --git a/sql/sp_head.h b/sql/sp_head.h index 3e44fa13d14cb..0e4bc952c93f4 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -952,6 +952,15 @@ class sp_head :private Query_arena, push_backpatch(THD *thd, sp_instr *, sp_label *, List *list, backpatch_instr_type itype); +public: + /* + List of all items (Item_trigger_field objects) representing fields in + old/new version of row in trigger. We use this list for checking whenever + all such fields are valid at trigger creation time and for binding these + fields to TABLE object at table open (altough for latter pointer to table + being opened is probably enough). + */ + SQL_I_List m_trg_table_fields; }; // class sp_head : public Sql_alloc diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 0e4d621de32dc..3c13bb1e68f72 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -239,7 +239,7 @@ bool LEX::set_trigger_new_row(const LEX_CSTRING *name, Item *val) Let us add this item to list of all Item_trigger_field objects in trigger. */ - trg_table_fields.link_in_list(trg_fld, &trg_fld->next_trg_field); + sphead->m_trg_table_fields.link_in_list(trg_fld, &trg_fld->next_trg_field); return sphead->add_instr(sp_fld); } @@ -7883,7 +7883,7 @@ Item *LEX::create_and_link_Item_trigger_field(THD *thd, in trigger. */ if (likely(trg_fld)) - trg_table_fields.link_in_list(trg_fld, &trg_fld->next_trg_field); + sphead->m_trg_table_fields.link_in_list(trg_fld, &trg_fld->next_trg_field); return trg_fld; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index b75641142755d..a243848b6834d 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -3536,14 +3536,6 @@ struct LEX: public Query_tables_list /* Characterstics of trigger being created */ st_trg_chistics trg_chistics; - /* - List of all items (Item_trigger_field objects) representing fields in - old/new version of row in trigger. We use this list for checking whenever - all such fields are valid at trigger creation time and for binding these - fields to TABLE object at table open (altough for latter pointer to table - being opened is probably enough). - */ - SQL_I_List trg_table_fields; /* stmt_definition_begin is intended to point to the next word after @@ -5102,7 +5094,6 @@ class sp_lex_local: public st_lex_local spcont= oldlex->spcont; /* Keep the parent trigger stuff too */ trg_chistics= oldlex->trg_chistics; - trg_table_fields.empty(); sp_lex_in_use= false; } }; diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index 067b921eaf3a9..132dcc2465e5a 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -939,7 +939,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, */ old_field= new_field= table->field; - for (trg_field= lex->trg_table_fields.first; + for (trg_field= lex->sphead->m_trg_table_fields.first; trg_field; trg_field= trg_field->next_trg_field) { /* @@ -1797,7 +1797,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, in old/new versions of row in trigger into lists containing all such objects for the trigger_list with same action and timing. */ - trigger->trigger_fields= lex.trg_table_fields.first; + trigger->trigger_fields= sp->m_trg_table_fields.first; /* Also let us bind these objects to Field objects in table being opened. @@ -1807,7 +1807,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const LEX_CSTRING *db, SELECT)... Anyway some things can be checked only during trigger execution. */ - for (Item_trigger_field *trg_field= lex.trg_table_fields.first; + for (Item_trigger_field *trg_field= sp->m_trg_table_fields.first; trg_field; trg_field= trg_field->next_trg_field) {