diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-06-21 16:15:00 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-06-21 16:15:00 -0600 |
commit | d310ce76991a8729b575b7c1404e97d2619d7739 (patch) | |
tree | 23328c5b7144436a44f8c85ec21eeeb58d330413 /sql/sql_db.cc | |
parent | 63bd9b50530145b5f2d5ae5b8a0c9d019eb9771a (diff) | |
parent | a7fa56c1736a19ae968bdf536e563a86bcb17c61 (diff) | |
download | mariadb-git-d310ce76991a8729b575b7c1404e97d2619d7739.tar.gz |
merge
sql/slave.cc:
Auto merged
sql/sql_db.cc:
Auto merged
Diffstat (limited to 'sql/sql_db.cc')
-rw-r--r-- | sql/sql_db.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/sql/sql_db.cc b/sql/sql_db.cc index f3fda058113..85d3f0a344c 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -39,6 +39,32 @@ int mysql_create_db(THD *thd, char *db, uint create_options) DBUG_ENTER("mysql_create_db"); VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); + VOID(pthread_mutex_lock(&LOCK_open)); + + // do not create database if another thread is holding read lock + if (global_read_lock) + { + if (thd->global_read_lock) + { + net_printf(&thd->net, ER_CREATE_DB_WITH_READ_LOCK); + VOID(pthread_mutex_unlock(&LOCK_open)); + goto exit; + } + while (global_read_lock && ! thd->killed) + { + (void) pthread_cond_wait(&COND_refresh,&LOCK_open); + } + + if (thd->killed) + { + net_printf(&thd->net, ER_SERVER_SHUTDOWN); + VOID(pthread_mutex_unlock(&LOCK_open)); + goto exit; + } + + } + + VOID(pthread_mutex_unlock(&LOCK_open)); /* Check directory */ (void)sprintf(path,"%s/%s", mysql_data_home, db); @@ -117,6 +143,26 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists) VOID(pthread_mutex_lock(&LOCK_mysql_create_db)); VOID(pthread_mutex_lock(&LOCK_open)); + // do not drop database if another thread is holding read lock + if (global_read_lock) + { + if (thd->global_read_lock) + { + net_printf(&thd->net, ER_DROP_DB_WITH_READ_LOCK); + goto exit; + } + while (global_read_lock && ! thd->killed) + { + (void) pthread_cond_wait(&COND_refresh,&LOCK_open); + } + + if (thd->killed) + { + net_printf(&thd->net, ER_SERVER_SHUTDOWN); + goto exit; + } + } + (void) sprintf(path,"%s/%s",mysql_data_home,db); unpack_dirname(path,path); // Convert if not unix /* See if the directory exists */ |