Bug #1135 IF NOT EXISTS should be available for CREATE INDEX
Submitted: 25 Aug 2003 9:58 Modified: 9 Dec 2003 9:51
Reporter: Terrence Brannon Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S4 (Feature request)
Version: OS:
Assigned to: Assigned Account CPU Architecture:Any

[25 Aug 2003 9:58] Terrence Brannon
Description:
For consistency and because I need it, it would be nice if there were a "IF NOT EXISTS" clause for CREATE INDEX as there is for CREATE TABLE

How to repeat:
a

Suggested fix:
a
[25 Aug 2003 14:45] Alexander Keremidarski
Terrence,

We should consider this option, but I would ask yo to clarify what exactly do you mean.

1) Check if index with same Name exists and if exists don't create new one

2) Check if index with same Columns List in definition exists.

From what you wrote It looks like you want 1), but it is always better to clarify the details.

If you want 1) this simply means you wish to supress error message:

ERROR 1061: Duplicate key name 'index_name'

In case of 2) things are slightly more complicated.

Current behaviour is that MySQL allows creating such redundant indexes under different names. 

I agree there is much sence in disallowing such indexes, but then your proposed syntax will become completely inconsistant with CREATE TABLE IF NOT EXISTS
[26 Nov 2003 17:06] Peter Gulutzan
Status changed from "need feedback" to "closed".