Fix a case where a corrupt stat4 record could go unrecognized due to integer overflow.
[sqlite.git] / test / triggerF.test
blob2e3e35e3b2dcb1bc74607bfd2f2d8e90190c82ac
1 # 2017 January 4
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} {
17   finish_test
18   return
22 foreach {tn sql log} {
23   1 {} {}
25   2 { 
26     CREATE TRIGGER trd AFTER DELETE ON t1 BEGIN
27       INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
28     END;
29   } {1one2 2two1 3three1}
31   3 { 
32     CREATE TRIGGER trd BEFORE DELETE ON t1 BEGIN
33       INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
34     END;
35   } {1one3 2two2 3three2}
37   4 { 
38     CREATE TRIGGER tr1 AFTER DELETE ON t1 BEGIN
39       INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
40     END;
41     CREATE TRIGGER tr2 BEFORE DELETE ON t1 BEGIN
42       INSERT INTO log VALUES(old.a || old.b || (SELECT count(*) FROM t1));
43     END;
44   } {1one3 1one2 2two2 2two1 3three2 3three1}
46 } {
47   reset_db
48   do_execsql_test 1.$tn.0 {
49     PRAGMA recursive_triggers = on;
50     CREATE TABLE t1(a INT PRIMARY KEY, b) WITHOUT ROWID;
51     CREATE TABLE log(t);
52   }
53   
54   execsql $sql
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;
64   }
66   do_execsql_test 1.$tn.2 {
67     SELECT * FROM log ORDER BY rowid;
68   } $log
71 finish_test