Skip to content

Commit 9e8e215

Browse files
committed
MDEV-37903 ALTER TABLE ... ENGINE=MRG_MyISAM is not binlogged as DDL
Fixed by marking MRG_MYISAM changes explicitly as a DDL
1 parent e6a1872 commit 9e8e215

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--timezone=GMT-3

mysql-test/main/merge_alter.result

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
SET timestamp=1000000000;
2+
RESET MASTER;
3+
CREATE TABLE t (i1 int, i2 int, pk int) ;
4+
CREATE TABLE t3 LIKE t ;
5+
ALTER TABLE t3 ENGINE = MERGE UNION (t1,t2);
6+
insert into t values(1,1,1);
7+
flush logs;
8+
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/;
9+
/*!40019 SET @@session.max_delayed_threads=0*/;
10+
/*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/;
11+
DELIMITER /*!*/;
12+
# at #
13+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Start: binlog v 4, server v #.##.## created 010909 4:46:40 at startup
14+
ROLLBACK/*!*/;
15+
# at #
16+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Gtid list []
17+
# at #
18+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Binlog checkpoint master-bin.000001
19+
# at #
20+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-1 ddl
21+
/*M!100101 SET @@session.skip_parallel_replication=0*//*!*/;
22+
/*M!100001 SET @@session.gtid_domain_id=0*//*!*/;
23+
/*M!100001 SET @@session.server_id=1*//*!*/;
24+
/*M!100001 SET @@session.gtid_seq_no=1*//*!*/;
25+
# at #
26+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
27+
use `test`/*!*/;
28+
SET TIMESTAMP=1000000000/*!*/;
29+
SET @@session.pseudo_thread_id=#/*!*/;
30+
SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1, @@session.check_constraint_checks=1, @@session.sql_if_exists=0, @@session.explicit_defaults_for_timestamp=1, @@session.system_versioning_insert_history=0/*!*/;
31+
SET @@session.sql_mode=1411383296/*!*/;
32+
SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/;
33+
/*!\C latin1 *//*!*/;
34+
SET @@session.character_set_client=X,@@session.collation_connection=X,@@session.collation_server=X/*!*/;
35+
SET @@session.lc_time_names=0/*!*/;
36+
SET @@session.collation_database=DEFAULT/*!*/;
37+
CREATE TABLE t (i1 int, i2 int, pk int)
38+
/*!*/;
39+
# at #
40+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-2 ddl
41+
/*M!100001 SET @@session.gtid_seq_no=2*//*!*/;
42+
# at #
43+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
44+
SET TIMESTAMP=1000000000/*!*/;
45+
CREATE TABLE t3 LIKE t
46+
/*!*/;
47+
# at #
48+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-3 ddl
49+
/*M!100001 SET @@session.gtid_seq_no=3*//*!*/;
50+
# at #
51+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
52+
SET TIMESTAMP=1000000000/*!*/;
53+
ALTER TABLE t3 ENGINE = MERGE UNION (t1,t2)
54+
/*!*/;
55+
# at #
56+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-4
57+
/*M!100001 SET @@session.gtid_seq_no=4*//*!*/;
58+
START TRANSACTION
59+
/*!*/;
60+
# at #
61+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
62+
SET TIMESTAMP=1000000000/*!*/;
63+
insert into t values(1,1,1)
64+
/*!*/;
65+
# at #
66+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
67+
SET TIMESTAMP=1000000000/*!*/;
68+
COMMIT
69+
/*!*/;
70+
# at #
71+
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Rotate to master-bin.000002 pos: 4
72+
DELIMITER ;
73+
# End of log file
74+
ROLLBACK /* added by mysqlbinlog */;
75+
/*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/;
76+
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/;
77+
drop table t,t3;

mysql-test/main/merge_alter.test

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--source include/have_binlog_format_mixed.inc
2+
3+
# MDEV-37903 ALTER TABLE ... ENGINE=MRG_MyISAM is not binlogged as DDL
4+
5+
# Fix timestamp to avoid varying results.
6+
SET timestamp=1000000000;
7+
8+
RESET MASTER;
9+
10+
CREATE TABLE t (i1 int, i2 int, pk int) ;
11+
CREATE TABLE t3 LIKE t ;
12+
ALTER TABLE t3 ENGINE = MERGE UNION (t1,t2);
13+
insert into t values(1,1,1);
14+
15+
flush logs;
16+
let $MYSQLD_DATADIR= `select @@datadir`;
17+
--replace_regex /server id [0-9]*/server id #/ /server v [^ ]*/server v #.##.##/ /exec_time=[0-9]*/exec_time=#/ /thread_id=[0-9]*/thread_id=#/ /table id [0-9]*/table id #/ /mapped to number [0-9]*/mapped to number #/ /end_log_pos [0-9]*/end_log_pos #/ /# at [0-9]*/# at #/ /CRC32 0x[0-9a-f]*/CRC32 XXX/ /collation_server=[0-9]+/collation_server=X/ /character_set_client=[a-zA-Z0-9]+/character_set_client=X/ /collation_connection=[0-9]+/collation_connection=X/ /xid=\d*/xid=<xid>/
18+
--exec $MYSQL_BINLOG --base64-output=decode-rows -v -v $MYSQLD_DATADIR/master-bin.000001
19+
20+
drop table t,t3;

sql/sql_table.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11593,6 +11593,7 @@ do_continue:;
1159311593
}
1159411594
else
1159511595
{
11596+
/* MERGE TABLE */
1159611597
if (!table->s->tmp_table &&
1159711598
wait_while_table_is_used(thd, table, HA_EXTRA_FORCE_REOPEN))
1159811599
goto err_new_table_cleanup;
@@ -11601,6 +11602,8 @@ do_continue:;
1160111602
alter_info->keys_onoff);
1160211603
if (trans_commit_stmt(thd) || trans_commit_implicit(thd))
1160311604
goto err_new_table_cleanup;
11605+
/* Ensure that the ALTER is binlogged as a DDL */
11606+
thd->transaction->stmt.mark_trans_did_ddl();
1160411607
}
1160511608
thd->count_cuted_fields= CHECK_FIELD_IGNORE;
1160611609

0 commit comments

Comments
 (0)