• unknown's avatar
    Fix for bug #13525 "Rename table does not keep info of triggers". · f8386dfa
    unknown authored
    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.
    f8386dfa
sql_trigger.h 5.18 KB