diff options
author | unknown <gluh@gluh.mysql.r18.ru> | 2003-08-27 18:03:39 +0500 |
---|---|---|
committer | unknown <gluh@gluh.mysql.r18.ru> | 2003-08-27 18:03:39 +0500 |
commit | 4c0890c49583bec96b3a70c982aefb8dc7b6e3fc (patch) | |
tree | f67788457623bbbf382374756ab4f3f6833bc25e | |
parent | caa8b46700351162e68e23d0c03d22e4496036fa (diff) | |
download | mariadb-git-4c0890c49583bec96b3a70c982aefb8dc7b6e3fc.tar.gz |
Fix for bug #799 FLUSH TABLES WITH READ LOCK does not block CREATE TABLE
-rw-r--r-- | mysql-test/r/drop.result | 10 | ||||
-rw-r--r-- | mysql-test/t/drop.test | 10 | ||||
-rw-r--r-- | sql/sql_table.cc | 17 |
3 files changed, 37 insertions, 0 deletions
diff --git a/mysql-test/r/drop.result b/mysql-test/r/drop.result index 367b28e9bf7..dbb6800cb75 100644 --- a/mysql-test/r/drop.result +++ b/mysql-test/r/drop.result @@ -44,3 +44,13 @@ mysql test drop database mysqltest; ERROR HY000: Can't drop database 'mysqltest'; database doesn't exist +drop table t1; +flush tables with read lock; +create table t1(n int); +ERROR HY000: Table 't1' was locked with a READ lock and can't be updated +unlock tables; +create table t1(n int); +show tables; +Tables_in_test +t1 +drop table t1; diff --git a/mysql-test/t/drop.test b/mysql-test/t/drop.test index a55cbb45fd9..78311a9dd52 100644 --- a/mysql-test/t/drop.test +++ b/mysql-test/t/drop.test @@ -43,3 +43,13 @@ drop database mysqltest; show databases; --error 1008 drop database mysqltest; + +# test create table and FLUSH TABLES WITH READ LOCK +drop table t1; +flush tables with read lock; +--error 1099; +create table t1(n int); +unlock tables; +create table t1(n int); +show tables; +drop table t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 37f8d0d7f4f..f33cc8fde14 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -900,6 +900,23 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, DBUG_RETURN(-1); } VOID(pthread_mutex_lock(&LOCK_open)); + if (global_read_lock) + { + thd->mysys_var->current_mutex= &LOCK_open; + thd->mysys_var->current_cond= &COND_refresh; + if (thd->global_read_lock) + my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), + table_name); + else + while (global_read_lock && ! thd->killed) + (void) pthread_cond_wait(&COND_refresh,&LOCK_open); + pthread_mutex_lock(&thd->mysys_var->mutex); + thd->mysys_var->current_mutex= 0; + thd->mysys_var->current_cond= 0; + pthread_mutex_unlock(&thd->mysys_var->mutex); + if (error) + goto end; + } if (!tmp_table && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)) { if (!access(path,F_OK)) |