Skip to content

Commit

Permalink
no ALTER TABLE should return ER_NO_DEFAULT_FOR_FIELD
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Aug 15, 2023
1 parent a5776aa commit df0771c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 0 additions & 4 deletions mysql-test/main/alter_table_online.result
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ connection con2;
insert into t1 values (123), (456), (789);
set debug_sync= 'now SIGNAL end';
connection default;
Warnings:
Warning 1364 Field 'b' doesn't have a default value
Warning 1364 Field 'b' doesn't have a default value
Warning 1364 Field 'b' doesn't have a default value
select * from t1;
a b
5 0
Expand Down
19 changes: 19 additions & 0 deletions sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11534,6 +11534,22 @@ bool mysql_trans_commit_alter_copy_data(THD *thd)
}

#ifdef HAVE_REPLICATION
/*
locking ALTER TABLE doesn't issue ER_NO_DEFAULT_FOR_FIELD, so online
ALTER shouldn't either
*/
class Has_default_error_handler : public Internal_error_handler
{
public:
bool handle_condition(THD *, uint sql_errno, const char *,
Sql_condition::enum_warning_level *,
const char *, Sql_condition **)
{
return sql_errno == ER_NO_DEFAULT_FOR_FIELD;
}
};


static int online_alter_read_from_binlog(THD *thd, rpl_group_info *rgi,
Cache_flip_event_log *log)
{
Expand All @@ -11550,6 +11566,8 @@ static int online_alter_read_from_binlog(THD *thd, rpl_group_info *rgi,
thd_progress_report(thd, 0, my_b_write_tell(log_file));

Abort_on_warning_instant_set old_abort_on_warning(thd, 0);
Has_default_error_handler hdeh;
thd->push_internal_handler(&hdeh);
do
{
const auto *descr_event= rgi->rli->relay_log.description_event_for_exec;
Expand All @@ -11569,6 +11587,7 @@ static int online_alter_read_from_binlog(THD *thd, rpl_group_info *rgi,
thd_progress_report(thd, my_b_tell(log_file), thd->progress.max_counter);
DEBUG_SYNC(thd, "alter_table_online_progress");
} while(!error);
thd->pop_internal_handler();

return error;
}
Expand Down

0 comments on commit df0771c

Please sign in to comment.