From 2b9fb342cfc2d34f69c648d97a939b70b569d5fa Mon Sep 17 00:00:00 2001 From: Aleksey Midenkov Date: Tue, 5 Jul 2022 12:55:10 +0300 Subject: [PATCH] MDEV-28978 Assertion failure in THD::binlog_query or unexpected ER_ERROR_ON_WRITE with auto-partitioning Added check whether binlogging is enabled before doing binlog_query(). --- mysql-test/suite/versioning/r/partition.result | 9 +++++++++ mysql-test/suite/versioning/t/partition.test | 12 +++++++++++- sql/sql_class.cc | 2 +- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/versioning/r/partition.result b/mysql-test/suite/versioning/r/partition.result index dd8d217185d..5ca28a26d35 100644 --- a/mysql-test/suite/versioning/r/partition.result +++ b/mysql-test/suite/versioning/r/partition.result @@ -3257,4 +3257,13 @@ delete from t partition (px); ERROR HY000: Unknown partition 'px' in table 't' unlock tables; drop table t; +# +# MDEV-28978 Assertion failure in THD::binlog_query or unexpected +# ER_ERROR_ON_WRITE with auto-partitioning +# +create table t (a int) with system versioning partition by system_time limit 6 auto; +insert into t () values (),(),(),(),(),(); +update t set a = 1; +update t set a = 2 limit 0; +drop table t; set global innodb_stats_persistent= @save_persistent; diff --git a/mysql-test/suite/versioning/t/partition.test b/mysql-test/suite/versioning/t/partition.test index 23fd35650cb..74e806f7d5f 100644 --- a/mysql-test/suite/versioning/t/partition.test +++ b/mysql-test/suite/versioning/t/partition.test @@ -2497,7 +2497,17 @@ unlock tables; # cleanup drop table t; +--echo # +--echo # MDEV-28978 Assertion failure in THD::binlog_query or unexpected +--echo # ER_ERROR_ON_WRITE with auto-partitioning +--echo # +create table t (a int) with system versioning partition by system_time limit 6 auto; +insert into t () values (),(),(),(),(),(); +update t set a = 1; +update t set a = 2 limit 0; +# cleanup +drop table t; + --disable_prepare_warnings set global innodb_stats_persistent= @save_persistent; - --source suite/versioning/common_finish.inc diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 982afaa0560..33aa71c7a20 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -7358,7 +7358,7 @@ int THD::binlog_flush_pending_rows_event(bool stmt_end, bool is_transactional) */ bool THD::binlog_for_noop_dml(bool transactional_table) { - if (log_current_statement()) + if (mysql_bin_log.is_open() && log_current_statement()) { reset_unsafe_warnings(); if (binlog_query(THD::STMT_QUERY_TYPE, query(), query_length(),