1# 2008 April 15 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# This file implements regression tests for SQLite library. Specifically, 12# it tests updating tables with constraints within a trigger. Ticket #3055. 13# 14 15set testdir [file dirname $argv0] 16source $testdir/tester.tcl 17ifcapable {!trigger} { 18 finish_test 19 return 20} 21 22# Create test tables with constraints. 23# 24do_test triggerB-1.1 { 25 execsql { 26 CREATE TABLE x(x INTEGER PRIMARY KEY, y INT NOT NULL); 27 INSERT INTO x(y) VALUES(1); 28 INSERT INTO x(y) VALUES(1); 29 CREATE TEMP VIEW vx AS SELECT x, y, 0 AS yy FROM x; 30 CREATE TEMP TRIGGER tx INSTEAD OF UPDATE OF y ON vx 31 BEGIN 32 UPDATE x SET y = new.y WHERE x = new.x; 33 END; 34 SELECT * FROM vx; 35 } 36} {1 1 0 2 1 0} 37do_test triggerB-1.2 { 38breakpoint 39 execsql { 40 UPDATE vx SET y = yy; 41 SELECT * FROM vx; 42 } 43} {1 0 0 2 0 0} 44 45finish_test 46