Commit 21e2c72b authored by unknown's avatar unknown

a fix (bug #2361: ALTER TABLE ... DROP PRIMARY KEY drops a non-primary key).

parent 41b3fb05
...@@ -412,3 +412,12 @@ t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE ...@@ -412,3 +412,12 @@ t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (a int UNIQUE);
ALTER TABLE t1 DROP PRIMARY KEY;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) default NULL,
UNIQUE KEY `a` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
...@@ -244,3 +244,12 @@ LOCK TABLES t1 WRITE; ...@@ -244,3 +244,12 @@ LOCK TABLES t1 WRITE;
ALTER TABLE t1 DISABLE KEYS; ALTER TABLE t1 DISABLE KEYS;
SHOW INDEX FROM t1; SHOW INDEX FROM t1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug 2361
#
CREATE TABLE t1 (a int UNIQUE);
ALTER TABLE t1 DROP PRIMARY KEY;
SHOW CREATE TABLE t1;
DROP TABLE t1;
...@@ -2242,13 +2242,15 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, ...@@ -2242,13 +2242,15 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
KEY *key_info=table->key_info; KEY *key_info=table->key_info;
for (uint i=0 ; i < table->keys ; i++,key_info++) for (uint i=0 ; i < table->keys ; i++,key_info++)
{ {
if (drop_primary && (key_info->flags & HA_NOSAME)) char *key_name= key_info->name;
if (drop_primary && !my_strcasecmp(system_charset_info, key_name,
"PRIMARY"))
{ {
drop_primary=0; drop_primary= 0;
continue; continue;
} }
char *key_name=key_info->name;
Alter_drop *drop; Alter_drop *drop;
drop_it.rewind(); drop_it.rewind();
while ((drop=drop_it++)) while ((drop=drop_it++))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment