Commit 090985ff authored by He Zhenxing's avatar He Zhenxing

Bug#47323 : mysqlbinlog --verbose displays bad output when events contain subset of columns

Commit the non-NDB specific part (originated by frazer) to 5.1 mainline.
parent e94ae02c
Verbose statements from : write-partial-row.binlog
select txt from raw_binlog_rows where txt like '###%';
txt
### INSERT INTO mysql.ndb_apply_status
### SET
### @1=1
### @2=25769803786
### @3=''
### @4=0
### @5=0
### INSERT INTO test.ba
### SET
### @1=3
### @2=3
### @3=3
### 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=4
### @2=4
### @3=4
### INSERT INTO test.ba
### SET
### @1=4
### @3=40
### DELETE FROM test.ba
### WHERE
### @1=2
drop table raw_binlog_rows;
Verbose statements from : write-full-row.binlog
select txt from raw_binlog_rows where txt like '###%';
txt
### INSERT INTO mysql.ndb_apply_status
### SET
### @1=2
### @2=25769803786
### @3=''
### @4=0
### @5=0
### INSERT INTO test.ba
### SET
### @1=3
### @2=3
### @3=3
### 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=4
### @2=4
### @3=4
### INSERT INTO test.ba
### SET
### @1=4
### @2=4
### @3=40
### DELETE FROM test.ba
### WHERE
### @1=2
drop table raw_binlog_rows;
Verbose statements from : update-partial-row.binlog
select txt from raw_binlog_rows where txt like '###%';
txt
### INSERT INTO mysql.ndb_apply_status
### SET
### @1=3
### @2=25769803786
### @3=''
### @4=0
### @5=0
### INSERT INTO test.ba
### SET
### @1=3
### @2=3
### @3=3
### 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=4
### @2=4
### @3=4
### UPDATE test.ba
### WHERE
### @1=4
### @3=4
### SET
### @1=4
### @3=40
### DELETE FROM test.ba
### WHERE
### @1=2
drop table raw_binlog_rows;
Verbose statements from : update-full-row.binlog
select txt from raw_binlog_rows where txt like '###%';
txt
### INSERT INTO mysql.ndb_apply_status
### SET
### @1=4
### @2=25769803786
### @3=''
### @4=0
### @5=0
### INSERT INTO test.ba
### SET
### @1=3
### @2=3
### @3=3
### 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=4
### @2=4
### @3=4
### UPDATE test.ba
### WHERE
### @1=4
### @2=4
### @3=4
### SET
### @1=4
### @2=4
### @3=40
### DELETE FROM test.ba
### WHERE
### @1=2
drop table raw_binlog_rows;
########################################################
# Test mysqlbinlog command with Ndb produced Binlog
# variants
#
# WHAT
# ====
# This test aims to check that the mysqlbinlog --verbose
# command can output binlogs in 4 format variants, currently
# used by Ndb
#
# 1) Updates logged as write_row events
# Only primary key and updated columns included in the
# event
# 2) Updates logged as write_row_events
# All columns included in the event
# 3) Updates logged as update_row events
# Only primary key and updated columns included in the
# event
# 4) Updates logged as update_row events
# All columns included in the event
#
# Format variant (1) is the Ndb default.
# Bug#47323 resulted in binlogs generated in format (1)
# being incorrectly parsed by the mysqlbinlog --verbose
# option
#
# HOW
# ===
# Row-based binlog files in each format have been
# captured from an Ndb cluster
# These are output using the mysqlbinlog --verbose
# tool and the output is checked.
#
########################################################
# We require binlog_format_row as we're independent of binlog format
# and there's no point running the same test 3 times
-- source include/have_binlog_format_row.inc
--disable_query_log
--let $binlog_file=write-partial-row.binlog
--exec $MYSQL_BINLOG --verbose suite/binlog/std_data/$binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
create table raw_binlog_rows (txt varchar(1000));
--eval load data local infile '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql' into table raw_binlog_rows columns terminated by '\n';
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
--enable_query_log
--echo Verbose statements from : $binlog_file
select txt from raw_binlog_rows where txt like '###%';
drop table raw_binlog_rows;
--disable_query_log
--let $binlog_file=write-full-row.binlog
--exec $MYSQL_BINLOG --verbose suite/binlog/std_data/$binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
create table raw_binlog_rows (txt varchar(1000));
--eval load data local infile '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql' into table raw_binlog_rows columns terminated by '\n';
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
--enable_query_log
--echo Verbose statements from : $binlog_file
select txt from raw_binlog_rows where txt like '###%';
drop table raw_binlog_rows;
--disable_query_log
--let $binlog_file=update-partial-row.binlog
--exec $MYSQL_BINLOG --verbose suite/binlog/std_data/$binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
create table raw_binlog_rows (txt varchar(1000));
--eval load data local infile '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql' into table raw_binlog_rows columns terminated by '\n';
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
--enable_query_log
--echo Verbose statements from : $binlog_file
select txt from raw_binlog_rows where txt like '###%';
drop table raw_binlog_rows;
--disable_query_log
--let $binlog_file=update-full-row.binlog
--exec $MYSQL_BINLOG --verbose suite/binlog/std_data/$binlog_file > $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
create table raw_binlog_rows (txt varchar(1000));
--eval load data local infile '$MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql' into table raw_binlog_rows columns terminated by '\n';
--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog_verbose.sql
--enable_query_log
--echo Verbose statements from : $binlog_file
select txt from raw_binlog_rows where txt like '###%';
drop table raw_binlog_rows;
......@@ -1852,6 +1852,7 @@ Rows_log_event::print_verbose_one_row(IO_CACHE *file, table_def *td,
{
const uchar *value0= value;
const uchar *null_bits= value;
uint null_bit_index= 0;
char typestr[64]= "";
value+= (m_width + 7) / 8;
......@@ -1860,7 +1861,8 @@ Rows_log_event::print_verbose_one_row(IO_CACHE *file, table_def *td,
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;
......@@ -1897,6 +1899,8 @@ Rows_log_event::print_verbose_one_row(IO_CACHE *file, table_def *td,
}
my_b_printf(file, "\n");
null_bit_index++;
}
return value - value0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment