1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

Bug #13601: Wrong int type for bit

The wrong value was being reported as the field_length for BIT
  fields, resulting in confusion for at least Connector/J. The
  field_length is now always the number of bits in the field, as
  it should be.


mysql-test/r/type_bit.result:
  Add new results
mysql-test/r/type_bit_innodb.result:
  Add new results
mysql-test/t/type_bit.test:
  Add new regression test
mysql-test/t/type_bit_innodb.test:
  Add new regression test
sql/field.cc:
  Fix Field_bit->field_length to actually report the display width, and
  store the bytes stored in the rec in the new bytes_in_rec member.
sql/field.h:
  Fix Field_bit::field_length to store the correct value, adding
  Field_bit::bytes_in_rec to remember the number of bytes used for
  storing the value. Remove Field_bit_as_char::create_length, as it
  is now redundant.
sql/ha_ndbcluster.cc:
  Handle field_length of Field_bit actually being the display width (# of bits).
sql/key.cc:
  Fix inappropriate use of field->field_length for BIT field.
This commit is contained in:
unknown
2006-04-04 17:54:58 -07:00
parent bfa21dd152
commit b3b626c31c
8 changed files with 75 additions and 39 deletions

View File

@ -564,3 +564,12 @@ b1+0 sum(b1) sum(b2)
1 4 4
2 2 2
drop table t1, t2;
create table t1 (a bit(7));
insert into t1 values (0x60);
select * from t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 a a 16 7 1 Y 0 0 63
a
`
drop table t1;
End of 5.0 tests

View File

@ -402,3 +402,12 @@ t1 CREATE TABLE `t1` (
`b` bit(10) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a bit(7)) engine=innodb;
insert into t1 values (0x60);
select * from t1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t1 t1 a a 16 7 1 Y 0 0 63
a
`
drop table t1;
End of 5.0 tests

View File

@ -227,3 +227,15 @@ select sum(a1), b1+0, b2+0 from t1 join t2 on b1 = b2 group by b1 order by 1;
select 1 from t1 join t2 on b1 = b2 group by b1 order by 1;
select b1+0,sum(b1), sum(b2) from t1 join t2 on b1 = b2 group by b1 order by 1;
drop table t1, t2;
#
# Bug #13601: Wrong field length reported for BIT fields
#
create table t1 (a bit(7));
insert into t1 values (0x60);
--enable_metadata
select * from t1;
--disable_metadata
drop table t1;
--echo End of 5.0 tests

View File

@ -133,3 +133,15 @@ show create table t1;
alter table t1 engine=innodb;
show create table t1;
drop table t1;
#
# Bug #13601: Wrong field length reported for BIT fields
#
create table t1 (a bit(7)) engine=innodb;
insert into t1 values (0x60);
--enable_metadata
select * from t1;
--disable_metadata
drop table t1;
--echo End of 5.0 tests