Bug #33000 | Triggers do not detect changes in meta-data. | ||
---|---|---|---|
Submitted: | 5 Dec 2007 14:31 | Modified: | 20 Jun 2012 16:40 |
Reporter: | Alexander Nozdrin | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S3 (Non-critical) |
Version: | 5.0/5.1, 5.1.24-BK | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[5 Dec 2007 14:31]
Alexander Nozdrin
[5 Dec 2007 16:05]
MySQL Verification Team
Thank you for the bug report. Verified as described. CREATE TABLE t1(c INT); -- base table for a trigger CREATE TABLE t2(a INT, b INT); INSERT INTO t2 VALUES (1, 2); CREATE TRIGGER t1_ai AFTER INSERT ON t1 FOR EACH ROW SELECT * FROM t2 INTO @a, @b; SELECT @a, @b; INSERT INTO t1 VALUES (1); -- activate the trigger SELECT @a, @b; ALTER TABLE t2 ADD COLUMN c INT; -- restart the server to flush the trigger cache. SELECT @a, @b; INSERT INTO t1 VALUES (2); -- activate the trigger SELECT @a, @b;
[25 Feb 2008 18:42]
Valeriy Kravchuk
The bug is still repeatable with latest 5.1.24-BK.
[30 Mar 2008 21:00]
Konstantin Osipov
Another test case (more severe): create table t1 (a int); create table t2 (a int unique); create table t3 (a int unique); create view v1 as select a from t2; create trigger t1_ai after insert on t1 for each row insert into v1 (a) values (new.a); insert into t1 (a) values (5); select * from t2; select * from t3; mysql> insert into t1 (a) values (6); ERROR 1146 (42S02): Table 'test.t2' doesn't exist (Which is weird to say the least). drop view v1; create view v1 as select a from t3; insert into t1 (a) values (6); This yields an error. Should insert into t3.
[30 Mar 2008 21:01]
Konstantin Osipov
Workaround: issue FLUSH TABLE/FLUSH TABLES
[30 Mar 2008 21:11]
Konstantin Osipov
Correct test case: create table t1 (a int); create table t2 (a int unique); create table t3 (a int unique); create view v1 as select a from t2; create trigger t1_ai after insert on t1 for each row insert into v1 (a) values (new.a); insert into t1 (a) values (5); select * from t2; select * from t3; dro pview v1; create view v1 as select a from t3;
[30 Mar 2008 21:15]
Konstantin Osipov
The weird error message is a funny side effect of the prelocking algorithm.
[20 Jun 2012 16:40]
Paul DuBois
Noted in 5.6.6 changelog. Failure of triggers to notice metadata changes in objects accessed within the program could cause trigger malfunction.
[16 Apr 2014 7:04]
MySQL Verification Team
One instance of the bug still hits 5.6, 5.7. Bug 18596756 - FAILED PREPARING OF TRIGGER ON TRUNCATED TABLES CAUSE ERROR 1054