@@ -61,13 +61,15 @@ def __is_null(self, null_bitmap, position):
61
61
bit = ord (bit )
62
62
return bit & (1 << (position % 8 ))
63
63
64
- def _read_column_data (self , bitmap ):
64
+ def _read_column_data (self , cols_bitmap ):
65
65
"""Use for WRITE, UPDATE and DELETE events.
66
66
Return an array of column data
67
67
"""
68
68
values = {}
69
69
70
- null_bitmap = self .packet .read ((bitmap .bits_set () + 7 ) / 8 )
70
+ # null bitmap length = (bits set in 'columns-present-bitmap'+7)/8
71
+ # See http://dev.mysql.com/doc/internals/en/rows-event.html
72
+ null_bitmap = self .packet .read ((cols_bitmap .bits_set () + 7 ) / 8 )
71
73
72
74
nullBitmapIndex = 0
73
75
nb_columns = len (self .columns )
@@ -76,7 +78,7 @@ def _read_column_data(self, bitmap):
76
78
name = self .table_map [self .table_id ].columns [i ].name
77
79
unsigned = self .table_map [self .table_id ].columns [i ].unsigned
78
80
79
- if bitmap .is_set (i ) == 0 :
81
+ if cols_bitmap .is_set (i ) == 0 :
80
82
values [name ] = None
81
83
continue
82
84
@@ -406,9 +408,8 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
406
408
def _fetch_one_row (self ):
407
409
row = {}
408
410
409
- b = Bitmap (self .columns_present_bitmap , self .number_of_columns )
410
- #null_bitmap = self.packet.read((self.number_of_columns + 7) / 8)
411
- row ["values" ] = self ._read_column_data (b )
411
+ cols_bitmap = Bitmap (self .columns_present_bitmap , self .number_of_columns )
412
+ row ["values" ] = self ._read_column_data (cols_bitmap )
412
413
return row
413
414
414
415
def _dump (self ):
@@ -436,9 +437,8 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
436
437
def _fetch_one_row (self ):
437
438
row = {}
438
439
439
- b = Bitmap (self .columns_present_bitmap , self .number_of_columns )
440
- # null_bitmap = self.packet.read((self.number_of_columns + 7) / 8)
441
- row ["values" ] = self ._read_column_data (b )
440
+ cols_bitmap = Bitmap (self .columns_present_bitmap , self .number_of_columns )
441
+ row ["values" ] = self ._read_column_data (cols_bitmap )
442
442
return row
443
443
444
444
def _dump (self ):
@@ -474,13 +474,11 @@ def __init__(self, from_packet, event_size, table_map, ctl_connection, **kwargs)
474
474
def _fetch_one_row (self ):
475
475
row = {}
476
476
477
- b = Bitmap (self .columns_present_bitmap , self .number_of_columns )
478
- #null_bitmap = self.packet.read((self.number_of_columns + 7) / 8)
479
- row ["before_values" ] = self ._read_column_data (b )
477
+ cols_bitmap1 = Bitmap (self .columns_present_bitmap , self .number_of_columns )
478
+ row ["before_values" ] = self ._read_column_data (cols_bitmap1 )
480
479
481
- b = Bitmap (self .columns_present_bitmap2 , self .number_of_columns )
482
- #null_bitmap = self.packet.read((self.number_of_columns + 7) / 8)
483
- row ["after_values" ] = self ._read_column_data (b )
480
+ cols_bitmap2 = Bitmap (self .columns_present_bitmap2 , self .number_of_columns )
481
+ row ["after_values" ] = self ._read_column_data (cols_bitmap2 )
484
482
return row
485
483
486
484
def _dump (self ):
0 commit comments