MDEV-4437 ALTER TABLE .. ADD UNIQUE INDEX IF NOT EXISTS causes syntax error.

Added the IF NOT EXISTS option to the CONSTRAINT keyword.
This commit is contained in:
Alexey Botchkov 2013-11-14 14:31:30 +04:00
parent 4157185f24
commit b69ed7d621
3 changed files with 24 additions and 3 deletions

View File

@ -1907,3 +1907,15 @@ t1 CREATE TABLE `t1` (
`b` bigint(20) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
create table t1 (i int);
alter table t1 add unique index if not exists idx(i);
alter table t1 add unique index if not exists idx(i);
Warnings:
Note 1061 Duplicate key name 'idx'
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`i` int(11) DEFAULT NULL,
UNIQUE KEY `idx` (`i`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;

View File

@ -1651,3 +1651,12 @@ alter table t1 change column if exists a b bigint;
show create table t1;
DROP TABLE t1;
#
# MDEV-4437 ALTER TABLE .. ADD UNIQUE INDEX IF NOT EXISTS causes syntax error.
#
create table t1 (i int);
alter table t1 add unique index if not exists idx(i);
alter table t1 add unique index if not exists idx(i);
show create table t1;
DROP TABLE t1;

View File

@ -955,10 +955,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%parse-param { THD *thd }
%lex-param { THD *thd }
/*
Currently there are 164 shift/reduce conflicts.
Currently there are 163 shift/reduce conflicts.
We should not introduce new conflicts any more.
*/
%expect 164
%expect 163
/*
Comments for TOKENS.
@ -5900,7 +5900,7 @@ key_def:
if (add_create_index (Lex, $1, $3))
MYSQL_YYABORT;
}
| opt_constraint constraint_key_type opt_ident key_alg
| opt_constraint constraint_key_type opt_if_not_exists_ident key_alg
'(' key_list ')'
{ Lex->option_list= NULL; }
normal_key_options