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-22 19:37:18+04:00, dlenev@stripped +3 -0
Fix for bug #35528 "Foreign keys: inconsistent error if partitions".
In --foreign-key-all-engines attempt to create partitioned table
(with non-automatic partitioning) with foreign key constraints
resulted in error. This contradicts LLD for WL148 "Foreign keys"
and is not consistent with behavior for column foreign keys in
the same situation.
The fix for this problem is to avoid check that was causing
this error in --foreign-key-all-engines mode.
Note that once we implement one of the later milestones of WL148
we may start emitting error in such cases again. But this behavior
should be consistent for table and column constraints and will go
away once WL4246 "Foreign Keys & Partitioning: Implement Storage
Engine API for foreign key support" is complete.
mysql-test/r/foreign_key_all_engines_2.result@stripped, 2008-04-22 19:37:15+04:00, dlenev@stripped +9 -0
Added test for bug #35528 "Foreign keys: inconsistent error if partitions"
mysql-test/t/foreign_key_all_engines_2.test@stripped, 2008-04-22 19:37:15+04:00, dlenev@stripped +24 -0
Added test for bug #35528 "Foreign keys: inconsistent error if partitions"
sql/sql_table.cc@stripped, 2008-04-22 19:37:15+04:00, dlenev@stripped +18 -7
Don't emit ER_CANNOT_ADD_FOREIGN error for partitioned tables with
foreign keys in --foreign-key-all-engines mode (as per WL#148 LLD).
Later milestones of WL148 might add check for FK API support which
will emit error in such case until WL4246 "Foreign Keys & Partitioning:
Implement Storage Engine API for foreign key support" is complete,
but this check should occur in another place.
diff -Nrup a/mysql-test/r/foreign_key_all_engines_2.result b/mysql-test/r/foreign_key_all_engines_2.result
--- a/mysql-test/r/foreign_key_all_engines_2.result 2008-04-22 16:18:49 +04:00
+++ b/mysql-test/r/foreign_key_all_engines_2.result 2008-04-22 19:37:15 +04:00
@@ -1,5 +1,14 @@
drop tables if exists t1, t2;
create table t1 (s1 int primary key);
+create table t2 (s1 int, foreign key (s1) references t2 (s1))
+partition by list (s1) (partition p1 values in (1));
+drop table t2;
+create table t2 (s1 int references t2 (s1))
+partition by list (s1) (partition p1 values in (1));
+drop table t2;
+drop table t1;
+drop tables if exists t1, t2;
+create table t1 (s1 int primary key);
create table t2 (s1 int references t2 (s1))
partition by range (s1) (partition p1 values less than (1));
drop table t2, t1;
diff -Nrup a/mysql-test/t/foreign_key_all_engines_2.test b/mysql-test/t/foreign_key_all_engines_2.test
--- a/mysql-test/t/foreign_key_all_engines_2.test 2008-04-22 16:18:49 +04:00
+++ b/mysql-test/t/foreign_key_all_engines_2.test 2008-04-22 19:37:15 +04:00
@@ -7,6 +7,28 @@
#
+# Bug #35528 "Foreign keys: inconsistent error if partitions"
+#
+# In --foreign-key-all-engines mode foreign keys on partitioned tables
+# should be supported once WL#4246 "Foreign Keys & Partitioning: Implement
+# Storage Engine API for foreign key support" is implemented.
+#
+# Until this moment we may emit error in this case, but it should not be
+# vague like ER_CANNOT_ADD_FOREIGN, and behavior in case of column and
+# table constraint should be consistent.
+--disable_warnings
+drop tables if exists t1, t2;
+--enable_warnings
+create table t1 (s1 int primary key);
+create table t2 (s1 int, foreign key (s1) references t2 (s1))
+ partition by list (s1) (partition p1 values in (1));
+drop table t2;
+create table t2 (s1 int references t2 (s1))
+ partition by list (s1) (partition p1 values in (1));
+drop table t2;
+drop table t1;
+
+#
# Bug #35529 "Foreign keys: crash dropping partitioned referenced table"
#
# Attempt to drop paritioned table with foreign keys led to weird error
@@ -23,3 +45,5 @@ create table t2 (s1 int references t2 (s
partition by range (s1) (partition p1 values less than (1));
# Dropping table t2 should succed
drop table t2, t1;
+
+
diff -Nrup a/sql/sql_table.cc b/sql/sql_table.cc
--- a/sql/sql_table.cc 2008-04-18 15:49:29 +04:00
+++ b/sql/sql_table.cc 2008-04-22 19:37:15 +04:00
@@ -3343,17 +3343,28 @@ bool mysql_create_table_no_lock(THD *thd
my_error(ER_PARTITION_NO_TEMPORARY, MYF(0));
goto err;
}
- while ((fkey= fkey_it++))
+ if (!opt_fk_all_engines)
{
/*
- Pre-WL#148 server ignores column foreign key constraints even
- for InnoDB. We do same here to preserve compatibility.
+ In --foreign-key-all-engines=0 mode we don't support foreign keys
+ on partitioned tables. In --foreign-key-all-engines=1 mode we should
+ support them once WL#4246 "Foreign Keys & Partitioning: Implement
+ Storage Engine API for foreign key support" is complete. Until this
+ moment we will also emit error in this mode but this should happen
+ elsewhere.
*/
- if (fkey->is_table_constraint &&
- !part_info->is_auto_partitioned)
+ while ((fkey= fkey_it++))
{
- my_error(ER_CANNOT_ADD_FOREIGN, MYF(0));
- goto err;
+ /*
+ Pre-WL#148 server ignores column foreign key constraints even
+ for InnoDB. We do same here to preserve compatibility.
+ */
+ if (fkey->is_table_constraint &&
+ !part_info->is_auto_partitioned)
+ {
+ my_error(ER_CANNOT_ADD_FOREIGN, MYF(0));
+ goto err;
+ }
}
}
if ((part_engine_type == partition_hton) &&