mirror of
https://github.com/MariaDB/server.git
synced 2025-01-31 02:51:44 +01:00
Fix for bug #28631: Bit index creation failure after alter
Problem: altering a bit field we use Field::is_equal() to check if the bit field is changed. Comparing the field type is not enough for bit fields. Fix: add proper Field_bit::is_equal() that compares the field lengths as well.
This commit is contained in:
parent
8a9fd5995e
commit
4f68dd9d78
4 changed files with 51 additions and 0 deletions
|
@ -619,3 +619,29 @@ bit_field int_field
|
|||
handler t1 close;
|
||||
drop table t1;
|
||||
End of 5.0 tests
|
||||
create table t1(a bit(7));
|
||||
insert into t1 values(0x40);
|
||||
alter table t1 modify column a bit(8);
|
||||
select hex(a) from t1;
|
||||
hex(a)
|
||||
40
|
||||
insert into t1 values(0x80);
|
||||
select hex(a) from t1;
|
||||
hex(a)
|
||||
40
|
||||
80
|
||||
create index a on t1(a);
|
||||
insert into t1 values(0x81);
|
||||
select hex(a) from t1;
|
||||
hex(a)
|
||||
40
|
||||
80
|
||||
81
|
||||
show create table t1;
|
||||
Table Create Table
|
||||
t1 CREATE TABLE `t1` (
|
||||
`a` bit(8) DEFAULT NULL,
|
||||
KEY `a` (`a`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t1;
|
||||
End of 5.1 tests
|
||||
|
|
|
@ -273,3 +273,20 @@ handler t1 close;
|
|||
drop table t1;
|
||||
|
||||
--echo End of 5.0 tests
|
||||
|
||||
#
|
||||
# Bug #28631: problem after alter
|
||||
#
|
||||
create table t1(a bit(7));
|
||||
insert into t1 values(0x40);
|
||||
alter table t1 modify column a bit(8);
|
||||
select hex(a) from t1;
|
||||
insert into t1 values(0x80);
|
||||
select hex(a) from t1;
|
||||
create index a on t1(a);
|
||||
insert into t1 values(0x81);
|
||||
select hex(a) from t1;
|
||||
show create table t1;
|
||||
drop table t1;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
|
|
@ -8239,6 +8239,13 @@ Field *Field_bit::new_key_field(MEM_ROOT *root,
|
|||
}
|
||||
|
||||
|
||||
uint Field_bit::is_equal(create_field *new_field)
|
||||
{
|
||||
return (new_field->sql_type == real_type() &&
|
||||
new_field->length == max_display_length());
|
||||
}
|
||||
|
||||
|
||||
int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs)
|
||||
{
|
||||
ASSERT_COLUMN_MARKED_FOR_WRITE;
|
||||
|
|
|
@ -1552,6 +1552,7 @@ public:
|
|||
bit_ptr == ((Field_bit *)field)->bit_ptr &&
|
||||
bit_ofs == ((Field_bit *)field)->bit_ofs);
|
||||
}
|
||||
uint is_equal(create_field *new_field);
|
||||
void move_field_offset(my_ptrdiff_t ptr_diff)
|
||||
{
|
||||
Field::move_field_offset(ptr_diff);
|
||||
|
|
Loading…
Add table
Reference in a new issue