diff options
author | unknown <thek@adventure.(none)> | 2007-07-27 16:56:29 +0200 |
---|---|---|
committer | unknown <thek@adventure.(none)> | 2007-07-27 16:56:29 +0200 |
commit | 07955aea2dc369be7637f28331bd1072a995d572 (patch) | |
tree | 2debe5900b642c4da4ed6a2427488d82f62e2784 /mysql-test/r/sp-prelocking.result | |
parent | 607ab14cf767ed0187e0c050ed61cb4ebaf34bb7 (diff) | |
download | mariadb-git-07955aea2dc369be7637f28331bd1072a995d572.tar.gz |
Bug #29929 LOCK TABLES does not pre-lock tables used in triggers of the locked tables
When a table was explicitly locked with LOCK TABLES no associated
tables from any related trigger on the subject table were locked.
As a result of this the user could experience unexpected locking
behavior and statement failures similar to "failed: 1100: Table'xx'
was not locked with LOCK TABLES".
This patch fixes this problem by making sure triggers are
pre-loaded on any statement if the subject table was explicitly
locked with LOCK TABLES.
mysql-test/r/sp-prelocking.result:
Added test case
mysql-test/t/sp-prelocking.test:
Added test case
sql/sql_lex.cc:
- Moved some conditional logic out of the table iteration.
- Added event map values for LOCK TABLE command.
sql/table.cc:
- Refactored set_trg_event_tpye into the two simpler functions set_trg_event_map
and set_trg_event_map as methods for manipulating the table event map.
The original function was only called from st_lex::set_trg_event_type_for_tables
so it was possible to move the event map creation logic to this function as
a loop optimization.
sql/table.h:
- Refactored set_trg_event_tpye into the two simpler functions set_trg_event_map
and set_trg_event_map as methods for manipulating the table event map.
The original function was only called from st_lex::set_trg_event_type_for_tables
so it was possible to move the event map creation logic to this function as
a loop optimization.
Diffstat (limited to 'mysql-test/r/sp-prelocking.result')
-rw-r--r-- | mysql-test/r/sp-prelocking.result | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/mysql-test/r/sp-prelocking.result b/mysql-test/r/sp-prelocking.result index c19bd1abd26..186b2c05d34 100644 --- a/mysql-test/r/sp-prelocking.result +++ b/mysql-test/r/sp-prelocking.result @@ -289,4 +289,34 @@ create table t1 select f_bug22427() as i; ERROR 42S01: Table 't1' already exists drop table t1; drop function f_bug22427; +# +# Bug #29929 LOCK TABLES does not pre-lock tables used in triggers of the locked tables +# +DROP table IF EXISTS t1,t2; +CREATE TABLE t1 (c1 INT); +CREATE TABLE t2 (c2 INT); +INSERT INTO t1 VALUES (1); +INSERT INTO t2 VALUES (2); +CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW +BEGIN +UPDATE t2 SET c2= c2 + 1; +END// +# Take a table lock on t1. +# This should pre-lock t2 through the trigger. +LOCK TABLE t1 WRITE; +INSERT INTO t1 VALUES (3); +UNLOCK TABLES; +LOCK TABLE t1 READ; +INSERT INTO t2 values(4); +ERROR HY000: Table 't2' was not locked with LOCK TABLES +UNLOCK TABLES; +SELECT * FROM t1; +c1 +1 +3 +SELECT * FROM t2; +c2 +3 +DROP TRIGGER t1_ai; +DROP TABLE t1, t2; End of 5.0 tests |