19a47736eSdrh# 2007 Aug 10 29a47736eSdrh# 39a47736eSdrh# The author disclaims copyright to this source code. In place of 49a47736eSdrh# a legal notice, here is a blessing: 59a47736eSdrh# 69a47736eSdrh# May you do good and not evil. 79a47736eSdrh# May you find forgiveness for yourself and forgive others. 89a47736eSdrh# May you share freely, never taking more than you give. 99a47736eSdrh# 109a47736eSdrh#*********************************************************************** 119a47736eSdrh# 129a47736eSdrh# This test script reproduces the problem reported by ticket #2565, 139a47736eSdrh# A database corruption bug that occurs in auto_vacuum mode when 149a47736eSdrh# the soft_heap_limit is set low enough to be triggered. 159a47736eSdrh# 161bc71590Sdanielk1977# $Id: softheap1.test,v 1.5 2008/07/08 17:13:59 danielk1977 Exp $ 179a47736eSdrh 189a47736eSdrh 199a47736eSdrhset testdir [file dirname $argv0] 209a47736eSdrhsource $testdir/tester.tcl 219a47736eSdrh 224152e677Sdanielk1977ifcapable !integrityck { 234152e677Sdanielk1977 finish_test 244152e677Sdanielk1977 return 254152e677Sdanielk1977} 264152e677Sdanielk1977 27*51a74d4cSdrh# EVIDENCE-OF: R-26343-45930 This pragma invokes the 28*51a74d4cSdrh# sqlite3_soft_heap_limit64() interface with the argument N, if N is 29*51a74d4cSdrh# specified and is a non-negative integer. 30*51a74d4cSdrh# 31*51a74d4cSdrh# EVIDENCE-OF: R-64451-07163 The soft_heap_limit pragma always returns 32*51a74d4cSdrh# the same integer that would be returned by the 33*51a74d4cSdrh# sqlite3_soft_heap_limit64(-1) C-language function. 34*51a74d4cSdrh# 3555e85ca5Sdrhdo_test softheap1-1.0 { 3655e85ca5Sdrh execsql {PRAGMA soft_heap_limit} 3755e85ca5Sdrh} [sqlite3_soft_heap_limit -1] 389a47736eSdrhdo_test softheap1-1.1 { 3955e85ca5Sdrh execsql {PRAGMA soft_heap_limit=123456; PRAGMA soft_heap_limit;} 4055e85ca5Sdrh} {123456 123456} 4155e85ca5Sdrhdo_test softheap1-1.2 { 4255e85ca5Sdrh sqlite3_soft_heap_limit -1 4355e85ca5Sdrh} {123456} 4455e85ca5Sdrhdo_test softheap1-1.3 { 4555e85ca5Sdrh execsql {PRAGMA soft_heap_limit(-1); PRAGMA soft_heap_limit;} 4655e85ca5Sdrh} {123456 123456} 4755e85ca5Sdrhdo_test softheap1-1.4 { 4855e85ca5Sdrh execsql {PRAGMA soft_heap_limit(0); PRAGMA soft_heap_limit;} 4955e85ca5Sdrh} {0 0} 5055e85ca5Sdrh 5155e85ca5Sdrhsqlite3_soft_heap_limit 5000 5255e85ca5Sdrhdo_test softheap1-2.0 { 5355e85ca5Sdrh execsql {PRAGMA soft_heap_limit} 5455e85ca5Sdrh} {5000} 5555e85ca5Sdrhdo_test softheap1-2.1 { 569a47736eSdrh execsql { 579a47736eSdrh PRAGMA auto_vacuum=1; 589a47736eSdrh CREATE TABLE t1(x); 593aefabafSdrh INSERT INTO t1 VALUES(hex(randomblob(1000))); 609a47736eSdrh BEGIN; 613aefabafSdrh } 623aefabafSdrh execsql { 639a47736eSdrh CREATE TABLE t2 AS SELECT * FROM t1; 643aefabafSdrh } 653aefabafSdrh execsql { 669a47736eSdrh ROLLBACK; 673aefabafSdrh } 683aefabafSdrh execsql { 699a47736eSdrh PRAGMA integrity_check; 709a47736eSdrh } 719a47736eSdrh} {ok} 721bc71590Sdanielk1977 73c1a60c51Sdansqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit) 749a47736eSdrhfinish_test 75