diff options
author | unknown <igor@olga.mysql.com> | 2007-01-12 13:43:25 -0800 |
---|---|---|
committer | unknown <igor@olga.mysql.com> | 2007-01-12 13:43:25 -0800 |
commit | 35e363932cdcf626efe42006df98f7182731e427 (patch) | |
tree | 5881e473ef67266d5a7ce068255ea2fec126bd6e /mysql-test/t/trigger.test | |
parent | 0f0d0f5bd45ef87ff75bc15c3faac8d9cb97c154 (diff) | |
download | mariadb-git-35e363932cdcf626efe42006df98f7182731e427.tar.gz |
Fixed bug #25398: crash in a trigger when using trigger fields
in a select list.
The objects of the Item_trigger_field class inherited the implementations
of the methods copy_or_same, get_tmp_table_item and get_tmp_table_field
from the class Item_field while they rather should have used the default
implementations defined for the base class Item.
It could cause catastrophic problems for triggers that used SELECTs
with select list containing trigger fields such as NEW.<table column>
under DISTINCT.
mysql-test/r/trigger.result:
Added a test case for bug #25398.
mysql-test/t/trigger.test:
Added a test case for bug #25398.
Diffstat (limited to 'mysql-test/t/trigger.test')
-rw-r--r-- | mysql-test/t/trigger.test | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test index ae01a4b2c3d..ea569f4ce09 100644 --- a/mysql-test/t/trigger.test +++ b/mysql-test/t/trigger.test @@ -1548,4 +1548,50 @@ select * from t1; drop table t1; +# +# Bug#25398: crash when a trigger contains a SELECT with +# trigger fields in the select list under DISTINCT +# + +CREATE TABLE t1 ( + id int NOT NULL DEFAULT '0', + a varchar(10) NOT NULL, + b varchar(10), + c varchar(10), + d timestamp NOT NULL, + PRIMARY KEY (id, a) +); + +CREATE TABLE t2 ( + fubar_id int unsigned NOT NULL DEFAULT '0', + last_change_time datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (fubar_id) +); + +DELIMITER |; + +CREATE TRIGGER fubar_change + AFTER UPDATE ON t1 + FOR EACH ROW + BEGIN + INSERT INTO t2 (fubar_id, last_change_time) + SELECT DISTINCT NEW.id AS fubar_id, NOW() AS last_change_time + FROM t1 WHERE (id = NEW.id) AND (OLD.c != NEW.c) + ON DUPLICATE KEY UPDATE + last_change_time = + IF((fubar_id = NEW.id)AND(OLD.c != NEW.c),NOW(),last_change_time); + END +| + +DELIMITER ;| + +INSERT INTO t1 (id,a, b,c,d) VALUES + (1,'a','b','c',now()),(2,'a','b','c',now()); + +UPDATE t1 SET c='Bang!' WHERE id=1; + +SELECT fubar_id FROM t2; + +DROP TABLE t1,t2; + --echo End of 5.0 tests |