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 #***********************************************************************
11 # This file implements regression tests for SQLite library.
13 # This file implements tests to make sure expression of an INSERT
14 # and UPDATE statement are only evaluated once. See ticket #980.
15 # If an expression uses a function that has side-effects or which
16 # is not deterministic (ex: random()) then we want to make sure
17 # that the same evaluation occurs for the actual INSERT/UPDATE and
18 # for the NEW.* fields of any triggers that fire.
20 # $Id: trigger6.test,v 1.2 2005/05/05 11:04:50 drh Exp $
22 set testdir [file dirname $argv0]
23 source $testdir/tester.tcl
24 ifcapable {!trigger} {
29 do_test trigger6-1.1 {
31 CREATE TABLE t1(x, y);
32 CREATE TABLE log(a, b, c);
33 CREATE TRIGGER r1 BEFORE INSERT ON t1 BEGIN
34 INSERT INTO log VALUES(1, new.x, new.y);
36 CREATE TRIGGER r2 BEFORE UPDATE ON t1 BEGIN
37 INSERT INTO log VALUES(2, new.x, new.y);
41 proc trigger6_counter {args} {
43 return $::trigger6_cnt
45 db function counter trigger6_counter
47 INSERT INTO t1 VALUES(1,counter());
51 do_test trigger6-1.2 {
56 do_test trigger6-1.3 {
60 INSERT INTO t1 VALUES(2,counter(2,3)+4);
64 do_test trigger6-1.4 {
69 do_test trigger6-1.5 {
72 UPDATE t1 SET y=counter(5);
76 do_test trigger6-1.6 {