summaryrefslogtreecommitdiff
path: root/sql/lock.cc
diff options
context:
space:
mode:
authorunknown <ingo@mysql.com>2005-04-27 18:59:31 +0200
committerunknown <ingo@mysql.com>2005-04-27 18:59:31 +0200
commitc4fea310e85b125a766ba2102bef95fd7511fbd4 (patch)
treeab14ae1fc19f2e74a9f31b5fdccaed142d65ddaa /sql/lock.cc
parent218cd8de889dde601d01b83dbc5c66d66561ec78 (diff)
parentdb39c4d2729d2b5b35c7f1dfded783b8daa0c64e (diff)
downloadmariadb-git-c4fea310e85b125a766ba2102bef95fd7511fbd4.tar.gz
Merge from 4.0 needs fixes
sql/lock.cc: Auto merged sql/mysql_priv.h: Auto merged
Diffstat (limited to 'sql/lock.cc')
-rw-r--r--sql/lock.cc51
1 files changed, 49 insertions, 2 deletions
diff --git a/sql/lock.cc b/sql/lock.cc
index 8f1cd080db7..03541bb0810 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -82,7 +82,8 @@ static int unlock_external(THD *thd, TABLE **table,uint count);
static void print_lock_error(int error);
-MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
+MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count,
+ bool ignore_global_read_lock)
{
MYSQL_LOCK *sql_lock;
TABLE *write_lock_used;
@@ -93,7 +94,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd,TABLE **tables,uint count)
if (!(sql_lock = get_lock_data(thd,tables,count, 0,&write_lock_used)))
break;
- if (global_read_lock && write_lock_used)
+ if (global_read_lock && write_lock_used && ! ignore_global_read_lock)
{
/*
Someone has issued LOCK ALL TABLES FOR READ and we want a write lock
@@ -911,3 +912,49 @@ void make_global_read_lock_block_commit(THD *thd)
pthread_mutex_unlock(&LOCK_open);
thd->global_read_lock= MADE_GLOBAL_READ_LOCK_BLOCK_COMMIT;
}
+
+
+/*
+ Set protection against global read lock.
+
+ SYNOPSIS
+ set_protect_against_global_read_lock()
+ void
+
+ RETURN
+ FALSE OK, no global read lock exists.
+ TRUE Error, global read lock exists already.
+*/
+
+my_bool set_protect_against_global_read_lock(void)
+{
+ my_bool global_read_lock_exists;
+
+ pthread_mutex_lock(&LOCK_open);
+ if (! (global_read_lock_exists= test(global_read_lock)))
+ protect_against_global_read_lock++;
+ pthread_mutex_unlock(&LOCK_open);
+ return global_read_lock_exists;
+}
+
+
+/*
+ Unset protection against global read lock.
+
+ SYNOPSIS
+ unset_protect_against_global_read_lock()
+ void
+
+ RETURN
+ void
+*/
+
+void unset_protect_against_global_read_lock(void)
+{
+ pthread_mutex_lock(&LOCK_open);
+ protect_against_global_read_lock--;
+ pthread_mutex_unlock(&LOCK_open);
+ pthread_cond_broadcast(&COND_refresh);
+}
+
+