Below is the list of changes that have just been committed into a local
6.1 repository of dlenev. When dlenev does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-02-16 11:26:10+03:00, dlenev@stripped +3 -0
Tentative fix for bug #34614 "Foreign Keys: syntax error with double reference".
According to the standard there can be several column foreign key constraints
defined for the same column but our grammar does not allow this.
This patch fixes grammar to support such constructs. Note that column foreign
key constraints are still ignored after parsing.
QQ: What about UNIQUE/NOT NULL/PRIMARY specifications? According to the
standard they are column constraints too and therefore can be
intermixed with referential constraints...
mysql-test/r/foreign_key.result@stripped, 2008-02-16 11:26:02+03:00, dlenev@stripped
+15 -0
Added test for bug #34614 "Foreign Keys: syntax error with double reference".
mysql-test/t/foreign_key.test@stripped, 2008-02-16 11:26:02+03:00, dlenev@stripped
+25 -0
Added test for bug #34614 "Foreign Keys: syntax error with double reference".
sql/sql_yacc.yy@stripped, 2008-02-16 11:26:02+03:00, dlenev@stripped +16 -5
Adjusted grammar to support several column foreign key constraints for the
one column as it is specified in the standard.
diff -Nrup a/mysql-test/r/foreign_key.result b/mysql-test/r/foreign_key.result
--- a/mysql-test/r/foreign_key.result 2008-02-13 21:05:31 +03:00
+++ b/mysql-test/r/foreign_key.result 2008-02-16 11:26:02 +03:00
@@ -55,3 +55,18 @@ add foreign key (a) references t3 (a)
on update set default on update set default);
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to
your MySQL server version for the right syntax to use near 'update set default)' at line
3
drop table t_34455;
+drop table if exists t1;
+create table t1 (
+a int references t2 (a) references t3 (a),
+b int references t2 references t3,
+c int references t2 (a) match full on update set null references t3 (a)
+on update cascade,
+d int constraint fk1 references t2 (a) constraint fk2 references t3 (a));
+alter table t1
+add column e int references t2 (a) references t3 (a),
+add column f int references t2 references t3,
+add column g int references t2 (a) match full on update set null
+references t3 (a) on update cascade,
+add column h int constraint fk1 references t2 (a)
+constraint fk2 references t3 (a);
+drop table t1;
diff -Nrup a/mysql-test/t/foreign_key.test b/mysql-test/t/foreign_key.test
--- a/mysql-test/t/foreign_key.test 2008-02-13 21:05:31 +03:00
+++ b/mysql-test/t/foreign_key.test 2008-02-16 11:26:02 +03:00
@@ -95,3 +95,28 @@ alter table t_34455
drop table t_34455;
+
+#
+# Bug #34614 "Foreign Keys: syntax error with double reference"
+#
+
+--disable_warnings
+drop table if exists t1;
+--enable_warnings
+
+create table t1 (
+ a int references t2 (a) references t3 (a),
+ b int references t2 references t3,
+ c int references t2 (a) match full on update set null references t3 (a)
+ on update cascade,
+ d int constraint fk1 references t2 (a) constraint fk2 references t3 (a));
+
+alter table t1
+ add column e int references t2 (a) references t3 (a),
+ add column f int references t2 references t3,
+ add column g int references t2 (a) match full on update set null
+ references t3 (a) on update cascade,
+ add column h int constraint fk1 references t2 (a)
+ constraint fk2 references t3 (a);
+
+drop table t1;
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy 2008-02-14 17:51:48 +03:00
+++ b/sql/sql_yacc.yy 2008-02-16 11:26:02 +03:00
@@ -4563,16 +4563,27 @@ field_list_item:
;
column_def:
- field_spec opt_check_constraint
+ field_spec
+ { Lex->ident= $1; }
+ column_constraint_list
{ }
- | field_spec opt_constraint references
+ ;
+
+column_constraint_list:
+ /* empty */ { }
+ | column_constraint_list column_constraint_def
+ ;
+
+column_constraint_def:
+ opt_constraint check_constraint
+ | opt_constraint references
{
THD *thd= YYTHD;
LEX *lex= thd->lex;
Key *key;
- lex->col_list.push_back(new (thd->mem_root) Key_part_spec($1.str));
- key= new (thd->mem_root) Foreign_key($2, FALSE, FALSE,
- lex->col_list, $3,
+ lex->col_list.push_back(new (thd->mem_root)
Key_part_spec(lex->ident.str));
+ key= new (thd->mem_root) Foreign_key($1, FALSE, FALSE,
+ lex->col_list, $2,
lex->ref_list,
lex->fk_delete_opt,
lex->fk_update_opt,