blob: f9986990069b34aa8343466122c386f44b141442 [file] [log] [blame]
danielk19772d786172007-12-12 14:46:58 +00001# 2007 Dec 12
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
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.
9#
10#***********************************************************************
11#
12# This file is to test that ticket #2832 has been fixed.
13#
danielk19772943c372009-04-07 14:14:22 +000014# $Id: tkt2832.test,v 1.5 2009/04/07 14:14:23 danielk1977 Exp $
danielk19772d786172007-12-12 14:46:58 +000015#
16
17set testdir [file dirname $argv0]
18source $testdir/tester.tcl
19
danielk19772943c372009-04-07 14:14:22 +000020ifcapable !trigger { finish_test ; return }
21
danielk1977967573d2007-12-12 16:06:23 +000022do_test tkt2832-1.1 {
danielk19772d786172007-12-12 14:46:58 +000023 execsql {
24 CREATE TABLE t1(a PRIMARY KEY);
25 INSERT INTO t1 VALUES(2);
26 INSERT INTO t1 VALUES(1);
27 INSERT INTO t1 VALUES(3);
28 }
29} {}
danielk1977967573d2007-12-12 16:06:23 +000030do_test tkt2832-1.2 {
danielk19772d786172007-12-12 14:46:58 +000031 execsql {
32 UPDATE OR REPLACE t1 SET a = 1;
33 SELECT * FROM t1;
34 }
35} {1}
36
danielk1977967573d2007-12-12 16:06:23 +000037do_test tkt2832-2.1 {
38 execsql {
39 CREATE TABLE t2(a, b);
40 CREATE TRIGGER t2_t AFTER UPDATE ON t2 BEGIN
41 DELETE FROM t2 WHERE a = new.a + 1;
42 END;
43 INSERT INTO t2 VALUES(1, 2);
44 INSERT INTO t2 VALUES(2, 3);
45 }
46} {}
47do_test tkt2832-2.2 {
48 execsql {
49 UPDATE t2 SET b = 5
50 }
51} {}
52
53do_test tkt2832-3.1 {
54 execsql {
55 CREATE TABLE t3(a, b);
56 CREATE TRIGGER t3_t AFTER DELETE ON t3 BEGIN
57 DELETE FROM t3 WHERE a = old.a + 1;
58 END;
59 INSERT INTO t3 VALUES(1, 2);
60 INSERT INTO t3 VALUES(2, 3);
61 }
62} {}
63do_test tkt2832-3.2 {
danielk1977967573d2007-12-12 16:06:23 +000064 execsql { DELETE FROM t3 WHERE 1 }
65} {}
66
danielk19772d786172007-12-12 14:46:58 +000067finish_test