Bug #46172 row events in binlog when using ndb even if binlog_format=statement
Description:
Row events are written to the binlog if an ndb table is updated, even if binlog_format = STATEMENT.
This is wrong, because row events shall never be written if binlog_format = STATEMENT.
When mysqlbinlog reads a binlog with row events, it outputs BINLOG statements. BINLOG statements can only be executed by root (for security reasons). Therefore, binlog_format = STATEMENT shall be possible to use to ensure that the output of mysqlbinlog does not contain BINLOG statements.
How to repeat:
--source include/have_binlog_format_statement.inc
--source include/have_ndb.inc
--source include/ndb_master-slave.inc
CREATE TABLE t1 (a INT) ENGINE = NDB;
SELECT @@session.binlog_format;
INSERT INTO t1 VALUES (1);
SHOW BINLOG EVENTS;
Suggested fix:
Disallow updates to ndb tables if binlog_format = STATEMENT.
Also, add the following assert to ensure that rows are never written when binlog_format = STATEMENT:
=== modified file 'sql/handler.cc'
--- sql/handler.cc 2009-06-09 16:44:26 +0000
+++ sql/handler.cc 2009-07-14 14:17:17 +0000
@@ -4522,6 +4522,8 @@
uint n_fields= table->s->fields;
my_bool use_bitbuf= n_fields <= sizeof(bitbuf)*8;
+ DBUG_ASSERT(thd->variables.binlog_format != BINLOG_FORMAT_STMT);
+
/*
If there are no table maps written to the binary log, this is
the first row handled in this statement. In that case, we need
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.041 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: Row events are written to the binlog if an ndb table is updated, even if binlog_format = STATEMENT. This is wrong, because row events shall never be written if binlog_format = STATEMENT. When mysqlbinlog reads a binlog with row events, it outputs BINLOG statements. BINLOG statements can only be executed by root (for security reasons). Therefore, binlog_format = STATEMENT shall be possible to use to ensure that the output of mysqlbinlog does not contain BINLOG statements. How to repeat: --source include/have_binlog_format_statement.inc --source include/have_ndb.inc --source include/ndb_master-slave.inc CREATE TABLE t1 (a INT) ENGINE = NDB; SELECT @@session.binlog_format; INSERT INTO t1 VALUES (1); SHOW BINLOG EVENTS; Suggested fix: Disallow updates to ndb tables if binlog_format = STATEMENT. Also, add the following assert to ensure that rows are never written when binlog_format = STATEMENT: === modified file 'sql/handler.cc' --- sql/handler.cc 2009-06-09 16:44:26 +0000 +++ sql/handler.cc 2009-07-14 14:17:17 +0000 @@ -4522,6 +4522,8 @@ uint n_fields= table->s->fields; my_bool use_bitbuf= n_fields <= sizeof(bitbuf)*8; + DBUG_ASSERT(thd->variables.binlog_format != BINLOG_FORMAT_STMT); + /* If there are no table maps written to the binary log, this is the first row handled in this statement. In that case, we need