summaryrefslogtreecommitdiff
path: root/sql/sql_trigger.h
diff options
context:
space:
mode:
authorunknown <dlenev@mysql.com>2006-02-24 23:50:36 +0300
committerunknown <dlenev@mysql.com>2006-02-24 23:50:36 +0300
commitf8386dfa4821b79b6f88f8d9950ed370ba22e508 (patch)
treecd355e9fb3c3537be6b3aae48e6d5eb5276fe04c /sql/sql_trigger.h
parentb479c27f440cefd679498286d9c904efd647805c (diff)
downloadmariadb-git-f8386dfa4821b79b6f88f8d9950ed370ba22e508.tar.gz
Fix for bug #13525 "Rename table does not keep info of triggers".
Let us transfer triggers associated with table when we rename it (but only if we are not changing database to which table belongs, in the latter case we will emit error). mysql-test/r/trigger.result: Added test for bug #13525 "Rename table does not keep info of triggers". mysql-test/t/trigger.test: Added test for bug #13525 "Rename table does not keep info of triggers". sql/sql_rename.cc: rename_tables(): Now after renaming table's .FRM file and updating handler data we call Table_triggers_list::change_table_name() which is reponsible for updating .TRG and .TRN files. sql/sql_table.cc: mysql_alter_table(): Now in case when ALTER should rename table we call Table_triggers_list::change_table_name() which is responsible for updating .TRG and .TRN files after renaming table. sql/sql_trigger.cc: Added Table_triggers_list::change_table_name() method and change_table_name_in_triggers()/trignames() methods responsible for updating .TRG and .TRN files for table during its renaming. Two small cleanups - removed versioning for .TRG files (since it was not working before anyway) and emphasized that type of lock specified in tables list is unimportant for DROP TABLE (since this statement uses name-locking). sql/sql_trigger.h: Table_triggers_list: Added on_table_names_list member to store pointers and lenghts of "ON table_name" parts in triggers' definitions to be able easily change them during RENAME TABLE. Added change_table_name() method and change_table_name_in_trignames/triggers() helper methods responsible for updating .TRG and .TRN files. sql/sql_yacc.yy: trigger_tail: To be able properly update triggers' definitions with new table names when renaming tables we need to know where in CREATE TRIGGER statement "ON db_name.table_name" part resides. Small cleanup - let us emphasize that for CREATE TRIGGER statement lock type which is specified in table list is unimportant since name-locking is used.
Diffstat (limited to 'sql/sql_trigger.h')
-rw-r--r--sql/sql_trigger.h17
1 files changed, 16 insertions, 1 deletions
diff --git a/sql/sql_trigger.h b/sql/sql_trigger.h
index 51002683897..caf6c5175fc 100644
--- a/sql/sql_trigger.h
+++ b/sql/sql_trigger.h
@@ -47,6 +47,11 @@ class Table_triggers_list: public Sql_alloc
*/
List<LEX_STRING> names_list;
/*
+ List of "ON table_name" parts in trigger definitions, used for
+ updating trigger definitions during RENAME TABLE.
+ */
+ List<LEX_STRING> on_table_names_list;
+ /*
Key representing triggers for this table in set of all stored
routines used by statement.
TODO: We won't need this member once triggers namespace will be
@@ -97,7 +102,10 @@ public:
static bool check_n_load(THD *thd, const char *db, const char *table_name,
TABLE *table, bool names_only);
static bool drop_all_triggers(THD *thd, char *db, char *table_name);
-
+ static bool change_table_name(THD *thd, const char *db,
+ const char *old_table,
+ const char *new_db,
+ const char *new_table);
bool has_delete_triggers()
{
return (bodies[TRG_EVENT_DELETE][TRG_ACTION_BEFORE] ||
@@ -122,6 +130,13 @@ public:
private:
bool prepare_record1_accessors(TABLE *table);
+ LEX_STRING* change_table_name_in_trignames(const char *db_name,
+ LEX_STRING *new_table_name,
+ LEX_STRING *stopper);
+ bool change_table_name_in_triggers(THD *thd,
+ const char *db_name,
+ LEX_STRING *old_table_name,
+ LEX_STRING *new_table_name);
};
extern const LEX_STRING trg_action_time_type_names[];