First public contribution.
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 #***********************************************************************
12 # This file tests changes to the name resolution logic that occurred
13 # in august of 2008 and where associated with tickets #3298 and #3301
15 # $Id: tkt3298.test,v 1.2 2008/08/22 12:46:46 drh Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
22 CREATE TABLE t1(a INTEGER PRIMARY KEY, b INT);
23 INSERT INTO t1 VALUES(0, 1);
24 INSERT INTO t1 VALUES(1, 1);
25 INSERT INTO t1 VALUES(2, 1);
26 CREATE VIEW v1 AS SELECT a AS x, b+1 AS y FROM t1;
27 CREATE TRIGGER r1 INSTEAD OF UPDATE ON v1
29 UPDATE t1 SET b=new.y-1 WHERE a=new.x;
31 CREATE TRIGGER r2 INSTEAD OF DELETE ON v1
33 DELETE FROM t1 WHERE a=old.x;
35 SELECT * FROM v1 ORDER BY x;
40 UPDATE v1 SET y=3 WHERE x=0;
41 SELECT * FROM v1 ORDER by x;
46 UPDATE v1 SET y=4 WHERE v1.x=2;
47 SELECT * FROM v1 ORDER by x;
52 DELETE FROM v1 WHERE x=1;
53 SELECT * FROM v1 ORDER BY x;
58 DELETE FROM v1 WHERE v1.x=2;
59 SELECT * FROM v1 ORDER BY x;
68 INSERT INTO t2 VALUES(1,11);
69 INSERT INTO t2 VALUES(2,22);
71 INSERT INTO t3 VALUES(1,'one');
73 SELECT *, (SELECT z FROM (SELECT y AS z FROM t3 WHERE x=t1.a+1) ) FROM t1;