@@ -7058,6 +7058,7 @@ static bool mysql_inplace_alter_table(THD *thd,
70587058 TABLE *altered_table,
70597059 Alter_inplace_info *ha_alter_info,
70607060 MDL_request *target_mdl_request,
7061+ TRIGGER_RENAME_PARAM *trigger_param,
70617062 Alter_table_ctx *alter_ctx)
70627063{
70637064 Open_table_context ot_ctx (thd, MYSQL_OPEN_REOPEN | MYSQL_OPEN_IGNORE_KILLED);
@@ -7330,7 +7331,7 @@ static bool mysql_inplace_alter_table(THD *thd,
73307331 */
73317332 DBUG_RETURN (true );
73327333 }
7333- if (Table_triggers_list::change_table_name (thd,
7334+ if (Table_triggers_list::change_table_name (thd, trigger_param,
73347335 &alter_ctx->db ,
73357336 &alter_ctx->alias ,
73367337 &alter_ctx->table_name ,
@@ -7343,7 +7344,8 @@ static bool mysql_inplace_alter_table(THD *thd,
73437344 */
73447345 (void ) mysql_rename_table (db_type,
73457346 &alter_ctx->new_db , &alter_ctx->new_alias ,
7346- &alter_ctx->db , &alter_ctx->alias , NO_FK_CHECKS);
7347+ &alter_ctx->db , &alter_ctx->alias ,
7348+ NO_FK_CHECKS);
73477349 DBUG_RETURN (true );
73487350 }
73497351 rename_table_in_stat_tables (thd, &alter_ctx->db , &alter_ctx->alias ,
@@ -8849,6 +8851,7 @@ simple_tmp_rename_or_index_change(THD *thd, TABLE_LIST *table_list,
88498851static bool
88508852simple_rename_or_index_change (THD *thd, TABLE_LIST *table_list,
88518853 Alter_info::enum_enable_or_disable keys_onoff,
8854+ TRIGGER_RENAME_PARAM *trigger_param,
88528855 Alter_table_ctx *alter_ctx)
88538856{
88548857 TABLE *table= table_list->table ;
@@ -8895,7 +8898,7 @@ simple_rename_or_index_change(THD *thd, TABLE_LIST *table_list,
88958898 if (mysql_rename_table (old_db_type, &alter_ctx->db , &alter_ctx->table_name ,
88968899 &alter_ctx->new_db , &alter_ctx->new_alias , 0 ))
88978900 error= -1 ;
8898- else if (Table_triggers_list::change_table_name (thd,
8901+ else if (Table_triggers_list::change_table_name (thd, trigger_param,
88998902 &alter_ctx->db ,
89008903 &alter_ctx->alias ,
89018904 &alter_ctx->table_name ,
@@ -9080,6 +9083,7 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db,
90809083 MDL_request target_mdl_request;
90819084 MDL_ticket *mdl_ticket= 0 ;
90829085 Alter_table_prelocking_strategy alter_prelocking_strategy;
9086+ TRIGGER_RENAME_PARAM trigger_param;
90839087 DBUG_ENTER (" mysql_alter_table" );
90849088
90859089 /*
@@ -9504,6 +9508,16 @@ do_continue:;
95049508 create_info))
95059509 DBUG_RETURN (true );
95069510
9511+ /* Check if rename of triggers are supported */
9512+ if (alter_ctx.is_table_renamed () &&
9513+ Table_triggers_list::prepare_for_rename (thd, &trigger_param,
9514+ &alter_ctx.db ,
9515+ &alter_ctx.alias ,
9516+ &alter_ctx.table_name ,
9517+ &alter_ctx.new_db ,
9518+ &alter_ctx.new_alias ))
9519+ DBUG_RETURN (true );
9520+
95079521 /*
95089522 Look if we have to do anything at all.
95099523 ALTER can become NOOP after handling
@@ -9549,6 +9563,7 @@ do_continue:;
95499563 }
95509564 res= simple_rename_or_index_change (thd, table_list,
95519565 alter_info->keys_onoff ,
9566+ &trigger_param,
95529567 &alter_ctx);
95539568 }
95549569 else
@@ -9805,7 +9820,7 @@ do_continue:;
98059820 &altered_table))
98069821 goto err_new_table_cleanup;
98079822 /*
9808- Avoid creating frm again in ha_create_table() if inline alter will not
9823+ Avoid creating frm again in ha_create_table() if inplace alter will not
98099824 be used.
98109825 */
98119826 frm_is_created= 1 ;
@@ -9879,9 +9894,12 @@ do_continue:;
98799894 */
98809895 enum_check_fields org_count_cuted_fields= thd->count_cuted_fields ;
98819896 thd->count_cuted_fields = CHECK_FIELD_WARN;
9882- int res= mysql_inplace_alter_table (thd, table_list, table, &altered_table,
9897+ int res= mysql_inplace_alter_table (thd,
9898+ table_list, table, &altered_table,
98839899 &ha_alter_info,
9884- &target_mdl_request, &alter_ctx);
9900+ &target_mdl_request,
9901+ &trigger_param,
9902+ &alter_ctx);
98859903 thd->count_cuted_fields = org_count_cuted_fields;
98869904 my_free (const_cast <uchar*>(frm.str ));
98879905
@@ -10216,7 +10234,7 @@ do_continue:;
1021610234 // Check if we renamed the table and if so update trigger files.
1021710235 if (alter_ctx.is_table_renamed ())
1021810236 {
10219- if (Table_triggers_list::change_table_name (thd,
10237+ if (Table_triggers_list::change_table_name (thd, &trigger_param,
1022010238 &alter_ctx.db ,
1022110239 &alter_ctx.alias ,
1022210240 &alter_ctx.table_name ,
0 commit comments