Commit fddccb6e authored by unknown's avatar unknown
Browse files

Fix for bug #9571: Primary key creation causes server crash.


sql/unireg.cc:
  Fix for bug #9571: Primary key creation causes server crash.
  We should pass null_pos to the make_field() anyway,
  as we use it for bit fields.
parent 2cb2374b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -377,3 +377,6 @@ hex(concat(a)) hex(concat(b))
07	0FFE
01	01FF
drop table t1;
create table t1(a int, b bit not null);
alter table t1 add primary key (a);
drop table t1;
+8 −0
Original line number Diff line number Diff line
@@ -112,3 +112,11 @@ insert into t1 values (7,(1<<12)-2), (0x01,0x01ff);
select hex(a),hex(b) from t1;
select hex(concat(a)),hex(concat(b)) from t1;
drop table t1;

#
# Bug #9571: problem with primary key creation
#

create table t1(a int, b bit not null);
alter table t1 add primary key (a);
drop table t1;
+2 −3
Original line number Diff line number Diff line
@@ -679,15 +679,14 @@ static bool make_empty_rec(THD *thd, File file,enum db_type table_type,
    null_count++;
  }
  bfill(buff,(null_length=(null_fields+7)/8),255);
  null_pos=buff;
  null_pos= buff + null_count / 8;

  List_iterator<create_field> it(create_fields);
  thd->count_cuted_fields= CHECK_FIELD_WARN;    // To find wrong default values
  while ((field=it++))
  {
    Field *regfield=make_field((char*) buff+field->offset,field->length,
			       field->flags & NOT_NULL_FLAG ? 0:
			       null_pos+null_count/8,
                               null_pos,
			       null_count & 7,
			       field->pack_flag,
			       field->sql_type,