3 # The author disclaims copyright to this source code. In place of
4 # a legal notice', here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 set testprefix triggerF
16 ifcapable {!trigger} {
22 foreach {tn sql log} {
26 CREATE TRIGGER trd AFTER DELETE ON t1 BEGIN
27 INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
29 } {1one2 2two1 3three1}
32 CREATE TRIGGER trd BEFORE DELETE ON t1 BEGIN
33 INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
35 } {1one3 2two2 3three2}
38 CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN
39 INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
41 CREATE TRIGGER tr2 BEFORE DELETE ON t1 BEGIN
42 INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
44 } {1one3 1one2 2two2 2two1 3three2 3three1}
48 do_execsql_test 1.$tn.0 {
49 PRAGMA recursive_triggers = on;
50 CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;
56 do_execsql_test 1.$tn.1 {
57 INSERT INTO t1 VALUES(1, 'one');
58 INSERT INTO t1 VALUES(2, 'two');
59 INSERT INTO t1 VALUES(3, 'three');
61 DELETE FROM t1 WHERE a=1;
62 INSERT OR REPLACE INTO t1 VALUES(2, 'three');
63 UPDATE OR REPLACE t1 SET a=3 WHERE a=2;
66 do_execsql_test 1.$tn.2 {
67 SELECT * FROM log ORDER BY rowid;