Commit b2dbaea3 authored by ramil@mysql.com's avatar ramil@mysql.com

Bit type: fix for create_field::create_field().

parent da9a6aec
...@@ -380,3 +380,25 @@ drop table t1; ...@@ -380,3 +380,25 @@ drop table t1;
create table t1(a int, b bit not null) engine=innodb; create table t1(a int, b bit not null) engine=innodb;
alter table t1 add primary key (a); alter table t1 add primary key (a);
drop table t1; drop table t1;
create table t1 (a bit, b bit(10)) engine=innodb;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bit(1) default NULL,
`b` bit(10) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
alter table t1 engine=heap;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bit(1) default NULL,
`b` bit(10) default NULL
) ENGINE=MEMORY DEFAULT CHARSET=latin1
alter table t1 engine=innodb;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` bit(1) default NULL,
`b` bit(10) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
drop table t1;
...@@ -121,3 +121,15 @@ drop table t1; ...@@ -121,3 +121,15 @@ drop table t1;
create table t1(a int, b bit not null) engine=innodb; create table t1(a int, b bit not null) engine=innodb;
alter table t1 add primary key (a); alter table t1 add primary key (a);
drop table t1; drop table t1;
#
# altering tables
#
create table t1 (a bit, b bit(10)) engine=innodb;
show create table t1;
alter table t1 engine=heap;
show create table t1;
alter table t1 engine=innodb;
show create table t1;
drop table t1;
...@@ -8358,7 +8358,9 @@ create_field::create_field(Field *old_field,Field *orig_field) ...@@ -8358,7 +8358,9 @@ create_field::create_field(Field *old_field,Field *orig_field)
break; break;
#endif #endif
case FIELD_TYPE_BIT: case FIELD_TYPE_BIT:
length= ((Field_bit *) old_field)->bit_len + length * 8; length= (old_field->key_type() == HA_KEYTYPE_BIT) ?
((Field_bit *) old_field)->bit_len + length * 8 :
((Field_bit_as_char *) old_field)->create_length;
break; break;
default: default:
break; break;
......
...@@ -1313,9 +1313,8 @@ public: ...@@ -1313,9 +1313,8 @@ public:
class Field_bit_as_char: public Field_bit { class Field_bit_as_char: public Field_bit {
protected:
uchar create_length;
public: public:
uchar create_length;
Field_bit_as_char(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, Field_bit_as_char(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg, uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const char *field_name_arg,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment