summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
Diffstat (limited to 'sql')
-rw-r--r--sql/lock.cc4
-rw-r--r--sql/log.h6
-rw-r--r--sql/sql_base.cc8
3 files changed, 13 insertions, 5 deletions
diff --git a/sql/lock.cc b/sql/lock.cc
index 6f1dd0669ee..9785bc4ac00 100644
--- a/sql/lock.cc
+++ b/sql/lock.cc
@@ -707,9 +707,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count,
if (!table_ptr[i]-> file->
check_if_locking_is_allowed(thd->lex->sql_command, thd->lex->type,
table_ptr[i], count, i, &system_count,
- (thd == logger.get_general_log_thd()) ||
- (thd == logger.get_slow_log_thd()) ||
- (thd == logger.get_privileged_thread())))
+ logger.is_privileged_thread(thd)))
DBUG_RETURN(0);
}
diff --git a/sql/log.h b/sql/log.h
index 25bcbd6c62d..d92e0117bcc 100644
--- a/sql/log.h
+++ b/sql/log.h
@@ -600,6 +600,12 @@ public:
else
return NULL;
}
+ bool is_privileged_thread(THD *thd)
+ {
+ return thd == get_general_log_thd() ||
+ thd == get_slow_log_thd() ||
+ thd == get_privileged_thread();
+ }
};
enum enum_binlog_format {
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index b798106082a..2450429fb69 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -4018,6 +4018,11 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen)
{
DBUG_ASSERT(thd->lock == 0); // You must lock everything at once
TABLE **start,**ptr;
+ uint lock_flag= MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN;
+
+ /* Don't honor the GLOBAL READ LOCK if called from a logger */
+ if (logger.is_privileged_thread(thd))
+ lock_flag|= MYSQL_LOCK_IGNORE_GLOBAL_READ_LOCK;
if (!(ptr=start=(TABLE**) thd->alloc(sizeof(TABLE*)*count)))
DBUG_RETURN(-1);
@@ -4046,8 +4051,7 @@ int lock_tables(THD *thd, TABLE_LIST *tables, uint count, bool *need_reopen)
}
if (! (thd->lock= mysql_lock_tables(thd, start, (uint) (ptr - start),
- MYSQL_LOCK_NOTIFY_IF_NEED_REOPEN,
- need_reopen)))
+ lock_flag, need_reopen)))
{
if (thd->lex->requires_prelocking())
{