sl@0: # 2007 Oct 3 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # sl@0: # This file is to test that ticket #2767 has been fixed. sl@0: # Ticket #2767 is for a VDBE stack overflow on BEFORE sl@0: # triggers that run RAISE(IGNORE). sl@0: # sl@0: # $Id: tkt2767.test,v 1.2 2008/07/12 14:52:21 drh Exp $ sl@0: # sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: do_test tkt2767-1.1 { sl@0: execsql { sl@0: -- Construct a table with many rows of data sl@0: CREATE TABLE t1(x); sl@0: INSERT INTO t1 VALUES(1); sl@0: INSERT INTO t1 VALUES(2); sl@0: INSERT INTO t1 SELECT x+2 FROM t1; sl@0: INSERT INTO t1 SELECT x+4 FROM t1; sl@0: INSERT INTO t1 SELECT x+8 FROM t1; sl@0: INSERT INTO t1 SELECT x+16 FROM t1; sl@0: sl@0: -- BEFORE triggers that invoke raise(ignore). The effect of sl@0: -- these triggers should be to make INSERTs, UPDATEs, and DELETEs sl@0: -- into no-ops. sl@0: CREATE TRIGGER r1 BEFORE UPDATE ON t1 BEGIN sl@0: SELECT raise(ignore); sl@0: END; sl@0: CREATE TRIGGER r2 BEFORE DELETE ON t1 BEGIN sl@0: SELECT raise(ignore); sl@0: END; sl@0: CREATE TRIGGER r3 BEFORE INSERT ON t1 BEGIN sl@0: SELECT raise(ignore); sl@0: END; sl@0: sl@0: -- Verify the table content sl@0: SELECT count(*), sum(x) FROM t1; sl@0: } sl@0: } {32 528} sl@0: sl@0: # Try to delete all elements of the table. This will invoke the sl@0: # DELETE trigger 32 times, which should overflow the VDBE stack if sl@0: # the problem of #2767 is not fixed. If the problem is fixed, all sl@0: # the deletes should be no-ops so the table should remain unchanged. sl@0: # sl@0: do_test tkt2767-1.2 { sl@0: execsql { sl@0: DELETE FROM t1 WHERE x>0; sl@0: SELECT count(*), sum(x) FROM t1; sl@0: } sl@0: } {32 528} sl@0: sl@0: # Try to update all elements of the table. This will invoke the sl@0: # UPDATE trigger 32 times, which should overflow the VDBE stack if sl@0: # the problem of #2767 is not fixed. If the problem is fixed, all sl@0: # the updates should be no-ops so the table should remain unchanged. sl@0: # sl@0: do_test tkt2767-1.3 { sl@0: execsql { sl@0: UPDATE t1 SET x=x+1; sl@0: SELECT count(*), sum(x) FROM t1; sl@0: } sl@0: } {32 528} sl@0: sl@0: # Invoke the insert trigger. The insert trigger was working sl@0: # even prior to the fix of #2767. But it seems good to go ahead sl@0: # and verify that it works. sl@0: # sl@0: do_test tkt2767-1.4 { sl@0: execsql { sl@0: INSERT INTO t1 SELECT x+32 FROM t1; sl@0: SELECT count(*), sum(x) FROM t1; sl@0: } sl@0: } {32 528} sl@0: sl@0: sl@0: sl@0: finish_test