summaryrefslogtreecommitdiff
path: root/mysql-test/t/trigger.test
diff options
context:
space:
mode:
authorunknown <gluh@mysql.com/eagle.(none)>2007-01-23 14:08:58 +0400
committerunknown <gluh@mysql.com/eagle.(none)>2007-01-23 14:08:58 +0400
commitacef88bee3bb91c2f28af504b69816038fd06977 (patch)
treeee8fd10d07635f84321d631699151d2b6ed34533 /mysql-test/t/trigger.test
parent644e6c7fdd75b9e6e869927d956e38964eb95494 (diff)
parent6447a7b6f2c45a16b24b18d5910036aeb514849c (diff)
downloadmariadb-git-acef88bee3bb91c2f28af504b69816038fd06977.tar.gz
Merge mysql.com:/home/gluh/MySQL/Merge/5.0
into mysql.com:/home/gluh/MySQL/Merge/5.0-opt mysql-test/r/func_in.result: Auto merged mysql-test/r/range.result: Auto merged mysql-test/r/sp-code.result: Auto merged mysql-test/t/func_in.test: Auto merged mysql-test/t/range.test: Auto merged mysql-test/t/trigger.test: Auto merged mysql-test/t/view.test: Auto merged sql/item.cc: Auto merged sql/item_func.cc: Auto merged sql/mysql_priv.h: Auto merged sql/sql_insert.cc: Auto merged sql/sql_lex.cc: Auto merged sql/sql_lex.h: Auto merged sql/sql_prepare.cc: Auto merged sql/sql_select.cc: Auto merged sql/sql_table.cc: Auto merged mysql-test/r/select.result: manual merge mysql-test/r/view.result: manual merge mysql-test/t/select.test: manual merge
Diffstat (limited to 'mysql-test/t/trigger.test')
-rw-r--r--mysql-test/t/trigger.test46
1 files changed, 46 insertions, 0 deletions
diff --git a/mysql-test/t/trigger.test b/mysql-test/t/trigger.test
index 63cef614b77..aa6cb2bf025 100644
--- a/mysql-test/t/trigger.test
+++ b/mysql-test/t/trigger.test
@@ -1554,4 +1554,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