[MDEV-14668] ADD PRIMARY KEY IF NOT EXISTS on composite key Created: 2017-12-15  Updated: 2018-06-12  Resolved: 2018-06-12

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: 10.0, 10.1, 10.0.31, 10.2.11, 10.2
Fix Version/s: 10.0.36

Type: Bug Priority: Major
Reporter: Antoine Lange Assignee: Alexey Botchkov
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux Mint


Issue Links:
Relates
relates to MDEV-8358 ALTER TABLE .. ADD PRIMARY KEY IF NOT... Closed

 Description   

I try to alter table to add a composite primary key with "if not exists clause" to a table. One of these column is already in a composite unique index with an other column.

I get warning code 1061 "Multiple primary key defined".
But without "IF NOT EXISTS", it works fine.

This is my example :

CREATE TABLE `HORIZON` (
	`ID` BIGINT(20) NOT NULL,
	`RANK` MEDIUMINT(4) NOT NULL,
	`CHECK_POINT` BIGINT(20) NOT NULL,
	UNIQUE INDEX `HORIZON_UIDX01` (`ID`, `RANK`)
) COLLATE='utf8_general_ci' ENGINE=InnoDB ;
 
ALTER TABLE `HORIZON` ADD PRIMARY KEY IF NOT EXISTS (`ID`, `CHECK_POINT`); /* warning code 1061 */
ALTER TABLE `HORIZON` ADD PRIMARY KEY (`ID`, `CHECK_POINT`); /* works fine */



 Comments   
Comment by Elena Stepanova [ 2017-12-16 ]

Thanks for the report and test case.

It appears to be related to MDEV-8358, thus assigning to holyfoot.

Comment by Alexey Botchkov [ 2018-06-12 ]

fixing patch
http://lists.askmonty.org/pipermail/commits/2018-June/012611.html

Generated at Thu Feb 08 08:15:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.