drh | 9a47736 | 2007-08-10 19:46:43 +0000 | [diff] [blame] | 1 | # 2007 Aug 10 |
| 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 test script reproduces the problem reported by ticket #2565, |
| 13 | # A database corruption bug that occurs in auto_vacuum mode when |
| 14 | # the soft_heap_limit is set low enough to be triggered. |
| 15 | # |
danielk1977 | 1bc7159 | 2008-07-08 17:13:59 +0000 | [diff] [blame] | 16 | # $Id: softheap1.test,v 1.5 2008/07/08 17:13:59 danielk1977 Exp $ |
drh | 9a47736 | 2007-08-10 19:46:43 +0000 | [diff] [blame] | 17 | |
| 18 | |
| 19 | set testdir [file dirname $argv0] |
| 20 | source $testdir/tester.tcl |
| 21 | |
danielk1977 | 4152e67 | 2007-09-12 17:01:45 +0000 | [diff] [blame] | 22 | ifcapable !integrityck { |
| 23 | finish_test |
| 24 | return |
| 25 | } |
| 26 | |
drh | 51a74d4 | 2015-02-28 01:04:27 +0000 | [diff] [blame] | 27 | # EVIDENCE-OF: R-26343-45930 This pragma invokes the |
| 28 | # sqlite3_soft_heap_limit64() interface with the argument N, if N is |
| 29 | # specified and is a non-negative integer. |
| 30 | # |
| 31 | # EVIDENCE-OF: R-64451-07163 The soft_heap_limit pragma always returns |
| 32 | # the same integer that would be returned by the |
| 33 | # sqlite3_soft_heap_limit64(-1) C-language function. |
| 34 | # |
drh | 55e85ca | 2013-09-13 21:01:56 +0000 | [diff] [blame] | 35 | do_test softheap1-1.0 { |
| 36 | execsql {PRAGMA soft_heap_limit} |
| 37 | } [sqlite3_soft_heap_limit -1] |
drh | 9a47736 | 2007-08-10 19:46:43 +0000 | [diff] [blame] | 38 | do_test softheap1-1.1 { |
drh | 55e85ca | 2013-09-13 21:01:56 +0000 | [diff] [blame] | 39 | execsql {PRAGMA soft_heap_limit=123456; PRAGMA soft_heap_limit;} |
| 40 | } {123456 123456} |
| 41 | do_test softheap1-1.2 { |
| 42 | sqlite3_soft_heap_limit -1 |
| 43 | } {123456} |
| 44 | do_test softheap1-1.3 { |
| 45 | execsql {PRAGMA soft_heap_limit(-1); PRAGMA soft_heap_limit;} |
| 46 | } {123456 123456} |
| 47 | do_test softheap1-1.4 { |
| 48 | execsql {PRAGMA soft_heap_limit(0); PRAGMA soft_heap_limit;} |
| 49 | } {0 0} |
| 50 | |
| 51 | sqlite3_soft_heap_limit 5000 |
| 52 | do_test softheap1-2.0 { |
| 53 | execsql {PRAGMA soft_heap_limit} |
| 54 | } {5000} |
| 55 | do_test softheap1-2.1 { |
drh | 9a47736 | 2007-08-10 19:46:43 +0000 | [diff] [blame] | 56 | execsql { |
| 57 | PRAGMA auto_vacuum=1; |
| 58 | CREATE TABLE t1(x); |
drh | 3aefaba | 2007-08-12 20:07:58 +0000 | [diff] [blame] | 59 | INSERT INTO t1 VALUES(hex(randomblob(1000))); |
drh | 9a47736 | 2007-08-10 19:46:43 +0000 | [diff] [blame] | 60 | BEGIN; |
drh | 3aefaba | 2007-08-12 20:07:58 +0000 | [diff] [blame] | 61 | } |
| 62 | execsql { |
drh | 9a47736 | 2007-08-10 19:46:43 +0000 | [diff] [blame] | 63 | CREATE TABLE t2 AS SELECT * FROM t1; |
drh | 3aefaba | 2007-08-12 20:07:58 +0000 | [diff] [blame] | 64 | } |
| 65 | execsql { |
drh | 9a47736 | 2007-08-10 19:46:43 +0000 | [diff] [blame] | 66 | ROLLBACK; |
drh | 3aefaba | 2007-08-12 20:07:58 +0000 | [diff] [blame] | 67 | } |
| 68 | execsql { |
drh | 9a47736 | 2007-08-10 19:46:43 +0000 | [diff] [blame] | 69 | PRAGMA integrity_check; |
| 70 | } |
| 71 | } {ok} |
danielk1977 | 1bc7159 | 2008-07-08 17:13:59 +0000 | [diff] [blame] | 72 | |
dan | c1a60c5 | 2010-06-07 14:28:16 +0000 | [diff] [blame] | 73 | sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) |
drh | 9a47736 | 2007-08-10 19:46:43 +0000 | [diff] [blame] | 74 | finish_test |