diff options
author | unknown <sasha@mysql.sashanet.com> | 2001-06-21 15:59:51 -0600 |
---|---|---|
committer | unknown <sasha@mysql.sashanet.com> | 2001-06-21 15:59:51 -0600 |
commit | a7fa56c1736a19ae968bdf536e563a86bcb17c61 (patch) | |
tree | f90722a876cbb527957b82b81c5f4ebc17aa7864 /sql/sql_db.cc | |
parent | 066eddd86208ff7aff062efce1957a66618de854 (diff) | |
download | mariadb-git-a7fa56c1736a19ae968bdf536e563a86bcb17c61.tar.gz |
fixed drop/create database bug when holding global read lock
preserve originating server id in Intvar events to avoid inifinite loops
include/mysqld_error.h:
new error messages
mysql-test/r/drop.result:
updated result
mysql-test/r/flush.result:
updated result
mysql-test/t/drop.test:
test for proper handling of drop/create database when holding
global read lock
mysql-test/t/flush.test:
test to see if other thread would block on drop database if we
are holding global read lock
sql/log.cc:
preserve originating server id in Intvar log event
sql/share/czech/errmsg.txt:
new error messages
sql/share/danish/errmsg.txt:
new error messages
sql/share/dutch/errmsg.txt:
new error messages
sql/share/english/errmsg.txt:
new error messages
sql/share/estonian/errmsg.txt:
new error messages
sql/share/french/errmsg.txt:
new error messages
sql/share/german/errmsg.txt:
new error messages
sql/share/greek/errmsg.txt:
new error messages
sql/share/hungarian/errmsg.txt:
new error messages
sql/share/italian/errmsg.txt:
new error messages
sql/share/japanese/errmsg.txt:
new error messages
sql/share/korean/errmsg.txt:
new error messages
sql/share/norwegian-ny/errmsg.txt:
new error messages
sql/share/norwegian/errmsg.txt:
new error messages
sql/share/polish/errmsg.txt:
new error messages
sql/share/portuguese/errmsg.txt:
new error messages
sql/share/romanian/errmsg.txt:
new error messages
sql/share/russian/errmsg.txt:
new error messages
sql/share/slovak/errmsg.txt:
new error messages
sql/share/spanish/errmsg.txt:
new error messages
sql/share/swedish/errmsg.txt:
new error messages
sql/slave.cc:
fixed typo in comment
sql/sql_db.cc:
global read lock should block drop/create database
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 5243498f7fc..7cd892f6079 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -38,6 +38,32 @@ void 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); @@ -105,6 +131,26 @@ void 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 */ |