From 93049e3de693767b9905f5f55df72c7dde32f8c0 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 30 Jun 2022 12:12:00 +0200 Subject: [PATCH] MDEV-28959 Online alter ignores strict table mode * don't disable warnings when catching up * do propagate warnings up like copy_data_between_tables() does --- .../main/alter_table_online_debug.result | 30 +++++++++++++++++++ mysql-test/main/alter_table_online_debug.test | 26 ++++++++++++++++ sql/sql_table.cc | 4 +-- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/alter_table_online_debug.result b/mysql-test/main/alter_table_online_debug.result index 31d35c08a17..274b16547d3 100644 --- a/mysql-test/main/alter_table_online_debug.result +++ b/mysql-test/main/alter_table_online_debug.result @@ -582,3 +582,33 @@ set debug_sync= 'reset'; drop table t1; drop table t2; drop table t3; +# +# MDEV-28959 Online alter ignores strict table mode +# +create table t1 (a int); +insert into t1 values (1),(2),(3); +set debug_sync= 'now wait_for downgraded'; +connection con2; +set sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES'; +set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit'; +alter table t1 modify a int not null, algorithm=copy, lock=none; +connection default; +insert into t1 values (null),(null); +set debug_sync= 'now signal goforit'; +connection con2; +ERROR 01000: Data truncated for column 'a' at row 4 +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` int(11) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci +select * from t1; +a +1 +2 +3 +NULL +NULL +connection default; +drop table t1; +set debug_sync= reset; diff --git a/mysql-test/main/alter_table_online_debug.test b/mysql-test/main/alter_table_online_debug.test index 44e5d1ec24a..62657cb240a 100644 --- a/mysql-test/main/alter_table_online_debug.test +++ b/mysql-test/main/alter_table_online_debug.test @@ -720,3 +720,29 @@ set debug_sync= 'reset'; drop table t1; drop table t2; drop table t3; + +--echo # +--echo # MDEV-28959 Online alter ignores strict table mode +--echo # +create table t1 (a int); +insert into t1 values (1),(2),(3); +--send set debug_sync= 'now wait_for downgraded' + +--connection con2 +set sql_mode='STRICT_TRANS_TABLES,STRICT_ALL_TABLES'; +set debug_sync= 'alter_table_online_downgraded signal downgraded wait_for goforit'; +--send alter table t1 modify a int not null, algorithm=copy, lock=none + +--connection default +--reap +insert into t1 values (null),(null); +set debug_sync= 'now signal goforit'; + +--connection con2 +--error WARN_DATA_TRUNCATED +--reap +show create table t1; +select * from t1; +--connection default +drop table t1; +set debug_sync= reset; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 80ceebfe277..389d288a75e 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -11566,7 +11566,6 @@ 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 @@ -11580,7 +11579,8 @@ static int online_alter_read_from_binlog(THD *thd, rpl_group_info *rgi, thd->set_n_backup_active_arena(&event_arena, &backup_arena); error= ev->apply_event(rgi); thd->restore_active_arena(&event_arena, &backup_arena); - + if (thd->is_error()) + error= 1; event_arena.free_items(); free_root(&event_mem_root, MYF(MY_KEEP_PREALLOC)); if (ev != rgi->rli->relay_log.description_event_for_exec)