summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <mattiasj@witty.local>2008-02-07 12:28:38 +0100
committerunknown <mattiasj@witty.local>2008-02-07 12:28:38 +0100
commitb2f0ed637171a1658699e3084c3a68710fefac93 (patch)
tree1c23bc4f74fcd6be5eb117b8f31a59c4893684a9
parent324d54170144dc8926258a13ef514a77ce170506 (diff)
downloadmariadb-git-b2f0ed637171a1658699e3084c3a68710fefac93.tar.gz
Bug#33379: valgrind error in parts/partition_bit_myisam
Problem was that Field_bit used Field::hash() function that did not know about using null-byte for storing bits. Resulting in wrong length, which was caught by valgrind. Solution: created a Field_bit::hash() that uses Field_bit::val_int() and my_charset_bin-collation function hash_sort. Also use the store function for platform independs mysql-test/r/partition_datatype.result: Bug#33379: valgrind error in parts/partition_bit_myisam result file enabled bit datatype test mysql-test/t/partition_datatype.test: Bug#33379: valgrind error in parts/partition_bit_myisam test file enabled bit datatype test sql/field.cc: Bug#33379: valgrind error in parts/partition_bit_myisam Problem was that Field_bit used Field::hash() function that did not know about using null-byte for storing bits. Resulting in wrong length. Solution: created a Field_bit::hash() that uses Field_bit::val_int() and my_charset_bin-collation function hash_sort. Also use the store function for platform independens. sql/field.h: Bug#33379: valgrind error in parts/partition_bit_myisam Problem was that Field_bit used Field::hash() function that did not know about using null-byte for storing bits. Resulting in wrong length. Solution: created a Field_bit::hash().
-rw-r--r--mysql-test/r/partition_datatype.result14
-rw-r--r--mysql-test/t/partition_datatype.test20
-rw-r--r--sql/field.cc17
-rw-r--r--sql/field.h1
4 files changed, 42 insertions, 10 deletions
diff --git a/mysql-test/r/partition_datatype.result b/mysql-test/r/partition_datatype.result
index c6506178b03..242e67de9e0 100644
--- a/mysql-test/r/partition_datatype.result
+++ b/mysql-test/r/partition_datatype.result
@@ -1,4 +1,11 @@
drop table if exists t1;
+# test with not null
+create table t1 (a bit not null) partition by key (a);
+insert into t1 values (b'1');
+select hex(a) from t1 where a = b'1';
+hex(a)
+1
+drop table t1;
create table t1 (a tinyint not null) partition by key (a);
insert into t1 values (2);
select * from t1 where a = 2;
@@ -125,6 +132,13 @@ select * from t1 where a = 'y';
a
y
drop table t1;
+# test with null allowed
+create table t1 (a bit) partition by key (a);
+insert into t1 values (b'1');
+select hex(a) from t1 where a = b'1';
+hex(a)
+1
+drop table t1;
create table t1 (a tinyint) partition by key (a);
insert into t1 values (2);
select * from t1 where a = 2;
diff --git a/mysql-test/t/partition_datatype.test b/mysql-test/t/partition_datatype.test
index 61d3cb42c7b..d6e65c3406e 100644
--- a/mysql-test/t/partition_datatype.test
+++ b/mysql-test/t/partition_datatype.test
@@ -11,11 +11,11 @@
drop table if exists t1;
--enable_warnings
-# FIXME: disabled this test because of valgrind error
-#create table t1 (a bit not null) partition by key (a);
-#insert into t1 values (b'1');
-#select * from t1 where a = b'1';
-#drop table t1;
+-- echo # test with not null
+create table t1 (a bit not null) partition by key (a);
+insert into t1 values (b'1');
+select hex(a) from t1 where a = b'1';
+drop table t1;
create table t1 (a tinyint not null) partition by key (a);
insert into t1 values (2);
select * from t1 where a = 2;
@@ -100,11 +100,11 @@ create table t1 (a set('y','n') not null) partition by key (a);
insert into t1 values ('y');
select * from t1 where a = 'y';
drop table t1;
-# FIXME: disabled this test because of valgrind error
-#create table t1 (a bit) partition by key (a);
-#insert into t1 values (b'1');
-#select * from t1 where a = b'1';
-#drop table t1;
+-- echo # test with null allowed
+create table t1 (a bit) partition by key (a);
+insert into t1 values (b'1');
+select hex(a) from t1 where a = b'1';
+drop table t1;
create table t1 (a tinyint) partition by key (a);
insert into t1 values (2);
select * from t1 where a = 2;
diff --git a/sql/field.cc b/sql/field.cc
index 7c4f6c9ff5f..88fac96df89 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -8793,6 +8793,23 @@ Field_bit::Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
}
+void Field_bit::hash(ulong *nr, ulong *nr2)
+{
+ if (is_null())
+ {
+ *nr^= (*nr << 1) | 1;
+ }
+ else
+ {
+ CHARSET_INFO *cs= &my_charset_bin;
+ longlong value= Field_bit::val_int();
+ uchar tmp[8];
+ mi_int8store(tmp,value);
+ cs->coll->hash_sort(cs, tmp, 8, nr, nr2);
+ }
+}
+
+
size_t
Field_bit::do_last_null_byte() const
{
diff --git a/sql/field.h b/sql/field.h
index a6a1d8bfabc..38a0b1d5bbd 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1904,6 +1904,7 @@ public:
Field::move_field_offset(ptr_diff);
bit_ptr= ADD_TO_PTR(bit_ptr, ptr_diff, uchar*);
}
+ void hash(ulong *nr, ulong *nr2);
private:
virtual size_t do_last_null_byte() const;