Commit 26b87c33 authored by Alexey Botchkov's avatar Alexey Botchkov

MDEV-10846 Running mysqldump backup twice returns error: Table

           'mysql.proc' doesn't exist.

        The mysql_rm_db() doesn't seem to expect the 'mysql' database
        to be deleted. Checks for that added.
        Also fixed the bug MDEV-11105 Table named 'db'
        has weird side effect.
        The db.opt file now removed separately.
parent 22490a0d
...@@ -209,3 +209,9 @@ INSERT INTO table1 VALUES (1); ...@@ -209,3 +209,9 @@ INSERT INTO table1 VALUES (1);
ERROR 42S02: Unknown table 't.notable' ERROR 42S02: Unknown table 't.notable'
DROP TABLE table1,table2; DROP TABLE table1,table2;
# End BUG#34750 # End BUG#34750
#
# MDEV-11105 Table named 'db' has weird side effect.
#
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.db(id INT);
DROP DATABASE mysqltest;
...@@ -313,3 +313,12 @@ INSERT INTO table1 VALUES (1); ...@@ -313,3 +313,12 @@ INSERT INTO table1 VALUES (1);
DROP TABLE table1,table2; DROP TABLE table1,table2;
--echo # End BUG#34750 --echo # End BUG#34750
--echo #
--echo # MDEV-11105 Table named 'db' has weird side effect.
--echo #
CREATE DATABASE mysqltest;
CREATE TABLE mysqltest.db(id INT);
DROP DATABASE mysqltest;
...@@ -784,7 +784,7 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info) ...@@ -784,7 +784,7 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
{ {
ulong deleted_tables= 0; ulong deleted_tables= 0;
bool error= true; bool error= true, rm_mysql_schema;
char path[FN_REFLEN + 16]; char path[FN_REFLEN + 16];
MY_DIR *dirp; MY_DIR *dirp;
uint length; uint length;
...@@ -809,6 +809,18 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) ...@@ -809,6 +809,18 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
length= build_table_filename(path, sizeof(path) - 1, db, "", "", 0); length= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);
strmov(path+length, MY_DB_OPT_FILE); // Append db option file name strmov(path+length, MY_DB_OPT_FILE); // Append db option file name
del_dbopt(path); // Remove dboption hash entry del_dbopt(path); // Remove dboption hash entry
/*
Now remove the db.opt file.
The 'find_db_tables_and_rm_known_files' doesn't remove this file
if there exists a table with the name 'db', so let's just do it
separately. We know this file exists and needs to be deleted anyway.
*/
if (my_delete_with_symlink(path, MYF(0)) && my_errno != ENOENT)
{
my_error(EE_DELETE, MYF(0), path, my_errno);
DBUG_RETURN(true);
}
path[length]= '\0'; // Remove file name path[length]= '\0'; // Remove file name
/* See if the directory exists */ /* See if the directory exists */
...@@ -835,7 +847,8 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) ...@@ -835,7 +847,8 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
Disable drop of enabled log tables, must be done before name locking. Disable drop of enabled log tables, must be done before name locking.
This check is only needed if we are dropping the "mysql" database. This check is only needed if we are dropping the "mysql" database.
*/ */
if ((my_strcasecmp(system_charset_info, MYSQL_SCHEMA_NAME.str, db) == 0)) if ((rm_mysql_schema=
(my_strcasecmp(system_charset_info, MYSQL_SCHEMA_NAME.str, db) == 0)))
{ {
for (table= tables; table; table= table->next_local) for (table= tables; table; table= table->next_local)
if (check_if_log_table(table, TRUE, "DROP")) if (check_if_log_table(table, TRUE, "DROP"))
...@@ -848,7 +861,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) ...@@ -848,7 +861,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
lock_db_routines(thd, dbnorm)) lock_db_routines(thd, dbnorm))
goto exit; goto exit;
if (!in_bootstrap) if (!in_bootstrap && !rm_mysql_schema)
{ {
for (table= tables; table; table= table->next_local) for (table= tables; table; table= table->next_local)
{ {
...@@ -893,10 +906,13 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) ...@@ -893,10 +906,13 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
ha_drop_database(path); ha_drop_database(path);
tmp_disable_binlog(thd); tmp_disable_binlog(thd);
query_cache_invalidate1(thd, dbnorm); query_cache_invalidate1(thd, dbnorm);
(void) sp_drop_db_routines(thd, dbnorm); /* @todo Do not ignore errors */ if (!rm_mysql_schema)
{
(void) sp_drop_db_routines(thd, dbnorm); /* @todo Do not ignore errors */
#ifdef HAVE_EVENT_SCHEDULER #ifdef HAVE_EVENT_SCHEDULER
Events::drop_schema_events(thd, dbnorm); Events::drop_schema_events(thd, dbnorm);
#endif #endif
}
reenable_binlog(thd); reenable_binlog(thd);
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment