summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorSergei Golubchik <serg@mariadb.org>2015-11-19 15:52:14 +0100
committerSergei Golubchik <serg@mariadb.org>2015-11-19 15:52:14 +0100
commitbeded7d9c9592ca8fdfc367f7c64f89c35995c44 (patch)
treea215a54ed5043bb17fe7d69a69439e05b21682d5 /sql/sql_table.cc
parentaf71da5d2f90c82b2357e808640003907c488bc2 (diff)
parent2553f143fdeb9068eb02a8fda58750c24071f5ef (diff)
downloadmariadb-git-beded7d9c9592ca8fdfc367f7c64f89c35995c44.tar.gz
Merge branch '10.0' into 10.1
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 35d736ea8a3..5af13273130 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -5848,6 +5848,13 @@ drop_create_field:
{
if (!key->if_not_exists() && !key->or_replace())
continue;
+
+ /* Check if the table already has a PRIMARY KEY */
+ bool dup_primary_key= key->type == Key::PRIMARY &&
+ table->s->primary_key != MAX_KEY;
+ if (dup_primary_key)
+ goto remove_key;
+
/* If the name of the key is not specified, */
/* let us check the name of the first key part. */
if ((keyname= key->name.str) == NULL)
@@ -5915,8 +5922,8 @@ remove_key:
if (key->if_not_exists())
{
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
- ER_DUP_KEYNAME, ER_THD(thd, ER_DUP_KEYNAME),
- keyname);
+ ER_DUP_KEYNAME, ER_THD(thd, dup_primary_key
+ ? ER_MULTIPLE_PRI_KEY : ER_DUP_KEYNAME), keyname);
key_it.remove();
if (key->type == Key::FOREIGN_KEY)
{