=== added file 'mysql-test/suite/ndb_binlog/r/ndb_binlog_mysqlbinlog_verbose.result' --- mysql-test/suite/ndb_binlog/r/ndb_binlog_mysqlbinlog_verbose.result 1970-01-01 00:00:00 +0000 +++ mysql-test/suite/ndb_binlog/r/ndb_binlog_mysqlbinlog_verbose.result 2009-09-22 16:41:21 +0000 @@ -0,0 +1,48 @@ +create table ba(ks int primary key, st int, lp int) engine = ndb; +insert into ba values (1, 1, 1), (2,2,2), (3,3,3), (4,4,4); +update ba set lp=40 where ks=4; +flush logs; +show variables like '%log_update%'; +Variable_name Value +sql_log_update ON +select txt from binlog_stmts where txt not like '%ndb_apply_status%' order by txt; +txt +INSERT INTO test.ba SET @1=1 @2=1 @3=1 +INSERT INTO test.ba SET @1=2 @2=2 @3=2 +INSERT INTO test.ba SET @1=3 @2=3 @3=3 +INSERT INTO test.ba SET @1=4 @2=4 @3=4 +INSERT INTO test.ba SET @1=4 @3=40 +flush logs; +show variables like '%log_update%'; +Variable_name Value +sql_log_update ON +select txt from binlog_stmts where txt not like '%ndb_apply_status%' order by txt; +txt +INSERT INTO test.ba SET @1=1 @2=1 @3=1 +INSERT INTO test.ba SET @1=2 @2=2 @3=2 +INSERT INTO test.ba SET @1=3 @2=3 @3=3 +INSERT INTO test.ba SET @1=4 @2=4 @3=4 +INSERT INTO test.ba SET @1=4 @2=4 @3=40 +flush logs; +show variables like '%log_update%'; +Variable_name Value +sql_log_update ON +select txt from binlog_stmts where txt not like '%ndb_apply_status%' order by txt; +txt +INSERT INTO test.ba SET @1=1 @2=1 @3=1 +INSERT INTO test.ba SET @1=2 @2=2 @3=2 +INSERT INTO test.ba SET @1=3 @2=3 @3=3 +INSERT INTO test.ba SET @1=4 @2=4 @3=4 +UPDATE test.ba WHERE @1=4 @3=4 SET @1=4 @3=40 +flush logs; +show variables like '%log_update%'; +Variable_name Value +sql_log_update ON +select txt from binlog_stmts where txt not like '%ndb_apply_status%' order by txt; +txt +INSERT INTO test.ba SET @1=1 @2=1 @3=1 +INSERT INTO test.ba SET @1=2 @2=2 @3=2 +INSERT INTO test.ba SET @1=3 @2=3 @3=3 +INSERT INTO test.ba SET @1=4 @2=4 @3=4 +UPDATE test.ba WHERE @1=4 @2=4 @3=4 SET @1=4 @2=4 @3=40 +drop table ba; === added file 'mysql-test/suite/ndb_binlog/t/ndb_binlog_get_binlog_stmts.inc' --- mysql-test/suite/ndb_binlog/t/ndb_binlog_get_binlog_stmts.inc 1970-01-01 00:00:00 +0000 +++ mysql-test/suite/ndb_binlog/t/ndb_binlog_get_binlog_stmts.inc 2009-09-22 16:51:32 +0000 @@ -0,0 +1,75 @@ +# +# Get the mysqlbinlog tool --verbose mode to dump the Binlog contents with +# 'SQL' statements in triple-comments over multiple lines, e.g. : +# +### INSERT +### SET +### @1=1 +### @2=2 +# +# Then munch this output into single-line statements +# Then sort to get deterministic order independent of table fragmentation etc. +# + +--disable_query_log +let $MYSQLD_DATADIR= `select @@datadir;`; +--exec $MYSQL_BINLOG --verbose $MYSQLD_DATADIR/mysqld-bin.000001 > $MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql + +create table raw_binlog_rows (txt varchar(1000)); + +--eval load data local infile '$MYSQLTEST_VARDIR/tmp/ndb_binlog_mysqlbinlog.sql' into table raw_binlog_rows columns terminated by '\n'; + +create table binlog_stmt_parts_unassoc (txt varchar(1000), line_count int, stmt_boundary int); + +set @line_count=0; +set @stmt_boundary=0; + +insert into binlog_stmt_parts_unassoc + select txt, + @line_count:= @line_count + 1, # So we can preserve order later + (txt like '%INSERT%' or # Identify statement boundaries + txt like '%UPDATE%' or + txt like '%DELETE%') + from raw_binlog_rows + where + txt like '###%'; # Discard non verbose output + +#select * from binlog_stmt_parts_unassoc; + +create table binlog_stmt_parts_assoc (txt varchar(1000), line_count int, stmt_num int); + +set @stmt_count = 0; + +insert into binlog_stmt_parts_assoc + select txt, + line_count, + @stmt_count:= @stmt_count + stmt_boundary # All rows from same stmt will + # have same stmt_num + from binlog_stmt_parts_unassoc order by line_count; + + +#select * from binlog_stmt_parts_assoc; + +create table binlog_stmts (txt varchar(1000), stmt_num int); + +insert into binlog_stmts + select group_concat(right(txt, # Combine rows in statment into 1 + length(txt) - 4) # Trim ### from line start + order by line_count + separator ' '), stmt_num + from binlog_stmt_parts_assoc + group by stmt_num; + +#select * from binlog_stmts; + +# Drop ndb_apply_status entries and sort by the statment +# text to get a deterministic order. +--enable_query_log +select txt from binlog_stmts where txt not like '%ndb_apply_status%' order by txt; + +--disable_query_log +drop table raw_binlog_rows; +drop table binlog_stmt_parts_unassoc; +drop table binlog_stmt_parts_assoc; +drop table binlog_stmts; +--enable_query_log \ No newline at end of file === added file 'mysql-test/suite/ndb_binlog/t/ndb_binlog_mysqlbinlog_verbose.cnf' --- mysql-test/suite/ndb_binlog/t/ndb_binlog_mysqlbinlog_verbose.cnf 1970-01-01 00:00:00 +0000 +++ mysql-test/suite/ndb_binlog/t/ndb_binlog_mysqlbinlog_verbose.cnf 2009-09-22 16:30:53 +0000 @@ -0,0 +1,42 @@ +!include include/default_mysqld.cnf +!include include/default_ndbd.cnf + +[cluster_config.1] +NoOfReplicas= 2 +ndbd=, +ndb_mgmd= +mysqld=,,, +ndbapi=,,,,,,,,,,, + +[mysqld] +# Make all mysqlds use cluster +ndbcluster +ndb-wait-connected=20 +ndb-cluster-connection-pool=1 +binlog-format=row + +[mysqld.1.1] +ndb-log-update-as-write=1 +ndb-log-updated-only=1 + +[mysqld.2.1] +ndb-log-update-as-write=1 +ndb-log-updated-only=0 + +[mysqld.3.1] +ndb-log-update-as-write=0 +ndb-log-updated-only=1 + +[mysqld.4.1] +ndb-log-update-as-write=0 +ndb-log-updated-only=0 + +[ENV] +NDB_CONNECTSTRING= @mysql_cluster.1.ndb_connectstring +MASTER_MYPORT= @mysqld.1.1.port +MASTER_MYPORT1= @mysqld.2.1.port +MASTER_MYPORT2= @mysqld.3.1.port +MASTER_MYPORT3= @mysqld.4.1.port + +NDB_BACKUP_DIR= @cluster_config.ndbd.1.1.BackupDataDir + === added file 'mysql-test/suite/ndb_binlog/t/ndb_binlog_mysqlbinlog_verbose.test' --- mysql-test/suite/ndb_binlog/t/ndb_binlog_mysqlbinlog_verbose.test 1970-01-01 00:00:00 +0000 +++ mysql-test/suite/ndb_binlog/t/ndb_binlog_mysqlbinlog_verbose.test 2009-09-22 16:40:48 +0000 @@ -0,0 +1,78 @@ +######################################################## +# Test mysqlbinlog command with Ndb produced Binlog +# Originally due to bug#47323 concerning +# mysqlbinlog --verbose output +######################################################## +-- source include/have_ndb.inc +-- source include/have_binlog_format_row.inc + +# Setup connections +connect(mysqld1,127.0.0.1,root,,test,$MASTER_MYPORT); +connect(mysqld2,127.0.0.1,root,,test,$MASTER_MYPORT1); +connect(mysqld3,127.0.0.1,root,,test,$MASTER_MYPORT2); +connect(mysqld4,127.0.0.1,root,,test,$MASTER_MYPORT3); + +connection mysqld1; + +# Create the table we're going to use +create table ba(ks int primary key, st int, lp int) engine = ndb; + +# Wait for each mysqld to startup binlogging +--let $source_server=mysqld1 +--let $dest_server=mysqld2 +source suite/rpl_ndb/t/rpl_ndb_wait_schema_logging.inc; + +--let $source_server=mysqld1 +--let $dest_server=mysqld3 +source suite/rpl_ndb/t/rpl_ndb_wait_schema_logging.inc; + +--let $source_server=mysqld1 +--let $dest_server=mysqld4 +source suite/rpl_ndb/t/rpl_ndb_wait_schema_logging.inc; + +--disable_query_log +connection mysqld1; +reset master; +connection mysqld2; +reset master; +connection mysqld3; +reset master; +connection mysqld4; +reset master; +--enable_query_log + +connection mysqld1; + +# Now make the inserts and update +insert into ba values (1, 1, 1), (2,2,2), (3,3,3), (4,4,4); +update ba set lp=40 where ks=4; # Update does not affect all columns + +sleep 1; # Time for updates to propagate to connected MySQLD's binlogs + +# Now let's have a look at what's in the Binlog on each server + +flush logs; +show variables like '%log_update%'; +--source suite/ndb_binlog/t/ndb_binlog_get_binlog_stmts.inc + +connection mysqld2; + +flush logs; +show variables like '%log_update%'; +--source suite/ndb_binlog/t/ndb_binlog_get_binlog_stmts.inc + +connection mysqld3; + +flush logs; +show variables like '%log_update%'; +--source suite/ndb_binlog/t/ndb_binlog_get_binlog_stmts.inc + +connection mysqld4; + +flush logs; +show variables like '%log_update%'; +--source suite/ndb_binlog/t/ndb_binlog_get_binlog_stmts.inc + + +drop table ba; + === modified file 'sql/log_event.cc' --- sql/log_event.cc 2009-08-25 19:44:04 +0000 +++ sql/log_event.cc 2009-09-22 11:24:41 +0000 @@ -1855,6 +1855,7 @@ Rows_log_event::print_verbose_one_row(IO { const uchar *value0= value; const uchar *null_bits= value; + uint null_bit_index= 0; char typestr[64]= ""; value+= (m_width + 7) / 8; @@ -1863,7 +1864,8 @@ Rows_log_event::print_verbose_one_row(IO for (size_t i= 0; i < td->size(); i ++) { - int is_null= (null_bits[i / 8] >> (i % 8)) & 0x01; + int is_null= (null_bits[null_bit_index / 8] + >> (null_bit_index % 8)) & 0x01; if (bitmap_is_set(cols_bitmap, i) == 0) continue; @@ -1900,6 +1902,8 @@ Rows_log_event::print_verbose_one_row(IO } my_b_printf(file, "\n"); + + null_bit_index++; } return value - value0; }