diff options
author | ramil@mysql.com <> | 2005-04-14 14:32:25 +0500 |
---|---|---|
committer | ramil@mysql.com <> | 2005-04-14 14:32:25 +0500 |
commit | b2dbaea39416cfb57ad73db2f72b1d1b86036e5a (patch) | |
tree | 61fc317c0336a71118ecd4b929bdf84c02d11972 | |
parent | da9a6aecadb324dee97c2db85f45a21c05fc9a07 (diff) | |
download | mariadb-git-b2dbaea39416cfb57ad73db2f72b1d1b86036e5a.tar.gz |
Bit type: fix for create_field::create_field().
-rw-r--r-- | mysql-test/r/type_bit_innodb.result | 22 | ||||
-rw-r--r-- | mysql-test/t/type_bit_innodb.test | 12 | ||||
-rw-r--r-- | sql/field.cc | 4 | ||||
-rw-r--r-- | sql/field.h | 3 |
4 files changed, 38 insertions, 3 deletions
diff --git a/mysql-test/r/type_bit_innodb.result b/mysql-test/r/type_bit_innodb.result index 57068f6502a..f3e9dad3baa 100644 --- a/mysql-test/r/type_bit_innodb.result +++ b/mysql-test/r/type_bit_innodb.result @@ -380,3 +380,25 @@ drop table t1; create table t1(a int, b bit not null) engine=innodb; alter table t1 add primary key (a); 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; diff --git a/mysql-test/t/type_bit_innodb.test b/mysql-test/t/type_bit_innodb.test index 6410b98fcd0..693fc169717 100644 --- a/mysql-test/t/type_bit_innodb.test +++ b/mysql-test/t/type_bit_innodb.test @@ -121,3 +121,15 @@ drop table t1; create table t1(a int, b bit not null) engine=innodb; alter table t1 add primary key (a); 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; diff --git a/sql/field.cc b/sql/field.cc index ea551f410b7..00f729d5b07 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -8358,7 +8358,9 @@ create_field::create_field(Field *old_field,Field *orig_field) break; #endif 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; default: break; diff --git a/sql/field.h b/sql/field.h index 6a1a7af194e..22787850442 100644 --- a/sql/field.h +++ b/sql/field.h @@ -1313,9 +1313,8 @@ public: class Field_bit_as_char: public Field_bit { -protected: - uchar create_length; public: + uchar create_length; 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, enum utype unireg_check_arg, const char *field_name_arg, |