summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei <andrei.elkin@mariadb.com>2021-12-09 16:49:41 +0200
committerAndrei <andrei.elkin@mariadb.com>2021-12-15 22:44:23 +0200
commit1dc04f9c7ef939a2b56ee869769ac3a5f1770c5c (patch)
tree7b6e69e67aa15de8ee2e0e8d3ade100f6ffc62da
parent4bcd709d79a74cce3f2dc638f67eb6da1f0e20d8 (diff)
downloadmariadb-git-1dc04f9c7ef939a2b56ee869769ac3a5f1770c5c.tar.gz
MDEV-11675. Open up support for algorithms instant and nocopy
The options, esp 'instant' make some '--error' noise which is mostly that this commit aims to handle.
-rw-r--r--mysql-test/suite/rpl/include/start_alter_options.inc162
-rw-r--r--mysql-test/suite/rpl/r/rpl_start_alter_instant.result66
-rw-r--r--mysql-test/suite/rpl/r/rpl_start_alter_options.result185
-rw-r--r--mysql-test/suite/rpl/r/rpl_start_alter_unsupported.result38
-rw-r--r--mysql-test/suite/rpl/t/rpl_start_alter_instant.test (renamed from mysql-test/suite/rpl/t/rpl_start_alter_unsupported.test)13
-rw-r--r--mysql-test/suite/rpl/t/rpl_start_alter_options.test16
-rw-r--r--sql/sql_table.cc8
7 files changed, 434 insertions, 54 deletions
diff --git a/mysql-test/suite/rpl/include/start_alter_options.inc b/mysql-test/suite/rpl/include/start_alter_options.inc
index 2dc662fa43c..72c7104b114 100644
--- a/mysql-test/suite/rpl/include/start_alter_options.inc
+++ b/mysql-test/suite/rpl/include/start_alter_options.inc
@@ -6,6 +6,8 @@
# $show_binlog
#
--let $force_needed= force ,
+# Error that is caused by a particular ALTER's option combination
+--let $alter_error = 0
--connection slave
stop slave;
@@ -28,10 +30,35 @@ create temporary table tmp_tbl(a int, b int) engine=innodb;
# | ADD [COLUMN] [IF NOT EXISTS] col_name column_definition
# [FIRST | AFTER col_name ]
# | ADD [COLUMN] [IF NOT EXISTS] (col_name column_definition,...)
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED
+}
+--error 0,$alter_error
--eval alter table t1 add column if not exists c int , $force_needed algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED
+}
+--error 0,$alter_error
--eval alter table t1 add column d int first, $force_needed algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_BAD_FIELD_ERROR
+}
+--error 0,$alter_error
--eval alter table t1 add column e int after c, $force_needed algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_BAD_FIELD_ERROR
+}
+--error 0,$alter_error
--eval alter table t1 add column f int after c, $force_needed add column g int first ,add column h char, algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY
+}
+--error 0,$alter_error
--eval alter table t1 drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, $force_needed algorithm=$alter_algorithm
if ($alter_algorithm == 'copy')
{
@@ -65,16 +92,56 @@ reset master;
# | DROP {INDEX|KEY} [IF EXISTS] index_name
# | DROP FOREIGN KEY [IF EXISTS] fk_symbol
# | DROP CONSTRAINT [IF EXISTS] constraint_name
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED
+}
+--error 0,$alter_error
--eval alter table t1 add column f int after b, $force_needed add column g int first ,add column h varchar(100), algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST
+}
+--error 0,$alter_error
--eval alter table t1 add index if not exists index_1(f), $force_needed algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY
+}
+--error 0,$alter_error
--eval alter table t1 drop index index_1, $force_needed algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST
+}
+--error 0,$alter_error
--eval alter table t1 add unique key unique_1(g), $force_needed algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY
+}
+--error 0,$alter_error
--eval alter table t1 drop index unique_1, $force_needed algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST
+}
+--error 0,$alter_error
--eval alter table t1 add fulltext key f_1(h), $force_needed algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY
+}
+--error 0,$alter_error
--eval alter table t1 drop column f, drop column g , $force_needed algorithm=$alter_algorithm
if ($alter_algorithm == 'copy')
{
--eval alter table tmp_tbl add column f int after b, $force_needed add column g int first ,add column h varchar(100), algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST
+}
+--error 0,$alter_error
--eval alter table tmp_tbl add index if not exists index_1(f), $force_needed algorithm=$alter_algorithm
--eval alter table tmp_tbl drop index index_1, $force_needed algorithm=$alter_algorithm
--eval alter table tmp_tbl add unique key unique_1(g), $force_needed algorithm=$alter_algorithm
@@ -84,8 +151,23 @@ if ($alter_algorithm == 'copy')
# | ADD [CONSTRAINT [symbol]] PRIMARY KEY
# [index_type] (index_col_name,...) [index_option] ...
# primary key changes cant use inplace algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST
+}
+--error 0,$alter_error
--eval alter table t1 add primary key(h), $force_needed algorithm=copy
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY
+}
+--error 0,$alter_error
--eval alter table t1 drop primary key, $force_needed algorithm=copy
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY
+}
+--error 0,$alter_error
--eval alter table t1 drop column h, $force_needed algorithm=copy
if ($alter_algorithm == 'copy')
{
@@ -106,10 +188,20 @@ reset master;
# | ADD PERIOD FOR SYSTEM_TIME (start_column_name, end_column_name)
# | ADD SYSTEM VERSIONING
# | DROP SYSTEM VERSIONING
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED
+}
+--error 0,$alter_error
--eval alter table t1 add column f varchar(100) after b, add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm
--eval alter table t1 add period for system_time(f,h)
--eval alter table t1 add system versioning
--eval alter table t1 drop system versioning
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY
+}
+--error 0,$alter_error
--eval alter table t1 drop column f, drop column g , drop column h, $force_needed algorithm=$alter_algorithm
--echo # show binlog and clear status
if ($alter_algorithm == 'copy')
@@ -132,11 +224,41 @@ reset master;
# [FIRST|AFTER col_name]
# | MODIFY [COLUMN] [IF EXISTS] col_name column_definition
# [FIRST | AFTER col_name]
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED
+}
+--error 0,$alter_error
--eval alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm ;
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_BAD_FIELD_ERROR
+}
+--error 0,$alter_error
--eval alter table t1 alter column f set default "****", $force_needed algorithm=$alter_algorithm ;
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_BAD_FIELD_ERROR
+}
+--error 0,$alter_error
--eval alter table t1 alter column f drop default, $force_needed algorithm=$alter_algorithm ;
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_BAD_FIELD_ERROR
+}
+--error 0,$alter_error
--eval alter table t1 change column g new_g char, $force_needed algorithm=copy;
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_BAD_FIELD_ERROR
+}
+--error 0,$alter_error
--eval alter table t1 modify column h varchar(100), $force_needed algorithm=copy;
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY
+}
+--error 0,$alter_error
--eval alter table t1 drop column new_g ,drop column f, drop column h, $force_needed algorithm=$alter_algorithm ;
if ($alter_algorithm == 'copy')
{
@@ -167,17 +289,47 @@ reset master;
# | [DEFAULT] COLLATE [=] collation_name
# | DISCARD TABLESPACE
# | IMPORT TABLESPACE
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED
+}
+--error 0,$alter_error
--eval alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_KEY_COLUMN_DOES_NOT_EXIST
+}
+--error 0,$alter_error
--eval alter table t1 add index if not exists index_1(f), $force_needed algorithm=$alter_algorithm
--eval alter table t1 disable keys, $force_needed algorithm=copy
--eval alter table t1 enable keys, $force_needed algorithm=copy
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED
+}
+--error 0,$alter_error
--eval alter table t1 rename t2, $force_needed algorithm=$alter_algorithm
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_NO_SUCH_TABLE
+}
+--error 0,$alter_error
--eval alter table t2 rename t1, $force_needed algorithm=$alter_algorithm
--eval alter table a1 order by a
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_BAD_FIELD_ERROR
+}
+--error 0,$alter_error
--eval alter table t1 rename column f to new_f, $force_needed algorithm=copy
--eval alter table t1 convert to character set 'utf8', $force_needed algorithm=copy
--eval alter table t1 default character set 'utf8', $force_needed algorithm=copy
--eval alter table t1 default collate 'utf8_icelandic_ci', $force_needed algorithm=copy
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY
+}
+--error 0,$alter_error
--eval alter table t1 drop column new_f ,drop column g, drop column h, $force_needed algorithm=$alter_algorithm
if ($alter_algorithm == 'copy')
{
@@ -207,9 +359,19 @@ reset master;
# Only add partition and remove partition is tested
# | ADD PARTITION (partition_definition)
# | REMOVE PARTITIONING
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_ALTER_OPERATION_NOT_SUPPORTED
+}
+--error 0,$alter_error
--eval alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, $force_needed algorithm=$alter_algorithm
--eval alter table t1 partition by hash(b) partitions 8
--eval alter table t1 remove partitioning
+if (`select '$alter_algorithm' = 'instant' or '$alter_algorithm' = 'nocopy'`)
+{
+ --let $alter_error=ER_CANT_DROP_FIELD_OR_KEY
+}
+--error 0,$alter_error
--eval alter table t1 drop column f ,drop column g, drop column h, $force_needed algorithm=$alter_algorithm
if ($alter_algorithm == 'copy')
{
diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_instant.result b/mysql-test/suite/rpl/r/rpl_start_alter_instant.result
new file mode 100644
index 00000000000..793ef74d6bb
--- /dev/null
+++ b/mysql-test/suite/rpl/r/rpl_start_alter_instant.result
@@ -0,0 +1,66 @@
+include/master-slave.inc
+[connection master]
+connection master;
+set binlog_alter_two_phase=true;
+CREATE OR REPLACE TABLE tab (
+a int PRIMARY KEY,
+b varchar(50),
+c varchar(50)
+) CHARACTER SET=latin1 engine=innodb;
+SET SESSION alter_algorithm='INSTANT';
+ALTER TABLE tab MODIFY COLUMN b varchar(100);
+SET SESSION alter_algorithm='NOCOPY';
+ALTER TABLE tab MODIFY COLUMN c varchar(100);
+SHOW CREATE TABLE tab;
+Table Create Table
+tab CREATE TABLE `tab` (
+ `a` int(11) NOT NULL,
+ `b` varchar(100) DEFAULT NULL,
+ `c` varchar(100) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+master-bin.000001 # Gtid # # GTID #-#-#
+master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE tab (
+a int PRIMARY KEY,
+b varchar(50),
+c varchar(50)
+) CHARACTER SET=latin1 engine=innodb
+master-bin.000001 # Gtid # # GTID #-#-# START ALTER
+master-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN b varchar(100)
+master-bin.000001 # Gtid # # GTID #-#-# COMMIT ALTER id=#
+master-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN b varchar(100)
+master-bin.000001 # Gtid # # GTID #-#-# START ALTER
+master-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN c varchar(100)
+master-bin.000001 # Gtid # # GTID #-#-# COMMIT ALTER id=#
+master-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN c varchar(100)
+connection slave;
+SHOW CREATE TABLE tab;
+Table Create Table
+tab CREATE TABLE `tab` (
+ `a` int(11) NOT NULL,
+ `b` varchar(100) DEFAULT NULL,
+ `c` varchar(100) DEFAULT NULL,
+ PRIMARY KEY (`a`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1
+include/show_binlog_events.inc
+Log_name Pos Event_type Server_id End_log_pos Info
+slave-bin.000001 # Gtid # # GTID #-#-#
+slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE tab (
+a int PRIMARY KEY,
+b varchar(50),
+c varchar(50)
+) CHARACTER SET=latin1 engine=innodb
+slave-bin.000001 # Gtid # # GTID #-#-# START ALTER
+slave-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN b varchar(100)
+slave-bin.000001 # Gtid # # GTID #-#-# COMMIT ALTER id=#
+slave-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN b varchar(100)
+slave-bin.000001 # Gtid # # GTID #-#-# START ALTER
+slave-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN c varchar(100)
+slave-bin.000001 # Gtid # # GTID #-#-# COMMIT ALTER id=#
+slave-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN c varchar(100)
+connection master;
+DROP TABLE tab;
+connection slave;
+include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_options.result b/mysql-test/suite/rpl/r/rpl_start_alter_options.result
index 704c88263ca..30854b12be1 100644
--- a/mysql-test/suite/rpl/r/rpl_start_alter_options.result
+++ b/mysql-test/suite/rpl/r/rpl_start_alter_options.result
@@ -311,6 +311,187 @@ set global slave_parallel_threads = 0;;
set global slave_parallel_mode = optimistic;;
set global gtid_strict_mode = 0;;
include/start_slave.inc
-# TODO remove support for nocopy and instant
-# and how to verify results
+# Prove formal support for nocopy and instant
+connection slave;
+stop slave;
+change master to master_use_gtid= current_pos;
+SET GLOBAL slave_parallel_threads=4;
+set global slave_parallel_mode=optimistic;
+set global gtid_strict_mode=1;
+start slave;
+connection master;
+set binlog_alter_two_phase=true;
+create table t1(a int , b int) engine=innodb;
+create table a1(a int , b int) engine=myisam;
+create temporary table tmp_tbl(a int, b int) engine=innodb;
+alter table t1 add column if not exists c int , force , algorithm=instant;
+alter table t1 add column d int first, force , algorithm=instant;
+alter table t1 add column e int after c, force , algorithm=instant;
+alter table t1 add column f int after c, force , add column g int first ,add column h char, algorithm=instant;
+alter table t1 drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, force , algorithm=instant;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+alter table t1 add column f int after b, force , add column g int first ,add column h varchar(100), algorithm=instant;
+alter table t1 add index if not exists index_1(f), force , algorithm=instant;
+alter table t1 drop index index_1, force , algorithm=instant;
+alter table t1 add unique key unique_1(g), force , algorithm=instant;
+alter table t1 drop index unique_1, force , algorithm=instant;
+alter table t1 add fulltext key f_1(h), force , algorithm=instant;
+alter table t1 drop column f, drop column g , force , algorithm=instant;
+alter table t1 add primary key(h), force , algorithm=copy;
+alter table t1 drop primary key, force , algorithm=copy;
+alter table t1 drop column h, force , algorithm=copy;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+alter table t1 add column f varchar(100) after b, add column g varchar(100) first ,add column h char, force , algorithm=instant;
+alter table t1 add period for system_time(f,h);
+alter table t1 add system versioning;
+alter table t1 drop system versioning;
+alter table t1 drop column f, drop column g , drop column h, force , algorithm=instant;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=instant ;;
+alter table t1 alter column f set default "****", force , algorithm=instant ;;
+alter table t1 alter column f drop default, force , algorithm=instant ;;
+alter table t1 change column g new_g char, force , algorithm=copy;;
+alter table t1 modify column h varchar(100), force , algorithm=copy;;
+alter table t1 drop column new_g ,drop column f, drop column h, force , algorithm=instant ;;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=instant;
+alter table t1 add index if not exists index_1(f), force , algorithm=instant;
+alter table t1 disable keys, force , algorithm=copy;
+Warnings:
+Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option
+alter table t1 enable keys, force , algorithm=copy;
+Warnings:
+Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option
+alter table t1 rename t2, force , algorithm=instant;
+alter table t2 rename t1, force , algorithm=instant;
+alter table a1 order by a;
+alter table t1 rename column f to new_f, force , algorithm=copy;
+alter table t1 convert to character set 'utf8', force , algorithm=copy;
+alter table t1 default character set 'utf8', force , algorithm=copy;
+alter table t1 default collate 'utf8_icelandic_ci', force , algorithm=copy;
+alter table t1 drop column new_f ,drop column g, drop column h, force , algorithm=instant;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=instant;
+alter table t1 partition by hash(b) partitions 8;
+alter table t1 remove partitioning;
+alter table t1 drop column f ,drop column g, drop column h, force , algorithm=instant;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+connection master;
+drop table t1, a1;
+drop temporary table tmp_tbl;
+connection slave;
+include/stop_slave.inc
+set global slave_parallel_threads = 0;;
+set global slave_parallel_mode = optimistic;;
+set global gtid_strict_mode = 0;;
+include/start_slave.inc
+connection slave;
+stop slave;
+change master to master_use_gtid= current_pos;
+SET GLOBAL slave_parallel_threads=4;
+set global slave_parallel_mode=optimistic;
+set global gtid_strict_mode=1;
+start slave;
+connection master;
+set binlog_alter_two_phase=true;
+create table t1(a int , b int) engine=innodb;
+create table a1(a int , b int) engine=myisam;
+create temporary table tmp_tbl(a int, b int) engine=innodb;
+alter table t1 add column if not exists c int , force , algorithm=nocopy;
+alter table t1 add column d int first, force , algorithm=nocopy;
+alter table t1 add column e int after c, force , algorithm=nocopy;
+alter table t1 add column f int after c, force , add column g int first ,add column h char, algorithm=nocopy;
+alter table t1 drop column c, drop column d, drop column e, drop column f, drop column g , drop column h, force , algorithm=nocopy;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+alter table t1 add column f int after b, force , add column g int first ,add column h varchar(100), algorithm=nocopy;
+alter table t1 add index if not exists index_1(f), force , algorithm=nocopy;
+alter table t1 drop index index_1, force , algorithm=nocopy;
+alter table t1 add unique key unique_1(g), force , algorithm=nocopy;
+alter table t1 drop index unique_1, force , algorithm=nocopy;
+alter table t1 add fulltext key f_1(h), force , algorithm=nocopy;
+alter table t1 drop column f, drop column g , force , algorithm=nocopy;
+alter table t1 add primary key(h), force , algorithm=copy;
+alter table t1 drop primary key, force , algorithm=copy;
+alter table t1 drop column h, force , algorithm=copy;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+alter table t1 add column f varchar(100) after b, add column g varchar(100) first ,add column h char, force , algorithm=nocopy;
+alter table t1 add period for system_time(f,h);
+alter table t1 add system versioning;
+alter table t1 drop system versioning;
+alter table t1 drop column f, drop column g , drop column h, force , algorithm=nocopy;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=nocopy ;;
+alter table t1 alter column f set default "****", force , algorithm=nocopy ;;
+alter table t1 alter column f drop default, force , algorithm=nocopy ;;
+alter table t1 change column g new_g char, force , algorithm=copy;;
+alter table t1 modify column h varchar(100), force , algorithm=copy;;
+alter table t1 drop column new_g ,drop column f, drop column h, force , algorithm=nocopy ;;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=nocopy;
+alter table t1 add index if not exists index_1(f), force , algorithm=nocopy;
+alter table t1 disable keys, force , algorithm=copy;
+Warnings:
+Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option
+alter table t1 enable keys, force , algorithm=copy;
+Warnings:
+Note 1031 Storage engine InnoDB of the table `test`.`t1` doesn't have this option
+alter table t1 rename t2, force , algorithm=nocopy;
+alter table t2 rename t1, force , algorithm=nocopy;
+alter table a1 order by a;
+alter table t1 rename column f to new_f, force , algorithm=copy;
+alter table t1 convert to character set 'utf8', force , algorithm=copy;
+alter table t1 default character set 'utf8', force , algorithm=copy;
+alter table t1 default collate 'utf8_icelandic_ci', force , algorithm=copy;
+alter table t1 drop column new_f ,drop column g, drop column h, force , algorithm=nocopy;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+alter table t1 add column f varchar(100) after b,add column g varchar(100) first ,add column h char, force , algorithm=nocopy;
+alter table t1 partition by hash(b) partitions 8;
+alter table t1 remove partitioning;
+alter table t1 drop column f ,drop column g, drop column h, force , algorithm=nocopy;
+# show binlog and clear status
+connection slave;
+reset master;
+connection master;
+connection master;
+drop table t1, a1;
+drop temporary table tmp_tbl;
+connection slave;
+include/stop_slave.inc
+set global slave_parallel_threads = 0;;
+set global slave_parallel_mode = optimistic;;
+set global gtid_strict_mode = 0;;
+include/start_slave.inc
include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/r/rpl_start_alter_unsupported.result b/mysql-test/suite/rpl/r/rpl_start_alter_unsupported.result
deleted file mode 100644
index a538cb0eb9f..00000000000
--- a/mysql-test/suite/rpl/r/rpl_start_alter_unsupported.result
+++ /dev/null
@@ -1,38 +0,0 @@
-include/master-slave.inc
-[connection master]
-connection master;
-set binlog_alter_two_phase=true;
-CREATE OR REPLACE TABLE tab (
-a int PRIMARY KEY,
-b varchar(50),
-c varchar(50)
-) CHARACTER SET=latin1 engine=innodb;
-SET SESSION alter_algorithm='INSTANT';
-ALTER TABLE tab MODIFY COLUMN c varchar(100);
-drop table tab;
-include/show_binlog_events.inc
-Log_name Pos Event_type Server_id End_log_pos Info
-master-bin.000001 # Gtid # # GTID #-#-#
-master-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE tab (
-a int PRIMARY KEY,
-b varchar(50),
-c varchar(50)
-) CHARACTER SET=latin1 engine=innodb
-master-bin.000001 # Gtid # # GTID #-#-#
-master-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN c varchar(100)
-master-bin.000001 # Gtid # # GTID #-#-#
-master-bin.000001 # Query # # use `test`; DROP TABLE `tab` /* generated by server */
-connection slave;
-include/show_binlog_events.inc
-Log_name Pos Event_type Server_id End_log_pos Info
-slave-bin.000001 # Gtid # # GTID #-#-#
-slave-bin.000001 # Query # # use `test`; CREATE OR REPLACE TABLE tab (
-a int PRIMARY KEY,
-b varchar(50),
-c varchar(50)
-) CHARACTER SET=latin1 engine=innodb
-slave-bin.000001 # Gtid # # GTID #-#-#
-slave-bin.000001 # Query # # use `test`; ALTER TABLE tab MODIFY COLUMN c varchar(100)
-slave-bin.000001 # Gtid # # GTID #-#-#
-slave-bin.000001 # Query # # use `test`; DROP TABLE IF EXISTS `tab` /* generated by server */
-include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_unsupported.test b/mysql-test/suite/rpl/t/rpl_start_alter_instant.test
index 078be1face4..ecb62e04fad 100644
--- a/mysql-test/suite/rpl/t/rpl_start_alter_unsupported.test
+++ b/mysql-test/suite/rpl/t/rpl_start_alter_instant.test
@@ -1,3 +1,5 @@
+# MDEV-11675
+# Prove that "fast" ALTER options also combine with @@binlog_alter_two_phase.
--source include/have_innodb.inc
--source include/master-slave.inc
@@ -10,10 +12,19 @@ CREATE OR REPLACE TABLE tab (
) CHARACTER SET=latin1 engine=innodb;
SET SESSION alter_algorithm='INSTANT';
+ALTER TABLE tab MODIFY COLUMN b varchar(100);
+SET SESSION alter_algorithm='NOCOPY';
ALTER TABLE tab MODIFY COLUMN c varchar(100);
-drop table tab;
+SHOW CREATE TABLE tab;
--source include/show_binlog_events.inc
--sync_slave_with_master
+SHOW CREATE TABLE tab;
--source include/show_binlog_events.inc
+
+--connection master
+DROP TABLE tab;
+
+--sync_slave_with_master
+
--source include/rpl_end.inc
diff --git a/mysql-test/suite/rpl/t/rpl_start_alter_options.test b/mysql-test/suite/rpl/t/rpl_start_alter_options.test
index ecf6829aada..12125b49122 100644
--- a/mysql-test/suite/rpl/t/rpl_start_alter_options.test
+++ b/mysql-test/suite/rpl/t/rpl_start_alter_options.test
@@ -20,14 +20,12 @@
--let $alter_algorithm= copy
--source include/start_alter_options.inc
---echo # TODO remove support for nocopy and instant
---echo # and how to verify results
-#--let $alter_algorithm= nocopy
-#--let $show_binlog= true
-#--source include/start_alter_options.inc
-
-#--let $alter_algorithm= instant
-#--let $show_binlog= true
-#--source include/start_alter_options.inc
+--echo # Prove formal support for nocopy and instant
+--let $alter_algorithm= instant
+--source include/start_alter_options.inc
+
+--let $alter_algorithm= nocopy
+--source include/start_alter_options.inc
+
--source include/rpl_end.inc
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index d891b739591..643000516d8 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -7476,10 +7476,10 @@ static bool mysql_inplace_alter_table(THD *thd,
MDL_SHARED_NO_WRITE,
thd->variables.lock_wait_timeout))
goto cleanup;
- // If alter_algorithm == Instant.
- if ((table->s->tmp_table == NO_TMP_TABLE || table->s->table_creation_was_logged
- || start_alter_id)
- && alter_info->algorithm(thd) != Alter_info::ALTER_TABLE_ALGORITHM_INSTANT)
+
+ DBUG_ASSERT(table->s->tmp_table == NO_TMP_TABLE || start_alter_id == 0);
+
+ if (table->s->tmp_table == NO_TMP_TABLE)
if (write_bin_log_start_alter(thd, partial_alter, start_alter_id,
if_exists, &table->s->mem_root))
goto cleanup;