Bug #42941 --database paramater to mysqlbinlog fails with RBR
Submitted: 17 Feb 2009 18:29 Modified: 9 Jul 2009 11:35
Reporter: Scott Noyes Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Row Based Replication ( RBR ) Severity:S3 (Non-critical)
Version:5.1.30 OS:Any
Assigned to: Luis Soares CPU Architecture:Any

[17 Feb 2009 18:29] Scott Noyes
Description:
mysqlbinlog --database=NOTtest still outputs updates made to the `test` schema when using row based replication.

I got this output (I did not expect to see the row from the UPDATE included, since it followed USE test):

BINLOG '
oPuaSQ8BAAAAZgAAAGoAAAABAAQANS4xLjMwLWVudGVycHJpc2UtZ3BsLWFkdmFuY2VkLWxvZwAA
AAAAAAAAAAAAAAAAAACg+5pJEzgNAAgAEgAEBAQEEgAAUwAEGggAAAAICAgC
'/*!*/;
# at 106
# at 174
# at 215
#090217 12:02:21 server id 1  end_log_pos 215
# Position  Timestamp   Type   Master ID        Size      Master Pos    Flags
#       ae ad fb 9a 49   13   01 00 00 00   29 00 00 00   d7 00 00 00   00 00
#       c1 10 00 00 00 00 00 00 00  04 74 65 73 74 00 02 74 |.........test..t|
#       d1 31 00 01 03 00 01  |1.....|
#       Table_map: `test`.`t1` mapped to number 16
#090217 12:02:21 server id 1  end_log_pos 265
# Position  Timestamp   Type   Master ID        Size      Master Pos    Flags
#       d7 ad fb 9a 49   18   01 00 00 00   32 00 00 00   09 01 00 00   10 00
#       ea 10 00 00 00 00 00 01 00  01 ff ff fe 02 00 00 00 |................|
#       fa fe 01 00 00 00 fe 02 00  00 00 fe 01 00 00 00  |...............|
#       Update_rows: table id 16 flags: STMT_END_F

BINLOG '
rfuaSRMBAAAAKQAAANcAAAAAABAAAAAAAAAABHRlc3QAAnQxAAEDAAE=
rfuaSRgBAAAAMgAAAAkBAAAQABAAAAAAAAEAAf///gIAAAD+AQAAAP4CAAAA/gEAAAA=
'/*!*/;
### UPDATE test.t1
### WHERE
###   @1=2
### SET
###   @1=1
### UPDATE test.t1
### WHERE
###   @1=2
### SET
###   @1=1
# at 265
#090217 12:02:21 server id 1  end_log_pos 292
# Position  Timestamp   Type   Master ID        Size      Master Pos    Flags
#      109 ad fb 9a 49   10   01 00 00 00   1b 00 00 00   24 01 00 00   00 00
#      11c 02 09 00 00 00 00 00 00   |........|
#       Xid = 2306

How to repeat:
RESET MASTER;
SET binlog_format='ROW';
USE test;
UPDATE t1 SET id = 1;

mysqlbinlog --database=NOTtest --verbose --hexdump mysql-bin.000001

Suggested fix:
Fix mysqlbinlog --database to correctly handle RBR format.

For a workaround, use STATEMENT format.
[27 May 2009 15:39] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/75069

2874 Luis Soares	2009-05-27
      BUG#42941: --database paramater to mysqlbinlog fails with RBR
      
      mysqlbinlog --database parameter was being ignored when processing
      row events. As such no event filtering would take place.
      
      This patch addresses this by deploying a call to shall_skip_database
      when table_map_events are handled (as these contain also the name of
      the database). All other rows events referencing the table id for the
      filtered map event, will also be skipped.
     @ client/mysqlbinlog.cc
        Added shall_skip_database call to the part of the code that handles 
        Table_map_log_events. It inspects the database name and decides whether
        to filter the event or not. Furthermore, if table map event is filtered
        next events referencing the table id in the table map event, will also
        be filtered.
     @ mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
        Test case that checks if row events are actually filtered out.
     @ sql/log_event.h
        Added a map for holding the currently ignored table map events.
        Table map events are inserted when they shall be skipped and removed
        once the last row event in the statement referencing this event is 
        processed.
[2 Jun 2009 11:26] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/75453

2874 Luis Soares	2009-06-02
      BUG#42941: --database paramater to mysqlbinlog fails with RBR
            
      mysqlbinlog --database parameter was being ignored when processing
      row events. As such no event filtering would take place.
            
      This patch addresses this by deploying a call to shall_skip_database
      when table_map_events are handled (as these contain also the name of
      the database). All other rows events referencing the table id for the
      filtered map event, will also be skipped.
     @ client/mysqlbinlog.cc
        Added shall_skip_database call to the part of the code that handles 
        Table_map_log_events. It inspects the database name and decides whether
        to filter the event or not. Furthermore, if table map event is filtered
        next events referencing the table id in the table map event, will also
        be filtered.
     @ mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
        Test case that checks if row events are actually filtered out.
     @ sql/log_event.h
        Added a map for holding the currently ignored table map events.
        Table map events are inserted when they shall be skipped and removed
        once the last row event in the statement referencing this event is 
        processed.
[5 Jun 2009 8:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/75631

2874 Luis Soares	2009-06-04
      BUG#42941: --database paramater to mysqlbinlog fails with RBR
                  
      mysqlbinlog --database parameter was being ignored when processing
      row events. As such no event filtering would take place.
                  
      This patch addresses this by deploying a call to shall_skip_database
      when table_map_events are handled (as these contain also the name of
      the database). All other rows events referencing the table id for the
      filtered map event, will also be skipped.
     @ client/mysqlbinlog.cc
        Added shall_skip_database call to the part of the code that handles 
        Table_map_log_events. It inspects the database name and decides whether
        to filter the event or not. Furthermore, if table map event is filtered
        next events referencing the table id in the table map event, will also
        be filtered.
     @ mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
        Test case that checks if row events are actually filtered out.
     @ sql/log_event.h
        Added a map for holding the currently ignored table map events.
        Table map events are inserted when they shall be skipped and removed
        once the last row event in the statement is processed.
[5 Jun 2009 9:16] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/75671

2874 Luis Soares	2009-06-05
      BUG#42941: --database paramater to mysqlbinlog fails with RBR
                  
      mysqlbinlog --database parameter was being ignored when processing
      row events. As such no event filtering would take place.
                  
      This patch addresses this by deploying a call to shall_skip_database
      when table_map_events are handled (as these contain also the name of
      the database). All other rows events referencing the table id for the
      filtered map event, will also be skipped.
     @ client/mysqlbinlog.cc
        Added shall_skip_database call to the part of the code that handles 
        Table_map_log_events. It inspects the database name and decides whether
        to filter the event or not. Furthermore, if table map event is filtered
        next events referencing the table id in the table map event, will also
        be filtered.
     @ mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
        Test case that checks if row events are actually filtered out.
     @ sql/log_event.h
        Added a map for holding the currently ignored table map events.
        Table map events are inserted when they shall be skipped and removed
        once the last row event in the statement is processed.
[7 Jun 2009 22:28] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/75815

2874 Luis Soares	2009-06-07
      BUG#42941: --database paramater to mysqlbinlog fails with RBR
                  
      mysqlbinlog --database parameter was being ignored when processing
      row events. As such no event filtering would take place.
                  
      This patch addresses this by deploying a call to shall_skip_database
      when table_map_events are handled (as these contain also the name of
      the database). All other rows events referencing the table id for the
      filtered map event, will also be skipped.
     @ client/mysqlbinlog.cc
        Added shall_skip_database call to the part of the code that handles 
        Table_map_log_events. It inspects the database name and decides whether
        to filter the event or not. Furthermore, if table map event is filtered
        next events referencing the table id in the table map event, will also
        be filtered.
     @ mysql-test/suite/binlog/t/binlog_row_mysqlbinlog_db_filter.test
        Test case that checks if row events are actually filtered out.
     @ sql/log_event.h
        Added a map for holding the currently ignored table map events.
        Table map events are inserted when they shall be skipped and removed
        once the last row event in the statement is processed.
[30 Jun 2009 19:10] Luis Soares
Queued in mysql-5.1-bugteam and mysql-pe.
[8 Jul 2009 13:30] Bugs System
Pushed into 5.1.37 (revid:joro@sun.com-20090708131116-kyz8iotbum8w9yic) (version source revid:satya.bn@sun.com-20090701053702-z92zt0gngiim23j2) (merge vers: 5.1.37) (pib:11)
[9 Jul 2009 7:37] Bugs System
Pushed into 5.1.37 (revid:joro@sun.com-20090708131116-kyz8iotbum8w9yic) (version source revid:satya.bn@sun.com-20090701053702-z92zt0gngiim23j2) (merge vers: 5.1.37) (pib:11)
[9 Jul 2009 11:35] Jon Stephens
Documented in the 5.1.37 changelog as follows:

        The --database option for mysqlbinlog was ignored when using the
        row-based logging format.

Also noted this issue in mysqlbinlog's description in the Manual.
[10 Jul 2009 11:20] Bugs System
Pushed into 5.4.4-alpha (revid:anozdrin@bk-internal.mysql.com-20090710111017-bnh2cau84ug1hvei) (version source revid:luis.soares@sun.com-20090630190413-tgyjl4e0f5y75e8e) (merge vers: 5.4.4-alpha) (pib:11)
[26 Aug 2009 13:45] Bugs System
Pushed into 5.1.37-ndb-7.0.8 (revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)
[26 Aug 2009 13:46] Bugs System
Pushed into 5.1.37-ndb-6.3.27 (revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (version source revid:jonas@mysql.com-20090826105955-bkj027t47gfbamnc) (merge vers: 5.1.37-ndb-6.3.27) (pib:11)
[26 Aug 2009 13:48] Bugs System
Pushed into 5.1.37-ndb-6.2.19 (revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (version source revid:jonas@mysql.com-20090825194404-37rtosk049t9koc4) (merge vers: 5.1.37-ndb-6.2.19) (pib:11)
[27 Aug 2009 16:32] Bugs System
Pushed into 5.1.35-ndb-7.1.0 (revid:magnus.blaudd@sun.com-20090827163030-6o3kk6r2oua159hr) (version source revid:jonas@mysql.com-20090826132541-yablppc59e3yb54l) (merge vers: 5.1.37-ndb-7.0.8) (pib:11)