summaryrefslogtreecommitdiff
path: root/sql/sql_db.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r--sql/sql_db.cc53
1 files changed, 31 insertions, 22 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index 2c44c1a8449..c788d324743 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -20,6 +20,7 @@
#include <mysys_err.h>
#include "sp.h"
#include "events.h"
+#include "sql_handler.h"
#include <my_dir.h>
#include <m_ctype.h>
#include "log.h"
@@ -948,9 +949,6 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
remove_db_from_cache(db);
pthread_mutex_unlock(&LOCK_open);
- Drop_table_error_handler err_handler(thd->get_internal_handler());
- thd->push_internal_handler(&err_handler);
-
error= -1;
/*
We temporarily disable the binary log while dropping the objects
@@ -975,7 +973,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
{
ha_drop_database(path);
tmp_disable_binlog(thd);
- query_cache_invalidate1(db);
+ query_cache_invalidate1(thd, db);
(void) sp_drop_db_routines(thd, db); /* @todo Do not ignore errors */
#ifdef HAVE_EVENT_SCHEDULER
Events::drop_schema_events(thd, db);
@@ -983,8 +981,8 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
error = 0;
reenable_binlog(thd);
}
- thd->pop_internal_handler();
}
+
if (!silent && deleted>=0)
{
const char *query;
@@ -1213,16 +1211,34 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
else
{
strxmov(filePath, org_path, "/", file->name, NullS);
- if (my_delete_with_symlink(filePath,MYF(MY_WME)))
+ /*
+ We ignore ENOENT error in order to skip files that was deleted
+ by concurrently running statement like REAPIR TABLE ...
+ */
+ if (my_delete_with_symlink(filePath, MYF(0)) &&
+ my_errno != ENOENT)
{
- goto err;
+ my_error(EE_DELETE, MYF(0), filePath, my_errno);
+ goto err;
}
}
}
- if (thd->killed ||
- (tot_list && mysql_rm_table_part2(thd, tot_list, 1, 0, 1, 1)))
+
+ if (thd->killed)
goto err;
+ if (tot_list)
+ {
+ int res= 0;
+ Drop_table_error_handler err_handler(thd->get_internal_handler());
+
+ thd->push_internal_handler(&err_handler);
+ res= mysql_rm_table_part2(thd, tot_list, 1, 0, 1, 1);
+ thd->pop_internal_handler();
+ if (res)
+ goto err;
+ }
+
/* Remove RAID directories */
{
List_iterator<String> it(raid_dirs);
@@ -1506,13 +1522,9 @@ static inline bool
cmp_db_names(const char *db1_name,
const char *db2_name)
{
- return
- /* db1 is NULL and db2 is NULL */
- (!db1_name && !db2_name) ||
-
- /* db1 is not-NULL, db2 is not-NULL, db1 == db2. */
- (db1_name && db2_name &&
- my_strcasecmp(system_charset_info, db1_name, db2_name) == 0);
+ return ((!db1_name && !db2_name) ||
+ (db1_name && db2_name &&
+ my_strcasecmp(system_charset_info, db1_name, db2_name) == 0));
}
@@ -1585,12 +1597,9 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
Security_context *sctx= thd->security_ctx;
ulong db_access= sctx->db_access;
CHARSET_INFO *db_default_cl;
-
DBUG_ENTER("mysql_change_db");
- DBUG_PRINT("enter",("name: '%s'", new_db_name->str));
- if (new_db_name == NULL ||
- new_db_name->length == 0)
+ if (new_db_name->length == 0)
{
if (force_switch)
{
@@ -1599,8 +1608,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
after loading stored program. The thing is that loading of stored
program can happen when there is no current database.
- TODO: actually, new_db_name and new_db_name->str seem to be always
- non-NULL. In case of stored program, new_db_name->str == "" and
+ In case of stored program, new_db_name->str == "" and
new_db_name->length == 0.
*/
@@ -1615,6 +1623,7 @@ bool mysql_change_db(THD *thd, const LEX_STRING *new_db_name, bool force_switch)
DBUG_RETURN(TRUE);
}
}
+ DBUG_PRINT("enter",("name: '%s'", new_db_name->str));
if (is_schema_db(new_db_name->str, new_db_name->length))
{