drh | 138eeeb | 2013-03-27 03:15:23 +0000 | [diff] [blame] | 1 | # 2013 March 27 |
| 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 that ticket [6bfb98dfc0] |
| 13 | # |
| 14 | # The final INSERT in the script below reports that the database is |
| 15 | # corrupt (SQLITE_CORRUPT) and aborts even though the database is not |
| 16 | # corrupt. |
| 17 | # |
| 18 | # PRAGMA page_size=512; |
| 19 | # CREATE TABLE t1(x INTEGER PRIMARY KEY, y); |
| 20 | # INSERT INTO t1 VALUES(1,randomblob(400)); |
| 21 | # INSERT INTO t1 VALUES(2,randomblob(400)); |
| 22 | # INSERT INTO t1 SELECT x+2, randomblob(400) FROM t1; |
| 23 | # INSERT INTO t1 SELECT x+4, randomblob(400) FROM t1; |
| 24 | # INSERT INTO t1 SELECT x+8, randomblob(400) FROM t1; |
| 25 | # INSERT INTO t1 SELECT x+16, randomblob(400) FROM t1; |
| 26 | # INSERT INTO t1 SELECT x+32, randomblob(400) FROM t1; |
| 27 | # INSERT INTO t1 SELECT x+64, randomblob(400) FROM t1 WHERE x<10; |
| 28 | # CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.x=74 BEGIN |
| 29 | # DELETE FROM t1; |
| 30 | # INSERT INTO t1 VALUES(75, randomblob(400)); |
| 31 | # INSERT INTO t1 VALUES(76, randomblob(400)); |
| 32 | # END; |
| 33 | # INSERT INTO t1 VALUES(74, randomblob(400)); |
| 34 | # |
| 35 | |
| 36 | set testdir [file dirname $argv0] |
| 37 | source $testdir/tester.tcl |
| 38 | |
| 39 | do_test tkt-6bfb98dfc0.100 { |
| 40 | db eval { |
| 41 | PRAGMA page_size=512; |
| 42 | CREATE TABLE t1(x INTEGER PRIMARY KEY, y); |
| 43 | INSERT INTO t1 VALUES(1,randomblob(400)); |
| 44 | INSERT INTO t1 VALUES(2,randomblob(400)); |
| 45 | INSERT INTO t1 SELECT x+2, randomblob(400) FROM t1; |
| 46 | INSERT INTO t1 SELECT x+4, randomblob(400) FROM t1; |
| 47 | INSERT INTO t1 SELECT x+8, randomblob(400) FROM t1; |
| 48 | INSERT INTO t1 SELECT x+16, randomblob(400) FROM t1; |
| 49 | INSERT INTO t1 SELECT x+32, randomblob(400) FROM t1; |
| 50 | INSERT INTO t1 SELECT x+64, randomblob(400) FROM t1 WHERE x<10; |
| 51 | CREATE TRIGGER r1 AFTER INSERT ON t1 WHEN new.x=74 BEGIN |
| 52 | DELETE FROM t1; |
| 53 | INSERT INTO t1 VALUES(75, randomblob(400)); |
| 54 | INSERT INTO t1 VALUES(76, randomblob(400)); |
| 55 | END; |
| 56 | INSERT INTO t1 VALUES(74, randomblob(400)); |
| 57 | SELECT x, length(y) FROM t1 ORDER BY x; |
| 58 | } |
| 59 | } {75 400 76 400} |
| 60 | |
| 61 | finish_test |