#At file:///home/dlenev/src/bzr/mysql-6.1-fk/ based on revid:dlenev@stripped
2720 Dmitry Lenev 2009-05-27
Follow-up for Milestone 14 of WL#148 "Foreign keys"
("DDL checks and changes: DROP, TRUNCATE, RENAME").
Ensure that even in --foreign-key-all-engines=0 mode we are able to
drop database with new foreign keys.
We achieve this by adding .CNS to the list of extentions of automatically
deletable files if old mode is in effect. Although such approach does not
guarantee data dictionary integrity in all situations (e.g. when there is
a cross database foreign key) it still makes sense from "ease of use"
point of view.
@ mysql-test/r/foreign_key.result
Added test checking that even in --foreign-key-all-engines=0 mode
we are able to drop database with new foreign keys.
@ mysql-test/std_data/newfk.CNS
Added auxiliary files for test checking even in old foreign key mode
we are able to drop database with new foreign keys.
@ mysql-test/std_data/newfk_child.MYD
Added auxiliary files for test checking even in old foreign key mode
we are able to drop database with new foreign keys.
@ mysql-test/std_data/newfk_child.MYI
Added auxiliary files for test checking even in old foreign key mode
we are able to drop database with new foreign keys.
@ mysql-test/std_data/newfk_child.frm
Added auxiliary files for test checking even in old foreign key mode
we are able to drop database with new foreign keys.
@ mysql-test/std_data/newfk_parent.MYD
Added auxiliary files for test checking even in old foreign key mode
we are able to drop database with new foreign keys.
@ mysql-test/std_data/newfk_parent.MYI
Added auxiliary files for test checking even in old foreign key mode
we are able to drop database with new foreign keys.
@ mysql-test/std_data/newfk_parent.frm
Added auxiliary files for test checking even in old foreign key mode
we are able to drop database with new foreign keys.
@ mysql-test/t/foreign_key.test
Added test checking that even in --foreign-key-all-engines=0 mode
we are able to drop database with new foreign keys.
@ sql/mysql_priv.h
Introduced adjust_rm_db_to_fk_all_engines_option() which can be
used to adjust structures used by mysql_rm_db() implementation
to --foreign-key-all-engines mode.
@ sql/mysqld.cc
Call adjust_rm_db_to_fk_all_engines_option() to adjust structures
used by mysql_rm_db() to current --foreign-key-all-engines mode
(particularly add .CNS to list of extentions of automatically
deletable files if old mode is in effect).
@ sql/sql_db.cc
Ensure that in --foreign-key-all-engines=0 mode we are able to drop
database with new foreign keys. We achieve this by adding .CNS to
the list of extentions of automatically deletable files if old mode
is in effect. Although such approach does not guarantee data
dictionary integrity in all situations (e.g. when there is a cross
database foreign key) it still makes sense from "ease of use" point
of view.
added:
mysql-test/std_data/newfk.CNS
mysql-test/std_data/newfk_child.MYD
mysql-test/std_data/newfk_child.MYI
mysql-test/std_data/newfk_child.frm
mysql-test/std_data/newfk_parent.MYD
mysql-test/std_data/newfk_parent.MYI
mysql-test/std_data/newfk_parent.frm
modified:
mysql-test/r/foreign_key.result
mysql-test/t/foreign_key.test
sql/mysql_priv.h
sql/mysqld.cc
sql/sql_db.cc
=== modified file 'mysql-test/r/foreign_key.result'
--- a/mysql-test/r/foreign_key.result 2008-06-27 05:11:56 +0000
+++ b/mysql-test/r/foreign_key.result 2009-05-27 09:00:35 +0000
@@ -111,3 +111,16 @@ create table t3 (s1 int references t1(s1
drop table t3;
create table t3 (s1 int primary key references t3(s1)) as select s1 from t1;
drop tables t1, t2, t3;
+#
+# Additional test for the 14th milestone of WL#148 "Foreign keys"
+# ("DDL checks and changes: DROP, TRUNCATE, RENAME").
+#
+# Ensure that even in --foreign-key-all-engines=0 mode we are able
+# to drop database with new foreign keys.
+drop database if exists mysqltest;
+create database mysqltest;
+# Simulate creation of database with new foreign keys by copying
+# pre-generated files.
+# DROP DATABASE should succeed.
+drop database mysqltest;
+use test;
=== added file 'mysql-test/std_data/newfk.CNS'
--- a/mysql-test/std_data/newfk.CNS 1970-01-01 00:00:00 +0000
+++ b/mysql-test/std_data/newfk.CNS 2009-05-27 09:00:35 +0000
@@ -0,0 +1 @@
+TYPE=CONSTRAINTNAME
=== added file 'mysql-test/std_data/newfk_child.MYD'
=== added file 'mysql-test/std_data/newfk_child.MYI'
Binary files a/mysql-test/std_data/newfk_child.MYI 1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/newfk_child.MYI 2009-05-27 09:00:35 +0000 differ
=== added file 'mysql-test/std_data/newfk_child.frm'
Binary files a/mysql-test/std_data/newfk_child.frm 1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/newfk_child.frm 2009-05-27 09:00:35 +0000 differ
=== added file 'mysql-test/std_data/newfk_parent.MYD'
=== added file 'mysql-test/std_data/newfk_parent.MYI'
Binary files a/mysql-test/std_data/newfk_parent.MYI 1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/newfk_parent.MYI 2009-05-27 09:00:35 +0000 differ
=== added file 'mysql-test/std_data/newfk_parent.frm'
Binary files a/mysql-test/std_data/newfk_parent.frm 1970-01-01 00:00:00 +0000 and b/mysql-test/std_data/newfk_parent.frm 2009-05-27 09:00:35 +0000 differ
=== modified file 'mysql-test/t/foreign_key.test'
--- a/mysql-test/t/foreign_key.test 2008-06-27 05:11:56 +0000
+++ b/mysql-test/t/foreign_key.test 2009-05-27 09:00:35 +0000
@@ -184,3 +184,28 @@ create table t3 (s1 int references t1(s1
drop table t3;
create table t3 (s1 int primary key references t3(s1)) as select s1 from t1;
drop tables t1, t2, t3;
+
+
+--echo #
+--echo # Additional test for the 14th milestone of WL#148 "Foreign keys"
+--echo # ("DDL checks and changes: DROP, TRUNCATE, RENAME").
+--echo #
+--echo # Ensure that even in --foreign-key-all-engines=0 mode we are able
+--echo # to drop database with new foreign keys.
+--disable_warnings
+drop database if exists mysqltest;
+--enable_warnings
+create database mysqltest;
+--echo # Simulate creation of database with new foreign keys by copying
+--echo # pre-generated files.
+let $MYSQLD_DATADIR= `select @@datadir`;
+--copy_file std_data/newfk_parent.frm $MYSQLD_DATADIR/mysqltest/newfk_parent.frm
+--copy_file std_data/newfk_parent.MYI $MYSQLD_DATADIR/mysqltest/newfk_parent.MYI
+--copy_file std_data/newfk_parent.MYD $MYSQLD_DATADIR/mysqltest/newfk_parent.MYD
+--copy_file std_data/newfk_child.frm $MYSQLD_DATADIR/mysqltest/newfk_child.frm
+--copy_file std_data/newfk_child.MYI $MYSQLD_DATADIR/mysqltest/newfk_child.MYI
+--copy_file std_data/newfk_child.MYD $MYSQLD_DATADIR/mysqltest/newfk_child.MYD
+--copy_file std_data/newfk.CNS $MYSQLD_DATADIR/mysqltest/newfk.CNS
+--echo # DROP DATABASE should succeed.
+drop database mysqltest;
+use test;
=== modified file 'sql/mysql_priv.h'
--- a/sql/mysql_priv.h 2009-05-27 03:08:49 +0000
+++ b/sql/mysql_priv.h 2009-05-27 09:00:35 +0000
@@ -1093,6 +1093,8 @@ int mysql_create_db(THD *thd, char *db,
bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create);
bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent);
bool mysql_upgrade_db(THD *thd, LEX_STRING *old_db);
+void adjust_rm_db_to_fk_all_engines_option();
+
void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, ushort flags);
void mysql_client_binlog_statement(THD *thd);
bool mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists,
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2009-05-18 04:18:37 +0000
+++ b/sql/mysqld.cc 2009-05-27 09:00:35 +0000
@@ -3698,6 +3698,7 @@ You should consider changing lower_case_
&my_charset_bin);
adjust_i_s_tables_to_fk_all_engines_option();
+ adjust_rm_db_to_fk_all_engines_option();
return 0;
}
=== modified file 'sql/sql_db.cc'
--- a/sql/sql_db.cc 2009-05-27 03:08:49 +0000
+++ b/sql/sql_db.cc 2009-05-27 09:00:35 +0000
@@ -29,9 +29,13 @@
#define MAX_DROP_TABLE_Q_LEN 1024
-const char *del_exts[]= {".frm", ".BAK", ".TMD",".opt", NullS};
+/**
+ List of extensions of files which should be automatically deleted when
+ dropping database. @sa adjust_rm_db_to_fk_all_engines_option().
+*/
+const char *del_exts[]= {".frm", ".BAK", ".TMD",".opt", NullS, NullS};
static TYPELIB deletable_extentions=
-{array_elements(del_exts)-1,"del_exts", del_exts, NULL};
+{array_elements(del_exts)-2,"del_exts", del_exts, NULL};
static long mysql_rm_known_files(THD *thd, MY_DIR *dirp,
const char *db, const char *path, uint level,
@@ -843,6 +847,30 @@ exit2:
}
+/**
+ Ensure that in --foreign-key-all-engines=0 mode we are able to
+ automatically delete .CNS files when dropping a database.
+ This allows to drop databases with foreign keys created in new
+ mode in old mode. Although such approach does not guarantee data
+ dictionary integrity in all situations (e.g. when there is a cross
+ database foreign key) it still makes sense from "ease of use"
+ point of view.
+*/
+
+void adjust_rm_db_to_fk_all_engines_option()
+{
+ /*
+ In --foreign-key-all-engines = 0 mode add .CNS to the list of
+ extensions files with which should be automatically deleted.
+ */
+ if (! opt_fk_all_engines)
+ {
+ del_exts[deletable_extentions.count]= CNS_EXT;
+ deletable_extentions.count++;
+ }
+}
+
+
/*
Drop all tables in a database and the database itself
Attachment: [text/bzr-bundle] bzr/dlenev@mysql.com-20090527090035-t30blokkj9rvvurp.bundle
| Thread |
|---|
| • bzr commit into mysql-6.1-fk branch (dlenev:2720) WL#148 | Dmitry Lenev | 27 May |