2 #pragma ident "%Z%%M% %I% %E% SMI"
4 # The author disclaims copyright to this source code. In place of
5 # a legal notice, here is a blessing:
7 # May you do good and not evil.
8 # May you find forgiveness for yourself and forgive others.
9 # May you share freely, never taking more than you give.
11 #***********************************************************************
13 # This file tests the triggers of views.
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
19 do_test trigger4-1.1 {
21 create table test1(id integer primary key,a);
22 create table test2(id integer,b);
24 select test1.id as id,a as a,b as b
25 from test1 join test2 on test2.id = test1.id;
26 create trigger I_test instead of insert on test
28 insert into test1 (id,a) values (NEW.id,NEW.a);
29 insert into test2 (id,b) values (NEW.id,NEW.b);
31 insert into test values(1,2,3);
35 do_test trigger4-1.2 {
40 do_test trigger4-1.3 {
44 insert into test values(4,5,6);
48 do_test trigger4-1.4 {
54 do_test trigger4-2.1 {
56 create trigger U_test instead of update on test
58 update test1 set a=NEW.a where id=NEW.id;
59 update test2 set b=NEW.b where id=NEW.id;
61 update test set a=22 where id=1;
65 do_test trigger4-2.2 {
70 do_test trigger4-2.3 {
74 update test set b=66 where id=4;
78 do_test trigger4-2.4 {
84 do_test trigger4-3.1 {
87 insert into test values(7,8,9);
89 } {1 {no such table: main.test2}}
90 do_test trigger4-3.2 {
94 insert into test values(7,8,9);
96 } {1 {no such table: main.test2}}
97 do_test trigger4-3.3 {
99 update test set a=222 where id=1;
101 } {1 {no such table: main.test2}}
102 do_test trigger4-3.4 {
107 do_test trigger4-3.5 {
109 create table test2(id,b);
110 insert into test values(7,8,9);
114 do_test trigger4-3.6 {
119 do_test trigger4-3.7 {
123 update test set b=99 where id=7;
128 integrity_check trigger4-4.1