1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

MDEV-14668 ADD PRIMARY KEY IF NOT EXISTS on composite key.

Check the name of the primary key to be 'PRIMARY'. Than
differs it from any implicit primary keys created by an engine.
This commit is contained in:
Alexey Botchkov
2018-06-12 12:36:51 +04:00
parent 0ad9c3a016
commit 6b8d34fe0d
3 changed files with 42 additions and 1 deletions

View File

@ -5930,7 +5930,9 @@ drop_create_field:
/* Check if the table already has a PRIMARY KEY */
if (key->type == Key::PRIMARY &&
table->s->primary_key != MAX_KEY)
table->s->primary_key != MAX_KEY &&
(keyname= table->s->key_info[table->s->primary_key].name) &&
my_strcasecmp(system_charset_info, keyname, primary_key_name) == 0)
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
ER_DUP_KEYNAME, ER(ER_MULTIPLE_PRI_KEY));