Commit 9b9522a8 authored by Sergei Golubchik's avatar Sergei Golubchik

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.
parent 1fc6e297
......@@ -6889,7 +6889,7 @@ static bool mysql_inplace_alter_table(THD *thd,
MDL_request *target_mdl_request,
Alter_table_ctx *alter_ctx)
{
Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN);
Open_table_context ot_ctx(thd, MYSQL_OPEN_REOPEN | MYSQL_OPEN_IGNORE_KILLED);
handlerton *db_type= table->s->db_type();
MDL_ticket *mdl_ticket= table->mdl_ticket;
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,
error, but still worth reporting as it might indicate serious
problem with server.
*/
goto err_with_mdl;
goto err_with_mdl_after_alter;
}
end_inplace:
if (thd->locked_tables_list.reopen_tables(thd))
goto err_with_mdl;
goto err_with_mdl_after_alter;
THD_STAGE_INFO(thd, stage_end);
......@@ -9199,6 +9199,10 @@ bool mysql_alter_table(THD *thd,char *new_db, char *new_name,
DBUG_RETURN(true);
err_with_mdl_after_alter:
/* the table was altered. binlog the operation */
write_bin_log(thd, true, thd->query(), thd->query_length());
err_with_mdl:
/*
An error happened while we were holding exclusive name metadata lock
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment