summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorhf@deer.(none) <>2003-12-02 19:06:24 +0400
committerhf@deer.(none) <>2003-12-02 19:06:24 +0400
commit02f382ecaa7b60c4da4a25434cdf80f2631e0b80 (patch)
treee42d6f69d6d5e61fe9558a68a021327bebf6c221 /sql
parent05e4d9031bace425b4b4747ffe1e8b2114b2a625 (diff)
downloadmariadb-git-02f382ecaa7b60c4da4a25434cdf80f2631e0b80.tar.gz
Fix for #1189 (Mess with names about CONSTRAINT)
Second edition: error message was deleted as Segey suggested Now name of the constraint will be used as the name of the key if the last not specified
Diffstat (limited to 'sql')
-rw-r--r--sql/sql_yacc.yy27
1 files changed, 18 insertions, 9 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 805dc9f1932..8fe69ad6ae3 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -598,7 +598,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
%type <simple_string>
remember_name remember_end opt_ident opt_db text_or_password
- opt_escape
+ opt_escape opt_constraint
%type <string>
text_string opt_gconcat_separator
@@ -631,7 +631,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize);
expr_list udf_expr_list when_list ident_list ident_list_arg
%type <key_type>
- key_type opt_unique_or_fulltext
+ key_type opt_unique_or_fulltext constraint_key_type
%type <key_alg>
key_alg opt_btree_or_rtree
@@ -1189,6 +1189,13 @@ key_def:
lex->key_list.push_back(new Key($1,$2, $3, lex->col_list));
lex->col_list.empty(); /* Alloced by sql_alloc */
}
+ | opt_constraint constraint_key_type opt_ident key_alg '(' key_list ')'
+ {
+ LEX *lex=Lex;
+ const char *key_name= $3 ? $3:$1;
+ lex->key_list.push_back(new Key($2, key_name, $4, lex->col_list));
+ lex->col_list.empty(); /* Alloced by sql_alloc */
+ }
| opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references
{
LEX *lex=Lex;
@@ -1212,8 +1219,8 @@ check_constraint:
;
opt_constraint:
- /* empty */
- | CONSTRAINT opt_ident;
+ /* empty */ { $$=(char*) 0; }
+ | CONSTRAINT opt_ident { $$=$2; };
field_spec:
field_ident
@@ -1575,14 +1582,16 @@ delete_option:
| SET DEFAULT { $$= (int) foreign_key::FK_OPTION_DEFAULT; };
key_type:
- opt_constraint PRIMARY_SYM KEY_SYM { $$= Key::PRIMARY; }
- | key_or_index { $$= Key::MULTIPLE; }
+ key_or_index { $$= Key::MULTIPLE; }
| FULLTEXT_SYM { $$= Key::FULLTEXT; }
| FULLTEXT_SYM key_or_index { $$= Key::FULLTEXT; }
| SPATIAL_SYM { $$= Key::SPATIAL; }
- | SPATIAL_SYM key_or_index { $$= Key::SPATIAL; }
- | opt_constraint UNIQUE_SYM { $$= Key::UNIQUE; }
- | opt_constraint UNIQUE_SYM key_or_index { $$= Key::UNIQUE; };
+ | SPATIAL_SYM key_or_index { $$= Key::SPATIAL; };
+
+constraint_key_type:
+ PRIMARY_SYM KEY_SYM { $$= Key::PRIMARY; }
+ | UNIQUE_SYM { $$= Key::UNIQUE; }
+ | UNIQUE_SYM key_or_index { $$= Key::UNIQUE; };
key_or_index:
KEY_SYM {}