From 952f06aa8bcfad6c62d4c2bbc15ffe6e05f01008 Mon Sep 17 00:00:00 2001 From: Thirunarayanan Balathandayuthapani Date: Wed, 20 Sep 2023 19:45:24 +0530 Subject: [PATCH] MDEV-29989 binlog_do_db option breaks versioning table Problem: ========= During commit, server calls prepare_commit_versioned to determine the transaction modified system-versioned data. Due to binlog_do_db option, we disable the binlog for the statement. But prepare_commit_versioned() is being called only when binlog is enabled for the statement. Fix: === prepare_commit_versioned() should happen irrespective of binlog state. So if the server has any read-write operation then we should call prepare_commit_versioned(). --- mysql-test/suite/versioning/t/trx_id.opt | 2 ++ sql/handler.cc | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 mysql-test/suite/versioning/t/trx_id.opt diff --git a/mysql-test/suite/versioning/t/trx_id.opt b/mysql-test/suite/versioning/t/trx_id.opt new file mode 100644 index 00000000000..f900254f5d0 --- /dev/null +++ b/mysql-test/suite/versioning/t/trx_id.opt @@ -0,0 +1,2 @@ +--log_bin +--binlog_do_db=foo diff --git a/sql/handler.cc b/sql/handler.cc index ca5a3e28c28..45721d6cfbb 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -1510,8 +1510,7 @@ int ha_commit_trans(THD *thd, bool all) uint rw_ha_count= ha_check_and_coalesce_trx_read_only(thd, ha_info, all); /* rw_trans is TRUE when we in a transaction changing data */ - bool rw_trans= is_real_trans && - (rw_ha_count > (thd->is_current_stmt_binlog_disabled()?0U:1U)); + bool rw_trans= is_real_trans && rw_ha_count > 0; MDL_request mdl_backup; DBUG_PRINT("info", ("is_real_trans: %d rw_trans: %d rw_ha_count: %d", is_real_trans, rw_trans, rw_ha_count));