From dededdec0ab3ebebd1fb1f9c346664cc49d34b78 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 24 Feb 2006 15:38:20 +0100 Subject: BUG#13418 (V2): Bit columns should replicate correctly when using RBR mysql-test/r/rpl_bit_npk.result: Updated results mysql-test/t/disabled.def: rpl_bit_npk now works sql/field.h: Field_bit::cmp_binary_offset wrongly used base class method that does not work for Field_bit This was discussed with Monty and should be pushed into 5.0 too sql/log_event.cc: Added checks for null bits Swapped use of m_after_image (was m_search_record) and table->record[1] to use record[i] in the same way as other MySQL code (i.e. use record[1] for scan data). Removed use of cmp_binary in record_compare (it is currently wrong to use that without copying the null bits to the compare data record) sql/log_event.h: Name change to indicate new semantics --- sql/field.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'sql/field.h') diff --git a/sql/field.h b/sql/field.h index 15c54f65ef7..ca178f518fd 100644 --- a/sql/field.h +++ b/sql/field.h @@ -173,8 +173,9 @@ public: virtual int cmp(const char *,const char *)=0; virtual int cmp_binary(const char *a,const char *b, uint32 max_length=~0L) { return memcmp(a,b,pack_length()); } - int cmp_offset(uint row_offset) { return cmp(ptr,ptr+row_offset); } - int cmp_binary_offset(uint row_offset) + virtual int cmp_offset(uint row_offset) + { return cmp(ptr,ptr+row_offset); } + virtual int cmp_binary_offset(uint row_offset) { return cmp_binary(ptr, ptr+row_offset); }; virtual int key_cmp(const byte *a,const byte *b) { return cmp((char*) a,(char*) b); } @@ -1317,6 +1318,20 @@ public: }; +/* + Note: + To use Field_bit::cmp_binary() you need to copy the bits stored in + the beginning of the record (the NULL bytes) to each memory you + want to compare (where the arguments point). + + This is the reason: + - Field_bit::cmp_binary() is only implemented in the base class + (Field::cmp_binary()). + - Field::cmp_binary() currenly use pack_length() to calculate how + long the data is. + - pack_length() includes size of the bits stored in the NULL bytes + of the record. +*/ class Field_bit :public Field { public: uchar *bit_ptr; // position in record where 'uneven' bits store @@ -1342,6 +1357,8 @@ public: my_decimal *val_decimal(my_decimal *); int cmp(const char *a, const char *b) { return cmp_binary(a, b); } + int cmp_binary_offset(uint row_offset) + { return cmp_offset(row_offset); } int cmp_max(const char *a, const char *b, uint max_length); int key_cmp(const byte *a, const byte *b) { return cmp_binary((char *) a, (char *) b); } -- cgit v1.2.1