Bug #46172 row events in binlog when using ndb even if binlog_format=statement
Submitted: 14 Jul 2009 15:17
Reporter: Sven Sandberg Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Cluster: Replication Severity:S2 (Serious)
Version:mysql-5.1 OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: 5.1+, binlog, binlog_format, ndb
Triage: Triaged: D4 (Minor) / R3 (Medium) / E4 (High)

[14 Jul 2009 15:17] Sven Sandberg
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
[17 Aug 2009 13:46] Jørgen Austvik
Changing binlog format must be distributed in the cluster to all mysqld processes