summaryrefslogtreecommitdiff
path: root/sql/field.h
diff options
context:
space:
mode:
authorunknown <igor@olga.mysql.com>2007-08-05 14:16:49 -0700
committerunknown <igor@olga.mysql.com>2007-08-05 14:16:49 -0700
commit4e6e122061b71f9378a161793367ae5120310ed4 (patch)
tree12ec2e76d023e43f61500fcc719fd311ddc67fdb /sql/field.h
parent71c3c0cfd57e1d37e4f04427388f8c473283540c (diff)
downloadmariadb-git-4e6e122061b71f9378a161793367ae5120310ed4.tar.gz
Fix bug #30219.
This bug manifested itself for queries with grouping by columns of the BIT type. It led to wrong comparisons of bit-field values and wrong result sets. Bit-field values never cannot be compared as binary values. Yet the class Field_bit had an implementation of the cmp method that compared bit-fields values as binary values. Also the get_image and set_image methods of the base class Field cannot be used for objects of the Field_bit class. Now these methods are declared as virtual and specific implementations of the methods are provided for the class Field_bit. mysql-test/r/type_bit.result: Added a test case for bug #30219. mysql-test/t/type_bit.test: Added a test case for bug #30219. sql/field.h: Fix bug #30219. This bug manifested itself for queries with grouping by columns of the BIT type. It led to wrong comparisons of bit-field values and wrong result sets. Bit-field values never cannot be compared as binary values. Yet the class Field_bit had an implementation of the cmp method that compared bit-fields values as binary values. Also the get_image and set_image methods of the base class Field cannot be used for objects of the Field_bit class. Now these methods are declared as virtual and specific implementations of these methods are provided for the class Field_bit.
Diffstat (limited to 'sql/field.h')
-rw-r--r--sql/field.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/sql/field.h b/sql/field.h
index fbf402ab5c3..92705b9aac4 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -231,9 +231,9 @@ public:
if (null_ptr)
null_ptr=ADD_TO_PTR(null_ptr,ptr_diff,uchar*);
}
- inline void get_image(char *buff,uint length, CHARSET_INFO *cs)
+ virtual void get_image(char *buff, uint length, CHARSET_INFO *cs)
{ memcpy(buff,ptr,length); }
- inline void set_image(char *buff,uint length, CHARSET_INFO *cs)
+ virtual void set_image(char *buff,uint length, CHARSET_INFO *cs)
{ memcpy(ptr,buff,length); }
@@ -1430,13 +1430,20 @@ public:
String *val_str(String*, String *);
my_decimal *val_decimal(my_decimal *);
int cmp(const char *a, const char *b)
- { return cmp_binary(a, b); }
+ {
+ DBUG_ASSERT(ptr == a);
+ return Field_bit::key_cmp(b, bytes_in_rec+test(bit_len));
+ }
int key_cmp(const byte *a, const byte *b)
{ return cmp_binary((char *) a, (char *) b); }
int key_cmp(const byte *str, uint length);
int cmp_offset(uint row_offset);
int cmp_binary_offset(uint row_offset)
{ return cmp_offset(row_offset); }
+ void get_image(char *buff, uint length, CHARSET_INFO *cs)
+ { get_key_image(buff, length, itRAW); }
+ void set_image(char *buff,uint length, CHARSET_INFO *cs)
+ { Field_bit::store(buff, length, cs); }
uint get_key_image(char *buff, uint length, imagetype type);
void set_key_image(char *buff, uint length)
{ Field_bit::store(buff, length, &my_charset_bin); }