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.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc
index b4a0e5c4c7d..1dd659283ac 100644
--- a/sql/sql_db.cc
+++ b/sql/sql_db.cc
@@ -642,6 +642,18 @@ int mysql_create_db(THD *thd, char *db, HA_CREATE_INFO *create_info,
goto exit2;
}
+ /*
+ Close and mark for re-open all HANDLER tables which are marked for flush
+ or which there are pending conflicing locks against. This is needed to
+ prevent deadlocks.
+ */
+ if (thd->handler_tables_hash.records)
+ {
+ pthread_mutex_lock(&LOCK_open);
+ mysql_ha_flush(thd);
+ pthread_mutex_unlock(&LOCK_open);
+ }
+
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
/* Check directory */
@@ -788,6 +800,18 @@ bool mysql_alter_db(THD *thd, const char *db, HA_CREATE_INFO *create_info)
if ((error=wait_if_global_read_lock(thd,0,1)))
goto exit2;
+ /*
+ Close and mark for re-open all HANDLER tables which are marked for flush
+ or which there are pending conflicing locks against. This is needed to
+ prevent deadlocks.
+ */
+ if (thd->handler_tables_hash.records)
+ {
+ pthread_mutex_lock(&LOCK_open);
+ mysql_ha_flush(thd);
+ pthread_mutex_unlock(&LOCK_open);
+ }
+
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
/*
@@ -886,6 +910,18 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
goto exit2;
}
+ /*
+ Close and mark for re-open all HANDLER tables which are marked for flush
+ or which there are pending conflicing locks against. This is needed to
+ prevent deadlocks.
+ */
+ if (thd->handler_tables_hash.records)
+ {
+ pthread_mutex_lock(&LOCK_open);
+ mysql_ha_flush(thd);
+ pthread_mutex_unlock(&LOCK_open);
+ }
+
VOID(pthread_mutex_lock(&LOCK_mysql_create_db));
length= build_table_filename(path, sizeof(path) - 1, db, "", "", 0);