diff --git a/mysql-test/suite/binlog/r/binlog_parallel_replication_ddl.result b/mysql-test/suite/binlog/r/binlog_parallel_replication_ddl.result index 34d8bbf5999a4..2f155fad721ad 100644 --- a/mysql-test/suite/binlog/r/binlog_parallel_replication_ddl.result +++ b/mysql-test/suite/binlog/r/binlog_parallel_replication_ddl.result @@ -1,8 +1,13 @@ +CREATE TABLE t1 (i1 int, i2 int, pk int); +CREATE TABLE t2 (i1 int, i2 int, pk int); +CREATE TABLE t3 LIKE t1; RESET MASTER; +ALTER TABLE t3 ENGINE = MERGE UNION (t1,t2); CREATE OR REPLACE SEQUENCE s1; DROP SEQUENCE s1; FLUSH LOGS; -FOUND 2 /GTID [0-9]+-[0-9]+-[0-9]+/ in mysqlbinlog.sql +DROP TABLE t3,t2,t1; +FOUND 3 /GTID [0-9]+-[0-9]+-[0-9]+/ in mysqlbinlog.sql The same as above number of samples must be found: -FOUND 2 /GTID [0-9]+-[0-9]+-[0-9]+ ddl/ in mysqlbinlog.sql +FOUND 3 /GTID [0-9]+-[0-9]+-[0-9]+ ddl/ in mysqlbinlog.sql End of the tests diff --git a/mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test b/mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test index d861ecc96df82..8c9249e1849d2 100644 --- a/mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test +++ b/mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test @@ -4,7 +4,14 @@ --source include/have_log_bin.inc --source include/have_binlog_format_mixed.inc +CREATE TABLE t1 (i1 int, i2 int, pk int); +CREATE TABLE t2 (i1 int, i2 int, pk int); +CREATE TABLE t3 LIKE t1; + RESET MASTER; +# MDEV-38623 ALTER TABLE ... ENGINE = MERGE is binlogged w/o ddl tag. +# Prove the DDL tag is in place. +ALTER TABLE t3 ENGINE = MERGE UNION (t1,t2); # MDEV-27365 CREATE-or-REPLACE SEQUENCE bilogged without DDL flag # Prove it is logged with the DDL flag. @@ -14,6 +21,9 @@ CREATE OR REPLACE SEQUENCE s1; DROP SEQUENCE s1; FLUSH LOGS; +# cleanup +DROP TABLE t3,t2,t1; + --let $MYSQLD_DATADIR= `select @@datadir` --exec $MYSQL_BINLOG --base64-output=decode-rows $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog.sql diff --git a/sql/misc_utils.h b/sql/misc_utils.h new file mode 100644 index 0000000000000..990907da0165f --- /dev/null +++ b/sql/misc_utils.h @@ -0,0 +1,31 @@ +/* Copyright (c) 2026, MariaDB Corporation + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#ifndef MISC_UTILS_INCLUDED +#define MISC_UTILS_INCLUDED + +template +class StateGuard { +public: + explicit StateGuard(T& var) : ref(var), value(var) {} + ~StateGuard() { ref = value; } + + StateGuard(const StateGuard&) = delete; + StateGuard& operator=(const StateGuard&) = delete; + +private: + T& ref; + T value; +}; +#endif /* MISC_UTILS_INCLUDED */ diff --git a/sql/sql_table.cc b/sql/sql_table.cc index a32bd87b2230b..502352642cebc 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -92,6 +92,7 @@ class Enable_wsrep_ctas_guard #ifdef _WIN32 #include #endif +#include "misc_utils.h" const LEX_CSTRING primary_key_name= { STRING_WITH_LEN("PRIMARY") }; static const LEX_CSTRING generated_by_server= @@ -11022,6 +11023,7 @@ do_continue:; THD_STAGE_INFO(thd, stage_manage_keys); alter_table_manage_keys(table, table->file->indexes_are_disabled(), alter_info->keys_onoff); + StateGuard g(thd->transaction->stmt.m_unsafe_rollback_flags); if (trans_commit_stmt(thd) || trans_commit_implicit(thd)) goto err_new_table_cleanup; }