MySQL Lists are EOL. Please join:

List:Commits« Previous MessageNext Message »
From:Mattias Jonsson Date:March 4 2010 11:29am
Subject:bzr commit into mysql-5.1-bugteam branch (mattias.jonsson:3369)
Bug#50104
View as plain text  
#At file:///Users/mattiasj/clones/bzrroot/b50104-51-bugteam_2/ based on revid:joro@stripped

 3369 Mattias Jonsson	2010-03-04
      Bug#50104: Partitioned table with just 1 partion works with fk
      
      There was no check for foreign keys when altering partitioned
      tables.
      
      Added check for FK when altering partitioned tables.
     @ mysql-test/r/partition_innodb.result
        Bug#50104: Partitioned table with just 1 partion works with fk
        
        Updated test result
     @ mysql-test/t/partition_innodb.test
        Bug#50104: Partitioned table with just 1 partion works with fk
        
        Added test for adding FK on partitioned tables (both 1 and 2
        partitions)
     @ sql/sql_partition.cc
        Bug#50104: Partitioned table with just 1 partion works with fk
        
        Disabled adding foreign key when altering a partitioned table.

    modified:
      mysql-test/r/partition_innodb.result
      mysql-test/t/partition_innodb.test
      sql/sql_partition.cc
=== modified file 'mysql-test/r/partition_innodb.result'
--- a/mysql-test/r/partition_innodb.result	2010-01-18 16:49:18 +0000
+++ b/mysql-test/r/partition_innodb.result	2010-03-04 11:29:22 +0000
@@ -1,4 +1,24 @@
-drop table if exists t1;
+drop table if exists t1, t2;
+#
+# Bug#50104: Partitioned table with just 1 partion works with fk
+#
+CREATE TABLE t2 (
+id INT,
+PRIMARY KEY (id)
+) ENGINE=InnoDB ;
+CREATE TABLE t1 (
+id INT NOT NULL AUTO_INCREMENT,
+parent_id INT DEFAULT NULL,
+PRIMARY KEY (id),
+KEY parent_id (parent_id)
+) ENGINE=InnoDB;
+ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 1;
+ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
+ERROR HY000: Foreign key clause is not yet supported in conjunction with partitioning
+ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 2;
+ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
+ERROR HY000: Foreign key clause is not yet supported in conjunction with partitioning
+DROP TABLE t1, t2;
 create table t1 (a int not null,
 b datetime not null,
 primary key (a,b))

=== modified file 'mysql-test/t/partition_innodb.test'
--- a/mysql-test/t/partition_innodb.test	2010-01-18 16:49:18 +0000
+++ b/mysql-test/t/partition_innodb.test	2010-03-04 11:29:22 +0000
@@ -2,11 +2,38 @@
 --source include/have_innodb.inc
 
 --disable_warnings
-drop table if exists t1;
+drop table if exists t1, t2;
 --enable_warnings
 
 let $MYSQLD_DATADIR= `SELECT @@datadir`;
 
+--echo #
+--echo # Bug#50104: Partitioned table with just 1 partion works with fk
+--echo #
+CREATE TABLE t2 (
+  id INT,
+  PRIMARY KEY (id)
+) ENGINE=InnoDB ;
+
+CREATE TABLE t1 (
+  id INT NOT NULL AUTO_INCREMENT,
+  parent_id INT DEFAULT NULL,
+  PRIMARY KEY (id),
+  KEY parent_id (parent_id)
+) ENGINE=InnoDB;
+
+ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 1;
+
+--error ER_FOREIGN_KEY_ON_PARTITIONED
+ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
+
+ALTER TABLE t1 PARTITION BY HASH (id) PARTITIONS 2;
+
+--error ER_FOREIGN_KEY_ON_PARTITIONED
+ALTER TABLE t1 ADD CONSTRAINT test_ibfk_1 FOREIGN KEY (parent_id) REFERENCES t2 (id);
+
+DROP TABLE t1, t2;
+
 #
 # Bug#47029: Crash when reorganize partition with subpartition
 #

=== modified file 'sql/sql_partition.cc'
--- a/sql/sql_partition.cc	2010-01-24 07:03:23 +0000
+++ b/sql/sql_partition.cc	2010-03-04 11:29:22 +0000
@@ -4273,6 +4273,12 @@ uint prep_alter_part_table(THD *thd, TAB
 {
   DBUG_ENTER("prep_alter_part_table");
 
+  /* Foreign keys on partitioned tables are not supported, waits for WL#148 */
+  if (table->part_info && (alter_info->flags & ALTER_FOREIGN_KEY))
+  {
+    my_error(ER_FOREIGN_KEY_ON_PARTITIONED, MYF(0));
+    DBUG_RETURN(TRUE);
+  }
   /*
     We are going to manipulate the partition info on the table object
     so we need to ensure that the data structure of the table object


Attachment: [text/bzr-bundle]
Thread
bzr commit into mysql-5.1-bugteam branch (mattias.jonsson:3369)Bug#50104Mattias Jonsson4 Mar