Skip to content

Commit

Permalink
MDEV-8582: innodb_force_primary_key option does not force PK or uniqu…
Browse files Browse the repository at this point in the history
…e key

Analysis: Handler used table flag HA_REQUIRE_PRIMARY_KEY but a bug on
sql_table.cc function mysql_prepare_create_table internally marked
secondary key with NOT NULL colums as unique key and did not then
fail on requirement that table should have primary key or unique key.
  • Loading branch information
Jan Lindström committed Aug 8, 2015
1 parent 3307eaa commit 46ad86f
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4042,7 +4042,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info,
my_error(ER_WRONG_NAME_FOR_INDEX, MYF(0), key_info->name);
DBUG_RETURN(TRUE);
}
if (!(key_info->flags & HA_NULL_PART_KEY))
if (key->type == Key::UNIQUE && !(key_info->flags & HA_NULL_PART_KEY))
unique_key=1;
key_info->key_length=(uint16) key_length;
if (key_length > max_key_length && key->type != Key::FULLTEXT)
Expand Down
5 changes: 0 additions & 5 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11134,11 +11134,6 @@ innobase_table_flags(
}
}

if (srv_force_primary_key && form->s->primary_key >= MAX_KEY) {
my_error(ER_REQUIRES_PRIMARY_KEY, MYF(0));
DBUG_RETURN(false);
}

row_format = form->s->row_type;

if (create_info->key_block_size) {
Expand Down
5 changes: 0 additions & 5 deletions storage/xtradb/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11645,11 +11645,6 @@ innobase_table_flags(
}
}

if (srv_force_primary_key && form->s->primary_key >= MAX_KEY) {
my_error(ER_REQUIRES_PRIMARY_KEY, MYF(0));
DBUG_RETURN(false);
}

row_format = form->s->row_type;

if (create_info->key_block_size) {
Expand Down

0 comments on commit 46ad86f

Please sign in to comment.