summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei <andrei.elkin@mariadb.com>2022-01-17 12:54:10 +0200
committerAndrei <andrei.elkin@mariadb.com>2022-01-17 12:54:10 +0200
commit9e5ea2ef4a9e38748a025ac0e8c03d6a5c737376 (patch)
treea440cb21099e552aa33d9edbc2259b26fd64e2f4
parent3aeac791220a45046f57c7351c58b6a14921addc (diff)
downloadmariadb-git-9e5ea2ef4a9e38748a025ac0e8c03d6a5c737376.tar.gz
MDEV-27365 CREATE-or-REPLACE bilogged without DDL flag
Former commit did not fix a use case of repeated CoR (added to the test file now). Also the former fixes are refactored to cover two use cases with one code branch change (in implicit commit).
-rw-r--r--mysql-test/suite/binlog/r/binlog_parallel_replication_ddl.result5
-rw-r--r--mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test1
-rw-r--r--sql/handler.h4
-rw-r--r--sql/sql_sequence.cc6
-rw-r--r--sql/transaction.cc6
-rw-r--r--sql/transaction.h2
6 files changed, 12 insertions, 12 deletions
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 34d8bbf5999..606562e853b 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,9 @@
RESET MASTER;
CREATE OR REPLACE SEQUENCE s1;
+CREATE OR REPLACE SEQUENCE s1;
DROP SEQUENCE s1;
FLUSH LOGS;
-FOUND 2 /GTID [0-9]+-[0-9]+-[0-9]+/ in mysqlbinlog.sql
+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 d861ecc96df..0ebff987292 100644
--- a/mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test
+++ b/mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test
@@ -9,6 +9,7 @@ RESET MASTER;
# MDEV-27365 CREATE-or-REPLACE SEQUENCE bilogged without DDL flag
# Prove it is logged with the DDL flag.
CREATE OR REPLACE SEQUENCE s1;
+CREATE OR REPLACE SEQUENCE s1;
# This one has been always correct.
DROP SEQUENCE s1;
diff --git a/sql/handler.h b/sql/handler.h
index fe61666bf20..5548796c964 100644
--- a/sql/handler.h
+++ b/sql/handler.h
@@ -1865,10 +1865,10 @@ struct THD_TRANS
*/
bool modified_non_trans_table;
- void reset() {
+ void reset(uint unsafe_flags_arg= 0) {
no_2pc= FALSE;
modified_non_trans_table= FALSE;
- m_unsafe_rollback_flags= 0;
+ m_unsafe_rollback_flags= unsafe_flags_arg;
}
bool is_empty() const { return ha_list == NULL; }
THD_TRANS() {} /* Remove gcc warning */
diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc
index b32f1294bec..0aedcbfeb4e 100644
--- a/sql/sql_sequence.cc
+++ b/sql/sql_sequence.cc
@@ -366,14 +366,10 @@ bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *org_table_list)
seq->reserved_until= seq->start;
error= seq->write_initial_sequence(table);
{
- uint save_unsafe_rollback_flags=
- thd->transaction->stmt.m_unsafe_rollback_flags;
if (trans_commit_stmt(thd))
error= 1;
- thd->transaction->stmt.m_unsafe_rollback_flags=
- save_unsafe_rollback_flags;
}
- if (trans_commit_implicit(thd))
+ if (trans_commit_implicit(thd, true))
error= 1;
if (!temporary_table)
diff --git a/sql/transaction.cc b/sql/transaction.cc
index 958abebfc47..f1d86bd3f5e 100644
--- a/sql/transaction.cc
+++ b/sql/transaction.cc
@@ -303,9 +303,11 @@ bool trans_commit(THD *thd)
@retval TRUE Failure
*/
-bool trans_commit_implicit(THD *thd)
+bool trans_commit_implicit(THD *thd, bool save_restore)
{
bool res= FALSE;
+ uint save_unsafe_rollback_flags= !save_restore ? 0 :
+ thd->transaction->all.m_unsafe_rollback_flags;
DBUG_ENTER("trans_commit_implicit");
if (trans_check(thd))
@@ -330,7 +332,7 @@ bool trans_commit_implicit(THD *thd)
}
thd->variables.option_bits&= ~(OPTION_BEGIN | OPTION_KEEP_LOG);
- thd->transaction->all.reset();
+ thd->transaction->all.reset(save_unsafe_rollback_flags);
/* The transaction should be marked as complete in P_S. */
DBUG_ASSERT(thd->m_transaction_psi == NULL);
diff --git a/sql/transaction.h b/sql/transaction.h
index fe0129fa8bc..7f7dd99cb8e 100644
--- a/sql/transaction.h
+++ b/sql/transaction.h
@@ -28,7 +28,7 @@ void trans_track_end_trx(THD *thd);
bool trans_begin(THD *thd, uint flags= 0);
bool trans_commit(THD *thd);
-bool trans_commit_implicit(THD *thd);
+bool trans_commit_implicit(THD *thd, bool save_restore= false);
bool trans_rollback(THD *thd);
bool trans_rollback_implicit(THD *thd);