summaryrefslogtreecommitdiff
path: root/sql/sql_trigger.cc
diff options
context:
space:
mode:
authorJon Olav Hauglid <jon.hauglid@sun.com>2009-12-09 15:25:48 +0100
committerJon Olav Hauglid <jon.hauglid@sun.com>2009-12-09 15:25:48 +0100
commitf3e9b392ac8dcdd79951a1e16b63415fc48fce0a (patch)
tree113e7d3bb3c8c29a92e520a1c4938e892807c3b8 /sql/sql_trigger.cc
parent832ad46641822b64fbf0e7f0e70b62ef7af504ac (diff)
downloadmariadb-git-f3e9b392ac8dcdd79951a1e16b63415fc48fce0a.tar.gz
Backport of revno: 2617.68.13
Introduce a counter for protection against global read lock on thread level. The functions for protection against global read lock sometimes need a local variable to signal when the protection is set, and hence need to be released. It would be better to control this behaviour via a counter on the THD struct, telling how many times the protection has been claimed by the current thread. A side-effect of the fix is that if protection is claimed twice for a thread, only a simple increment is required for the second claim, instead of a mutex-protected increment of the global variable protect_against_global_read_lock. sql/lock.cc: Count how many times that we have claimed protection against global read lock. Assert that we really have the protection when releasing it. Added comments to all functions operating on global_read_lock. sql/sql_class.cc: Added the counter variable global_read_lock_protection. sql/sql_class.h: Added the counter variable global_read_lock_protection. sql/sql_parse.cc: Replaced test on local variable need_start_waiting with test on thd->global_read_lock_protection. sql/sql_table.cc: Replaced test on local variable need_start_waiting with test on thd->global_read_lock_protection. sql/sql_trigger.cc: Inserted test on thd->global_read_lock_protection.
Diffstat (limited to 'sql/sql_trigger.cc')
-rw-r--r--sql/sql_trigger.cc6
1 files changed, 2 insertions, 4 deletions
diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc
index 015e0d4daa1..b3108cae3d9 100644
--- a/sql/sql_trigger.cc
+++ b/sql/sql_trigger.cc
@@ -328,7 +328,6 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
TABLE *table;
bool result= TRUE;
String stmt_query;
- bool need_start_waiting= FALSE;
bool lock_upgrade_done= FALSE;
MDL_ticket *mdl_ticket= NULL;
@@ -386,8 +385,7 @@ bool mysql_create_or_drop_trigger(THD *thd, TABLE_LIST *tables, bool create)
LOCK_open is not enough because global read lock is held without holding
LOCK_open).
*/
- if (!thd->locked_tables_mode &&
- !(need_start_waiting= !wait_if_global_read_lock(thd, 0, 1)))
+ if (!thd->locked_tables_mode && wait_if_global_read_lock(thd, 0, 1))
DBUG_RETURN(TRUE);
if (!create)
@@ -521,7 +519,7 @@ end:
if (thd->locked_tables_mode && tables && lock_upgrade_done)
mdl_ticket->downgrade_exclusive_lock();
- if (need_start_waiting)
+ if (thd->global_read_lock_protection > 0)
start_waiting_global_read_lock(thd);
if (!result)