Below is the list of changes that have just been committed into a local
5.1 repository of mattiasj. When mattiasj 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, 2007-12-06 14:43:06+01:00, mattiasj@stripped +3 -0
Bug#32948: FKs allowed to reference partitioned table
Problem: when alter to partitioned table,
it does not see it as change of engine.
Solution: If alter includes partitioning, check if it is possible
to change engines (eg. is the table referenced by a FK)
mysql-test/r/partition_innodb.result@stripped, 2007-12-06 14:43:04+01:00, mattiasj@stripped +12 -0
Bug#32948: FKs allowed to reference partitioned table
test result
mysql-test/t/partition_innodb.test@stripped, 2007-12-06 14:43:04+01:00, mattiasj@stripped +15 -0
Bug#32948: FKs allowed to reference partitioned table
test case
sql/sql_table.cc@stripped, 2007-12-06 14:43:05+01:00, mattiasj@stripped +2 -1
Bug#32948: FKs allowed to reference partitioned table
if alter to partitioning, it is the same as changing engine.
diff -Nrup a/mysql-test/r/partition_innodb.result b/mysql-test/r/partition_innodb.result
--- a/mysql-test/r/partition_innodb.result 2007-11-13 06:41:57 +01:00
+++ b/mysql-test/r/partition_innodb.result 2007-12-06 14:43:04 +01:00
@@ -1,3 +1,15 @@
+# Bug#32948
+CREATE TABLE t1 (c1 INT, PRIMARY KEY (c1)) ENGINE=INNODB;
+CREATE TABLE t2 (c1 INT, PRIMARY KEY (c1),
+FOREIGN KEY (c1) REFERENCES t1 (c1)
+ON DELETE CASCADE)
+ENGINE=INNODB;
+ALTER TABLE t1 PARTITION BY HASH(c1) PARTITIONS 5;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+ALTER TABLE t1 ENGINE=MyISAM;
+ERROR 23000: Cannot delete or update a parent row: a foreign key constraint fails
+DROP TABLE t2;
+DROP TABLE t1;
create table t1 (a int) engine=innodb partition by hash(a) ;
show table status like 't1';
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
diff -Nrup a/mysql-test/t/partition_innodb.test b/mysql-test/t/partition_innodb.test
--- a/mysql-test/t/partition_innodb.test 2007-11-13 06:41:57 +01:00
+++ b/mysql-test/t/partition_innodb.test 2007-12-06 14:43:04 +01:00
@@ -1,6 +1,21 @@
--source include/have_partition.inc
--source include/have_innodb.inc
+# Bug#32948 - FKs allowed to reference partitioned table
+#
+-- echo # Bug#32948
+CREATE TABLE t1 (c1 INT, PRIMARY KEY (c1)) ENGINE=INNODB;
+CREATE TABLE t2 (c1 INT, PRIMARY KEY (c1),
+ FOREIGN KEY (c1) REFERENCES t1 (c1)
+ ON DELETE CASCADE)
+ENGINE=INNODB;
+--error ER_ROW_IS_REFERENCED
+ALTER TABLE t1 PARTITION BY HASH(c1) PARTITIONS 5;
+--error ER_ROW_IS_REFERENCED
+ALTER TABLE t1 ENGINE=MyISAM;
+DROP TABLE t2;
+DROP TABLE t1;
+
#
# Bug #14673: Wrong InnoDB default row format
#
diff -Nrup a/sql/sql_table.cc b/sql/sql_table.cc
--- a/sql/sql_table.cc 2007-11-27 19:20:09 +01:00
+++ b/sql/sql_table.cc 2007-12-06 14:43:05 +01:00
@@ -5974,7 +5974,8 @@ view_err:
goto err;
new_db_type= create_info->db_type;
- if (new_db_type != old_db_type &&
+ if ((new_db_type != old_db_type ||
+ alter_info->flags & ALTER_PARTITION) &&
!table->file->can_switch_engines())
{
my_error(ER_ROW_IS_REFERENCED, MYF(0));
Thread |
---|
• bk commit into 5.1 tree (mattiasj:1.2677) BUG#32948 | mattiasj | 6 Dec |