diff --git a/mysql-test/suite/versioning/r/rpl.result b/mysql-test/suite/versioning/r/rpl.result index 62dd9798a95..ebcce457f5f 100644 --- a/mysql-test/suite/versioning/r/rpl.result +++ b/mysql-test/suite/versioning/r/rpl.result @@ -528,4 +528,17 @@ a check_row_ts(rs,re) set sql_mode=default; connection master; drop tables t1, t2, t3; +# +# MDEV-33330 Server crash or assertion failure in +# binlog_get_pending_rows_event +# +create or replace table t (x int) with system versioning +partition by system_time interval 1 minute auto partitions 3; +insert into t values (1); +connect con1,localhost,root,,; +set timestamp= @@timestamp+120; +update t set x= x + 1; +connection default; +disconnect con1; +drop table t; include/rpl_end.inc diff --git a/mysql-test/suite/versioning/t/rpl.test b/mysql-test/suite/versioning/t/rpl.test index c723751a060..d804fe03fe5 100644 --- a/mysql-test/suite/versioning/t/rpl.test +++ b/mysql-test/suite/versioning/t/rpl.test @@ -442,5 +442,28 @@ set sql_mode=default; connection master; drop tables t1, t2, t3; + +--echo # +--echo # MDEV-33330 Server crash or assertion failure in +--echo # binlog_get_pending_rows_event +--echo # + +create or replace table t (x int) with system versioning +partition by system_time interval 1 minute auto partitions 3; +insert into t values (1); + +connect (con1,localhost,root,,); +set timestamp= @@timestamp+120; +update t set x= x + 1; +connection default; + +# Cleanup +disconnect con1; +drop table t; + +# +# End of 11.2 tests +# + --source suite/versioning/common_finish.inc --source include/rpl_end.inc diff --git a/sql/sql_class.h b/sql/sql_class.h index c8de83a6f0a..8333fda05e0 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -3034,9 +3034,14 @@ public: bool binlog_need_stmt_format(bool is_transactional) const { - return log_current_statement() && - !binlog_get_pending_rows_event(binlog_get_cache_mngr(), - use_trans_cache(this, is_transactional)); + if (!log_current_statement()) + return false; + auto *cache_mngr= binlog_get_cache_mngr(); + if (!cache_mngr) + return true; + return !binlog_get_pending_rows_event(cache_mngr, + use_trans_cache(this, + is_transactional)); } bool binlog_for_noop_dml(bool transactional_table);