List:Commits« Previous MessageNext Message »
From:dlenev Date:April 18 2008 1:49pm
Subject:bk commit into 6.1 tree (dlenev:1.2606) BUG#35522
View as plain text  
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-04-18 15:49:35+04:00, dlenev@stripped +4 -0
  Fix for bug #35522 "Foreign keys: 'foreign key without name' errors".
  
  In --foreign-key-all-engines mode we should not replace names of FKs
  in error messages with 'foreign key without name' even if though names
  are automatically generated and are not known to user.
  
  Changed code to do just that.

  mysql-test/r/foreign_key_all_engines.result@stripped, 2008-04-18 15:49:29+04:00,
dlenev@stripped +12 -3
    Added test case for bug #35522 "Foreign keys: 'foreign key without name'
    errors". Adjusted results of other test cases which changed due to bugfix.

  mysql-test/t/foreign_key_all_engines.test@stripped, 2008-04-18 15:49:29+04:00,
dlenev@stripped +20 -0
    Added test case for bug #35522 "Foreign keys: 'foreign key without name'
    errors".

  sql/fk_dd.cc@stripped, 2008-04-18 15:49:29+04:00, dlenev@stripped +3 -9
    Don't hide foreign key name in error messages even tough it was generated.

  sql/sql_table.cc@stripped, 2008-04-18 15:49:29+04:00, dlenev@stripped +1 -2
    There is no need to check Foreign_key::is_name_generated flag
    if opt_fk_all_engines is false since this member is always false
    in this case.

diff -Nrup a/mysql-test/r/foreign_key_all_engines.result
b/mysql-test/r/foreign_key_all_engines.result
--- a/mysql-test/r/foreign_key_all_engines.result	2008-03-21 12:42:51 +03:00
+++ b/mysql-test/r/foreign_key_all_engines.result	2008-04-18 15:49:29 +04:00
@@ -226,11 +226,11 @@ drop table t1, t2;
 drop database mysqltest;
 create table t2 (a int, b int, primary key (a,b));
 create table t1 (fk1 int, fk2 int, foreign key (fk1, fk2) references t2);
-ERROR 42000: Foreign key error: Constraint 'foreign key without name': '(parent column
list)' is mandatory in MySQL
+ERROR 42000: Foreign key error: Constraint 'fk_t1_1_7507': '(parent column list)' is
mandatory in MySQL
 create table t1 (fk1 int, fk2 int, foreign key (fk1, fk2) references t2 (a, b) match
partial);
-ERROR 42000: Foreign key error: Constraint 'foreign key without name': MATCH PARTIAL not
supported
+ERROR 42000: Foreign key error: Constraint 'fk_t1_1_828': MATCH PARTIAL not supported
 create table t1 (fk1 int references t2 (a, b));
-ERROR 42000: Foreign key error: Constraint 'foreign key without name': Parent column
count (2) not equal to child column count (1)
+ERROR 42000: Foreign key error: Constraint 'fk_t1_1_1619': Parent column count (2) not
equal to child column count (1)
 drop table t2;
 create table t1 (a int primary key);
 create table t2 (fk int
@@ -269,3 +269,12 @@ drop table t3;
 use test;
 drop database mysqltest;
 drop table t1, t2;
+set @@rand_seed1=10000000,@@rand_seed2=1000000;
+set @@pseudo_thread_id= 1;
+drop tables if exists t1, t2;
+create table t2 (a int primary key);
+create table t1 (fk1 int references t2 (a, b));
+ERROR 42000: Foreign key error: Constraint 'fk_t1_1_288': Parent column count (2) not
equal to child column count (1)
+create table t1 (fk1 int, foreign key (fk1) references t2 (a, b));
+ERROR 42000: Foreign key error: Constraint 'fk_t1_1_1164': Parent column count (2) not
equal to child column count (1)
+drop table t2;
diff -Nrup a/mysql-test/t/foreign_key_all_engines.test
b/mysql-test/t/foreign_key_all_engines.test
--- a/mysql-test/t/foreign_key_all_engines.test	2008-03-21 12:42:51 +03:00
+++ b/mysql-test/t/foreign_key_all_engines.test	2008-04-18 15:49:29 +04:00
@@ -176,3 +176,23 @@ drop table t3;
 use test;
 drop database mysqltest;
 drop table t1, t2;
+
+
+#
+# Test for bug #35522 "Foreign keys: 'foreign key without name' errors"
+# In --foreign-key-all-engines mode we should not replace names of FKs
+# in error messages with 'foreign key without name' even if though names
+# are automatically generated and are not known to user.
+
+# Ensure that automatically generated names are stable
+set @@rand_seed1=10000000,@@rand_seed2=1000000;
+set @@pseudo_thread_id= 1;
+--disable_warnings
+drop tables if exists t1, t2;
+--enable_warnings
+create table t2 (a int primary key);
+--error ER_FK_PARENT_COLUMN_COUNT
+create table t1 (fk1 int references t2 (a, b));
+--error ER_FK_PARENT_COLUMN_COUNT
+create table t1 (fk1 int, foreign key (fk1) references t2 (a, b));
+drop table t2;
diff -Nrup a/sql/fk_dd.cc b/sql/fk_dd.cc
--- a/sql/fk_dd.cc	2008-03-20 19:46:47 +03:00
+++ b/sql/fk_dd.cc	2008-04-18 15:49:29 +04:00
@@ -814,25 +814,19 @@ bool fk_check_constraint_added(Foreign_k
 
   if (fkey->match_opt == Foreign_key::FK_MATCH_PARTIAL)
   {
-    my_error(ER_FK_MATCH_PARTIAL, MYF(0),
-             ((fkey->name.str && !fkey->is_name_generated) ?
-              fkey->name.str : "foreign key without name"));
+    my_error(ER_FK_MATCH_PARTIAL, MYF(0), fkey->name.str);
     DBUG_RETURN(TRUE);
   }
 
   if (!fkey->ref_columns.elements)
   {
-    my_error(ER_FK_PARENT_COLUMN_MANDATORY, MYF(0),
-             ((fkey->name.str && !fkey->is_name_generated) ?
-              fkey->name.str : "foreign key without name"));
+    my_error(ER_FK_PARENT_COLUMN_MANDATORY, MYF(0), fkey->name.str);
     DBUG_RETURN(TRUE);
   }
 
   if (fkey->ref_columns.elements != fkey->columns.elements)
   {
-    my_error(ER_FK_PARENT_COLUMN_COUNT, MYF(0),
-             ((fkey->name.str && !fkey->is_name_generated) ?
-              fkey->name.str : "foreign key without name"),
+    my_error(ER_FK_PARENT_COLUMN_COUNT, MYF(0), fkey->name.str,
              fkey->ref_columns.elements, fkey->columns.elements);
     DBUG_RETURN(TRUE);
   }
diff -Nrup a/sql/sql_table.cc b/sql/sql_table.cc
--- a/sql/sql_table.cc	2008-03-21 12:42:51 +03:00
+++ b/sql/sql_table.cc	2008-04-18 15:49:29 +04:00
@@ -2559,8 +2559,7 @@ mysql_prepare_create_table(THD *thd, con
           fkey->ref_columns.elements != fkey->columns.elements)
       {
         my_error(ER_WRONG_FK_DEF, MYF(0),
-                 ((fkey->name.str && !fkey->is_name_generated) ?
-                  fkey->name.str : "foreign key without name"),
+                 fkey->name.str ? fkey->name.str : "foreign key without name",
                  ER(ER_KEY_REF_DO_NOT_MATCH_TABLE_REF));
         DBUG_RETURN(TRUE);
       }
Thread
bk commit into 6.1 tree (dlenev:1.2606) BUG#35522dlenev18 Apr