List:Commits« Previous MessageNext Message »
From:dlenev Date:April 20 2008 2:57pm
Subject:bk commit into 6.1 tree (dlenev:1.2609) BUG#35531
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-20 18:57:10+04:00, dlenev@stripped +3 -0
  Fix for bug #35531 "Foreign keys: comment clause misplaced".
  
  Clauses for column referential constraints were erroneously
  placed before comment clause in SHOW CREATE TABLE output.
  Since with current syntax referential clause must be last
  clause of column definition it was impossible to correctly
  restore table with columns having both comment and referential
  constraint clause from SHOW CREATE TABLE output.
  
  Fixed SHOW CREATE TABLE to produce correct output.

  mysql-test/r/foreign_key_all_engines.result@stripped, 2008-04-20 18:57:07+04:00, dlenev@stripped +19 -0
    Added test for bug #35531 "Foreign keys: comment clause misplaced".

  mysql-test/t/foreign_key_all_engines.test@stripped, 2008-04-20 18:57:07+04:00, dlenev@stripped +23 -0
    Added test for bug #35531 "Foreign keys: comment clause misplaced".

  sql/sql_show.cc@stripped, 2008-04-20 18:57:07+04:00, dlenev@stripped +3 -3
    In SHOW CREATE TABLE output clauses for column referential constraints
    should go after all other clauses defining column. This is required
    since currently this is the only syntax supported by CREATE TABLE.

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-04-20 17:42:47 +04:00
+++ b/mysql-test/r/foreign_key_all_engines.result	2008-04-20 18:57:07 +04:00
@@ -310,3 +310,22 @@ set @@foreign_key_all_engines= 0;
 ERROR HY000: Variable 'foreign_key_all_engines' is a read only variable
 set @@session.foreign_key_all_engines= 0;
 ERROR HY000: Variable 'foreign_key_all_engines' is a read only variable
+drop tables if exists t1, t2, t3;
+create table t1 (i int primary key);
+create table t2 (j int primary key);
+create table t3 (fk int comment 'my comment' constraint c references t1 (i));
+show create table t3;
+Table	Create Table
+t3	CREATE TABLE `t3` (
+  `fk` int(11) DEFAULT NULL COMMENT 'my comment' CONSTRAINT `c` REFERENCES `t1` (`i`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t3;
+create table t3 (fk int comment 'my comment'
+                        constraint c1 references t1 (i)
+constraint c2 references t2 (j));
+show create table t3;
+Table	Create Table
+t3	CREATE TABLE `t3` (
+  `fk` int(11) DEFAULT NULL COMMENT 'my comment' CONSTRAINT `c1` REFERENCES `t1` (`i`) CONSTRAINT `c2` REFERENCES `t2` (`j`)
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop tables t1, t2, t3;
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-04-20 17:42:47 +04:00
+++ b/mysql-test/t/foreign_key_all_engines.test	2008-04-20 18:57:07 +04:00
@@ -233,3 +233,26 @@ set foreign_key_all_engines= 0;
 set @@foreign_key_all_engines= 0;
 --error ER_INCORRECT_GLOBAL_LOCAL_VAR
 set @@session.foreign_key_all_engines= 0;
+
+
+#
+# Test for bug #35531 "Foreign keys: comment clause misplaced".
+# Clauses for column referential constraints were erroneously
+# placed before comment clause in SHOW CREATE TABLE output.
+# Since with current syntax referential clause must be last
+# clause of column definition it was impossible to correctly
+# restore table with columns having both comment and referential
+# constraint clause from SHOW CREATE TABLE output.
+--disable_warnings
+drop tables if exists t1, t2, t3;
+--enable_warnings
+create table t1 (i int primary key);
+create table t2 (j int primary key);
+create table t3 (fk int comment 'my comment' constraint c references t1 (i));
+show create table t3;
+drop table t3;
+create table t3 (fk int comment 'my comment'
+                        constraint c1 references t1 (i)
+                        constraint c2 references t2 (j));
+show create table t3;
+drop tables t1, t2, t3;
diff -Nrup a/sql/sql_show.cc b/sql/sql_show.cc
--- a/sql/sql_show.cc	2008-03-21 13:55:41 +03:00
+++ b/sql/sql_show.cc	2008-04-20 18:57:07 +04:00
@@ -1161,14 +1161,14 @@ int store_create_info(THD *thd, TABLE_LI
         !(thd->variables.sql_mode & MODE_NO_FIELD_OPTIONS))
       packet->append(STRING_WITH_LEN(" AUTO_INCREMENT"));
 
-    if (opt_fk_all_engines)
-      fk_get_column_constraint_for_create(thd, packet, table, field->field_name);
-
     if (field->comment.length)
     {
       packet->append(STRING_WITH_LEN(" COMMENT "));
       append_unescaped(packet, field->comment.str, field->comment.length);
     }
+
+    if (opt_fk_all_engines)
+      fk_get_column_constraint_for_create(thd, packet, table, field->field_name);
   }
 
   key_info= table->key_info;
Thread
bk commit into 6.1 tree (dlenev:1.2609) BUG#35531dlenev20 Apr
  • Re: bk commit into 6.1 tree (dlenev:1.2609) BUG#35531Konstantin Osipov20 Apr