Skip to content

Commit 9b9522a

Browse files
committed
MDEV-8133 ALTER TABLE can perform the operation but escape the binary log
fix a few cases where a successful ALTER was not binlogged: * on errors after the completed ALTER, binlog it, then return an error * don't let thd->killed abort open_table() after completed online ALTER.
1 parent 1fc6e29 commit 9b9522a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

sql/sql_table.cc

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6889,7 +6889,7 @@ static bool mysql_inplace_alter_table(THD *thd,
68896889
MDL_request *target_mdl_request,
68906890
Alter_table_ctx *alter_ctx)
68916891
{
6892-
Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN);
6892+
Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN | MYSQL_OPEN_IGNORE_KILLED);
68936893
handlerton *db_type= table->s->db_type();
68946894
MDL_ticket *mdl_ticket= table->mdl_ticket;
68956895
HA_CREATE_INFO *create_info= ha_alter_info->create_info;
@@ -9094,13 +9094,13 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
90949094
error, but still worth reporting as it might indicate serious
90959095
problem with server.
90969096
*/
9097-
goto err_with_mdl;
9097+
goto err_with_mdl_after_alter;
90989098
}
90999099

91009100
end_inplace:
91019101

91029102
if (thd->locked_tables_list.reopen_tables(thd))
9103-
goto err_with_mdl;
9103+
goto err_with_mdl_after_alter;
91049104

91059105
THD_STAGE_INFO(thd, stage_end);
91069106

@@ -9199,6 +9199,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
91999199

92009200
DBUG_RETURN(true);
92019201

9202+
err_with_mdl_after_alter:
9203+
/* the table was altered. binlog the operation */
9204+
write_bin_log(thd, true, thd->query(), thd->query_length());
9205+
92029206
err_with_mdl:
92039207
/*
92049208
An error happened while we were holding exclusive name metadata lock

0 commit comments

Comments
 (0)