diff options
author | Dmitry Shulga <dmitry.shulga@mariadb.com> | 2022-12-20 15:09:48 +0700 |
---|---|---|
committer | Dmitry Shulga <dmitry.shulga@mariadb.com> | 2022-12-20 15:09:48 +0700 |
commit | bd42be6b2b95543f6e53edf5fda592651787e938 (patch) | |
tree | 237026ede5000acf27dcbd4902257e3c89c136d7 | |
parent | 72614b7074d3d171b4310ce5d7ab7e0b4ea68b41 (diff) | |
download | mariadb-git-bd42be6b2b95543f6e53edf5fda592651787e938.tar.gz |
MDEV-5816: Stored programs: validation of stored program statements
This is the prerequisite patch to move the data member
LEX::trg_table_fields to the class sp_head and rename it as
m_trg_table_fields.
This data member is used for handling OLD/NEW pseudo-rows inside
a trigger body and in order to be able to reparse a trigger body
the data member must be moved from the struct LEX to the class sp_head.
-rw-r--r-- | sql/sp_head.cc | 8 | ||||
-rw-r--r-- | sql/sp_head.h | 9 | ||||
-rw-r--r-- | sql/sql_lex.cc | 4 | ||||
-rw-r--r-- | sql/sql_lex.h | 9 | ||||
-rw-r--r-- | sql/sql_trigger.cc | 6 |
5 files changed, 14 insertions, 22 deletions
diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 279cea9d78e..aec8983f76f 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 457d0019028..2be7312fe7a 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -953,6 +953,15 @@ protected: push_backpatch(THD *thd, sp_instr *, sp_label *, List<bp_t> *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<Item_trigger_field> m_trg_table_fields; }; // class sp_head : public Sql_alloc diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 5397484f7de..295151373e1 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); } @@ -7913,7 +7913,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 942e2075ff1..9d4dd02759c 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -3477,14 +3477,6 @@ public: /* 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<Item_trigger_field> trg_table_fields; /* stmt_definition_begin is intended to point to the next word after @@ -5044,7 +5036,6 @@ public: 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 067b921eaf3..132dcc2465e 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) { |