OLD | NEW |
(Empty) | |
| 1 # 2007 Oct 3 |
| 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 # |
| 12 # This file is to test that ticket #2767 has been fixed. |
| 13 # Ticket #2767 is for a VDBE stack overflow on BEFORE |
| 14 # triggers that run RAISE(IGNORE). |
| 15 # |
| 16 # $Id: tkt2767.test,v 1.3 2009/04/07 14:14:23 danielk1977 Exp $ |
| 17 # |
| 18 |
| 19 set testdir [file dirname $argv0] |
| 20 source $testdir/tester.tcl |
| 21 |
| 22 ifcapable !trigger { finish_test ; return } |
| 23 |
| 24 do_test tkt2767-1.1 { |
| 25 execsql { |
| 26 -- Construct a table with many rows of data |
| 27 CREATE TABLE t1(x); |
| 28 INSERT INTO t1 VALUES(1); |
| 29 INSERT INTO t1 VALUES(2); |
| 30 INSERT INTO t1 SELECT x+2 FROM t1; |
| 31 INSERT INTO t1 SELECT x+4 FROM t1; |
| 32 INSERT INTO t1 SELECT x+8 FROM t1; |
| 33 INSERT INTO t1 SELECT x+16 FROM t1; |
| 34 |
| 35 -- BEFORE triggers that invoke raise(ignore). The effect of |
| 36 -- these triggers should be to make INSERTs, UPDATEs, and DELETEs |
| 37 -- into no-ops. |
| 38 CREATE TRIGGER r1 BEFORE UPDATE ON t1 BEGIN |
| 39 SELECT raise(ignore); |
| 40 END; |
| 41 CREATE TRIGGER r2 BEFORE DELETE ON t1 BEGIN |
| 42 SELECT raise(ignore); |
| 43 END; |
| 44 CREATE TRIGGER r3 BEFORE INSERT ON t1 BEGIN |
| 45 SELECT raise(ignore); |
| 46 END; |
| 47 |
| 48 -- Verify the table content |
| 49 SELECT count(*), sum(x) FROM t1; |
| 50 } |
| 51 } {32 528} |
| 52 |
| 53 # Try to delete all elements of the table. This will invoke the |
| 54 # DELETE trigger 32 times, which should overflow the VDBE stack if |
| 55 # the problem of #2767 is not fixed. If the problem is fixed, all |
| 56 # the deletes should be no-ops so the table should remain unchanged. |
| 57 # |
| 58 do_test tkt2767-1.2 { |
| 59 execsql { |
| 60 DELETE FROM t1 WHERE x>0; |
| 61 SELECT count(*), sum(x) FROM t1; |
| 62 } |
| 63 } {32 528} |
| 64 |
| 65 # Try to update all elements of the table. This will invoke the |
| 66 # UPDATE trigger 32 times, which should overflow the VDBE stack if |
| 67 # the problem of #2767 is not fixed. If the problem is fixed, all |
| 68 # the updates should be no-ops so the table should remain unchanged. |
| 69 # |
| 70 do_test tkt2767-1.3 { |
| 71 execsql { |
| 72 UPDATE t1 SET x=x+1; |
| 73 SELECT count(*), sum(x) FROM t1; |
| 74 } |
| 75 } {32 528} |
| 76 |
| 77 # Invoke the insert trigger. The insert trigger was working |
| 78 # even prior to the fix of #2767. But it seems good to go ahead |
| 79 # and verify that it works. |
| 80 # |
| 81 do_test tkt2767-1.4 { |
| 82 execsql { |
| 83 INSERT INTO t1 SELECT x+32 FROM t1; |
| 84 SELECT count(*), sum(x) FROM t1; |
| 85 } |
| 86 } {32 528} |
| 87 |
| 88 |
| 89 |
| 90 finish_test |
OLD | NEW |