Commit b69ed7d6 authored by Alexey Botchkov's avatar Alexey Botchkov

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

        Added the IF NOT EXISTS option to the CONSTRAINT keyword.
parent 4157185f
......@@ -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;
......@@ -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;
......@@ -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
......
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