1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt2767.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,88 @@
1.4 +# 2007 Oct 3
1.5 +#
1.6 +# The author disclaims copyright to this source code. In place of
1.7 +# a legal notice, here is a blessing:
1.8 +#
1.9 +# May you do good and not evil.
1.10 +# May you find forgiveness for yourself and forgive others.
1.11 +# May you share freely, never taking more than you give.
1.12 +#
1.13 +#***********************************************************************
1.14 +#
1.15 +# This file is to test that ticket #2767 has been fixed.
1.16 +# Ticket #2767 is for a VDBE stack overflow on BEFORE
1.17 +# triggers that run RAISE(IGNORE).
1.18 +#
1.19 +# $Id: tkt2767.test,v 1.2 2008/07/12 14:52:21 drh Exp $
1.20 +#
1.21 +
1.22 +set testdir [file dirname $argv0]
1.23 +source $testdir/tester.tcl
1.24 +
1.25 +do_test tkt2767-1.1 {
1.26 + execsql {
1.27 + -- Construct a table with many rows of data
1.28 + CREATE TABLE t1(x);
1.29 + INSERT INTO t1 VALUES(1);
1.30 + INSERT INTO t1 VALUES(2);
1.31 + INSERT INTO t1 SELECT x+2 FROM t1;
1.32 + INSERT INTO t1 SELECT x+4 FROM t1;
1.33 + INSERT INTO t1 SELECT x+8 FROM t1;
1.34 + INSERT INTO t1 SELECT x+16 FROM t1;
1.35 +
1.36 + -- BEFORE triggers that invoke raise(ignore). The effect of
1.37 + -- these triggers should be to make INSERTs, UPDATEs, and DELETEs
1.38 + -- into no-ops.
1.39 + CREATE TRIGGER r1 BEFORE UPDATE ON t1 BEGIN
1.40 + SELECT raise(ignore);
1.41 + END;
1.42 + CREATE TRIGGER r2 BEFORE DELETE ON t1 BEGIN
1.43 + SELECT raise(ignore);
1.44 + END;
1.45 + CREATE TRIGGER r3 BEFORE INSERT ON t1 BEGIN
1.46 + SELECT raise(ignore);
1.47 + END;
1.48 +
1.49 + -- Verify the table content
1.50 + SELECT count(*), sum(x) FROM t1;
1.51 + }
1.52 +} {32 528}
1.53 +
1.54 +# Try to delete all elements of the table. This will invoke the
1.55 +# DELETE trigger 32 times, which should overflow the VDBE stack if
1.56 +# the problem of #2767 is not fixed. If the problem is fixed, all
1.57 +# the deletes should be no-ops so the table should remain unchanged.
1.58 +#
1.59 +do_test tkt2767-1.2 {
1.60 + execsql {
1.61 + DELETE FROM t1 WHERE x>0;
1.62 + SELECT count(*), sum(x) FROM t1;
1.63 + }
1.64 +} {32 528}
1.65 +
1.66 +# Try to update all elements of the table. This will invoke the
1.67 +# UPDATE trigger 32 times, which should overflow the VDBE stack if
1.68 +# the problem of #2767 is not fixed. If the problem is fixed, all
1.69 +# the updates should be no-ops so the table should remain unchanged.
1.70 +#
1.71 +do_test tkt2767-1.3 {
1.72 + execsql {
1.73 + UPDATE t1 SET x=x+1;
1.74 + SELECT count(*), sum(x) FROM t1;
1.75 + }
1.76 +} {32 528}
1.77 +
1.78 +# Invoke the insert trigger. The insert trigger was working
1.79 +# even prior to the fix of #2767. But it seems good to go ahead
1.80 +# and verify that it works.
1.81 +#
1.82 +do_test tkt2767-1.4 {
1.83 + execsql {
1.84 + INSERT INTO t1 SELECT x+32 FROM t1;
1.85 + SELECT count(*), sum(x) FROM t1;
1.86 + }
1.87 +} {32 528}
1.88 +
1.89 +
1.90 +
1.91 +finish_test