From fa4006bc8ac7c2c773be2acb1303840c372c3e11 Mon Sep 17 00:00:00 2001 From: He Zhenxing Date: Fri, 9 Oct 2009 16:54:48 +0800 Subject: [PATCH] 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. --- .../r/binlog_row_mysqlbinlog_verbose.result | 161 ++++++++++++++++++ .../binlog/std_data/update-full-row.binlog | Bin 0 -> 614 bytes .../binlog/std_data/update-partial-row.binlog | Bin 0 -> 606 bytes .../binlog/std_data/write-full-row.binlog | Bin 0 -> 571 bytes .../binlog/std_data/write-partial-row.binlog | Bin 0 -> 596 bytes .../t/binlog_row_mysqlbinlog_verbose.test | 82 +++++++++ sql/log_event.cc | 6 +- 7 files changed, 248 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_verbose.result create mode 100644 mysql-test/suite/binlog/std_data/update-full-row.binlog create mode 100644 mysql-test/suite/binlog/std_data/update-partial-row.binlog create mode 100644 mysql-test/suite/binlog/std_data/write-full-row.binlog create mode 100644 mysql-test/suite/binlog/std_data/write-partial-row.binlog create mode 100644 mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_verbose.test diff --git a/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_verbose.result b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_verbose.result new file mode 100644 index 00000000000..f1a3fafc498 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_row_mysqlbinlog_verbose.result @@ -0,0 +1,161 @@ +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; diff --git a/mysql-test/suite/binlog/std_data/update-full-row.binlog b/mysql-test/suite/binlog/std_data/update-full-row.binlog new file mode 100644 index 0000000000000000000000000000000000000000..866a351033e5fd95cd96736f7575cf1278cba11c GIT binary patch literal 614 zcma)4!Ab&A6g|#7^$~=ki_A^XDySLKsH`BYh%nHI+Ka=e6sFdU3%{gg`@W&yh_-#k zw9(FeF$3bJ3uk8Tz2}^JXWq=bhvE43<2t7R^oU0SP}p}X?%ts@^gZXmt-6&X$M1TR zzB3s04P*HtHpSX1Gzw6R0&oXa)?{j}EooaarB1v{kw~J;@q$uLGNbOhP?nvuHd^h6tperor<7dA?V>Gae77?I7%glK^R3 z=eXq@5cQf2Iw4w%>Wyz{tPmMuDH7=|TW>}h?`Y2>o5dKBG-E^-lNgaqh#`h0NovH` zqG2|>KuwY@Qbo5ex=rGTx;*|CNx@FdWRx(>ahx$ZX666KadFdZHtt_&pk%}j(GyFv QwcO1&_8tCO?yf}j7fK*a0{{R3 literal 0 HcmV?d00001 diff --git a/mysql-test/suite/binlog/std_data/update-partial-row.binlog b/mysql-test/suite/binlog/std_data/update-partial-row.binlog new file mode 100644 index 0000000000000000000000000000000000000000..67e3611aa3a5d8dd2bd9b1b0bd6a590b0562cdce GIT binary patch literal 606 zcma))%}T>S6opTdNf`ubX&2UR1XqG4v=#plq$(l`t%$BI4XH(`wI%7IPvX+O&)_?_ za_=j+%R*Yu9hpMu#tUDPnS0K?HNaXkmq}~+JixF+=`QS zGK%53I>#xefVfwr(IIKhyVt%Xu|%?DA!gQVre2NJ&gf24v073|T2hA#ORBiANWqeL zD&%9npy&NqnR(ctMD(koUnk$x=kYf{25x2|Ekt3C;h2jWcm972r&o=}#qE#BBq4l6=OG0Wzei zc=PUK}DQ3598U#ZP6y8C-4G@BprJ-@95MWhJkzH)xBE7 z4g0}l;6|f?R;)hQrgFAUipnGrWukkMRRyI|%I31otF*uyCqW)nj9NsNNjM@&L#ZHw z?DG1i-PQKozYo5&ZhNVgX+KHH4tx>_a&qZ81QqSMxs(=Or^z^?627bF$8j|6C8?iI z5-JE)#4Z;^+`YjIH9_}p_s%yL)_?<6B5!>}>0P&)J&HvpkThgmG-PaQ$Rs9)e6oim zyKk{<7kr|*M8ED932V*;R_HUnz=W^#|7U!4*Xgt$#xRiVbO4$>&|BfRKDf}u|Kc5T G)PDdA3P>dY literal 0 HcmV?d00001 diff --git a/mysql-test/suite/binlog/std_data/write-partial-row.binlog b/mysql-test/suite/binlog/std_data/write-partial-row.binlog new file mode 100644 index 0000000000000000000000000000000000000000..7424ec4e940b5bd3b3d261e5be16f685d883c241 GIT binary patch literal 596 zcmaJ?=e}h+l zf_HEJg&ef?&1xc2@WI>c%)I%?uru#=IC^-#C|E>v1Kxo|l6G}X?=+mD?>T$Au4@O5 z-}fd1Cm0QkV)5WI<^5$+R3ZtKh^|Ri6qHISJ4D##E=}->onVFvZcQSN8{|b4`%*y! z*~!^?tHb$aj&FjmMx@P&Y2$trlkK@A0Lo|5BM3|mRez+p`)M=|sEGgSxnUSgdr|Dh zlZbLc6)@$Th_hF?(IMC|6J^J>tdCN-T=%o71;%7lX{6B|a#M8Zg! z72JUH $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; diff --git a/sql/log_event.cc b/sql/log_event.cc index d7921ad3c27..ae7c4335f59 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -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; }