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-23 09:18:40+04:00, dlenev@stripped +5 -0
Fix for bug #35533 "Foreign keys: can't drop database with foreign keys".
In --foreign-key-all-engines mode attempt to drop database containing
tables with foreign keys failed with error and left empty directory behind.
Code implementing DROP DATABASE was not aware of the fact that .CNS files,
which represent occupied names of foreign key constraints, are automatically
removed if table corresponding on which foreign key is defined is dropped
and therefore they can be safely ignored while scanning database directory
before removing it.
This fix adds ".CNS" to the list of such known ignorable files extensions.
mysql-test/r/foreign_key_all_engines.result@stripped, 2008-04-23 09:18:36+04:00, dlenev@stripped +7 -0
Added test case for bug #35533 "Foreign keys: can't drop database with
foreign keys".
mysql-test/t/foreign_key_all_engines.test@stripped, 2008-04-23 09:18:36+04:00, dlenev@stripped +15 -0
Added test case for bug #35533 "Foreign keys: can't drop database with
foreign keys".
sql/fk_dd.cc@stripped, 2008-04-23 09:18:36+04:00, dlenev@stripped +1 -1
Made string constant for extension of files corresponging to constraint
names available outside of fk_dd.cc
sql/fk_dd.h@stripped, 2008-04-23 09:18:36+04:00, dlenev@stripped +3 -0
Made string constant for extension of files corresponging to constraint
names available outside of fk_dd.cc
sql/handler.cc@stripped, 2008-04-23 09:18:36+04:00, dlenev@stripped +2 -0
Add ".CNS" to the list of known files extensions associated with table.
DROP DATABASE implementation assumes that such files will be removed once
table with which they are associated is dropped and therefore they can be
ignored while scanning contents of database directory before dropping it.
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 18:57:07 +04:00
+++ b/mysql-test/r/foreign_key_all_engines.result 2008-04-23 09:18:36 +04:00
@@ -329,3 +329,10 @@ 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;
+drop database if exists mysqltest;
+create database mysqltest;
+use mysqltest;
+create table t1 (i int primary key);
+create table t2 (fk int references t1 (i));
+use test;
+drop database mysqltest;
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 18:57:07 +04:00
+++ b/mysql-test/t/foreign_key_all_engines.test 2008-04-23 09:18:36 +04:00
@@ -256,3 +256,18 @@ create table t3 (fk int comment 'my comm
constraint c2 references t2 (j));
show create table t3;
drop tables t1, t2, t3;
+
+
+#
+# Test for bug #35533 "Foreign keys: can't drop database with foreign keys".
+#
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+create database mysqltest;
+use mysqltest;
+create table t1 (i int primary key);
+create table t2 (fk int references t1 (i));
+use test;
+# This statement should succeed
+drop database mysqltest;
diff -Nrup a/sql/fk_dd.cc b/sql/fk_dd.cc
--- a/sql/fk_dd.cc 2008-04-20 17:42:47 +04:00
+++ b/sql/fk_dd.cc 2008-04-23 09:18:36 +04:00
@@ -632,7 +632,7 @@ static const LEX_STRING constraint_name_
String with extension of .CNS files.
*/
-static const char * const CNS_EXT= ".CNS";
+const char * const CNS_EXT= ".CNS";
/**
diff -Nrup a/sql/fk_dd.h b/sql/fk_dd.h
--- a/sql/fk_dd.h 2008-03-20 19:46:47 +03:00
+++ b/sql/fk_dd.h 2008-04-23 09:18:36 +04:00
@@ -41,4 +41,7 @@ bool fk_drop_all_constraint_names_for_ta
bool fk_check_constraint_added(Foreign_key *fkey, List<Foreign_key> &fkey_list,
const char *db);
+
+extern const char * const CNS_EXT;
+
#endif
diff -Nrup a/sql/handler.cc b/sql/handler.cc
--- a/sql/handler.cc 2008-03-13 12:07:32 +03:00
+++ b/sql/handler.cc 2008-04-23 09:18:36 +04:00
@@ -28,6 +28,7 @@
#include <myisampack.h>
#include <errno.h>
#include "backup/debug.h"
+#include "fk_dd.h"
#ifdef WITH_PARTITION_STORAGE_ENGINE
#include "ha_partition.h"
@@ -5042,6 +5043,7 @@ TYPELIB *ha_known_exts(void)
known_extensions_id= mysys_usage_id;
found_exts.push_back((char*) TRG_EXT);
found_exts.push_back((char*) TRN_EXT);
+ found_exts.push_back((char*) CNS_EXT);
plugin_foreach(NULL, exts_handlerton,
MYSQL_STORAGE_ENGINE_PLUGIN, &found_exts);