mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
MDEV-8212 alter table - failing to ADD PRIMARY KEY IF NOT EXISTS when existing index of same as column name.
The default name for the primary key is rather 'PRIMARY' instead of the indexed column name.
This commit is contained in:
@ -5859,12 +5859,17 @@ drop_create_field:
|
||||
/* let us check the name of the first key part. */
|
||||
if ((keyname= key->name.str) == NULL)
|
||||
{
|
||||
List_iterator<Key_part_spec> part_it(key->columns);
|
||||
Key_part_spec *kp;
|
||||
if ((kp= part_it++))
|
||||
keyname= kp->field_name.str;
|
||||
if (keyname == NULL)
|
||||
continue;
|
||||
if (key->type == Key::PRIMARY)
|
||||
keyname= primary_key_name;
|
||||
else
|
||||
{
|
||||
List_iterator<Key_part_spec> part_it(key->columns);
|
||||
Key_part_spec *kp;
|
||||
if ((kp= part_it++))
|
||||
keyname= kp->field_name.str;
|
||||
if (keyname == NULL)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (key->type != Key::FOREIGN_KEY)
|
||||
{
|
||||
|
Reference in New Issue
Block a user