000001 # 2007 Aug 10
000002 #
000003 # The author disclaims copyright to this source code. In place of
000004 # a legal notice, here is a blessing:
000005 #
000006 # May you do good and not evil.
000007 # May you find forgiveness for yourself and forgive others.
000008 # May you share freely, never taking more than you give.
000009 #
000010 #***********************************************************************
000011 #
000012 # This test script reproduces the problem reported by ticket #2565,
000013 # A database corruption bug that occurs in auto_vacuum mode when
000014 # the soft_heap_limit is set low enough to be triggered.
000015 #
000016 # $Id: softheap1.test,v 1.5 2008/07/08 17:13:59 danielk1977 Exp $
000017
000018
000019 set testdir [file dirname $argv0]
000020 source $testdir/tester.tcl
000021
000022 ifcapable !integrityck {
000023 finish_test
000024 return
000025 }
000026
000027 # EVIDENCE-OF: R-26343-45930 This pragma invokes the
000028 # sqlite3_soft_heap_limit64() interface with the argument N, if N is
000029 # specified and is a non-negative integer.
000030 #
000031 # EVIDENCE-OF: R-64451-07163 The soft_heap_limit pragma always returns
000032 # the same integer that would be returned by the
000033 # sqlite3_soft_heap_limit64(-1) C-language function.
000034 #
000035 do_test softheap1-1.0 {
000036 execsql {PRAGMA soft_heap_limit}
000037 } [sqlite3_soft_heap_limit -1]
000038 do_test softheap1-1.1 {
000039 execsql {PRAGMA soft_heap_limit=123456; PRAGMA soft_heap_limit;}
000040 } {123456 123456}
000041 do_test softheap1-1.2 {
000042 sqlite3_soft_heap_limit -1
000043 } {123456}
000044 do_test softheap1-1.3 {
000045 execsql {PRAGMA soft_heap_limit(-1); PRAGMA soft_heap_limit;}
000046 } {123456 123456}
000047 do_test softheap1-1.4 {
000048 execsql {PRAGMA soft_heap_limit(0); PRAGMA soft_heap_limit;}
000049 } {0 0}
000050
000051 sqlite3_soft_heap_limit 5000
000052 do_test softheap1-2.0 {
000053 execsql {PRAGMA soft_heap_limit}
000054 } {5000}
000055 do_test softheap1-2.1 {
000056 execsql {
000057 PRAGMA auto_vacuum=1;
000058 CREATE TABLE t1(x);
000059 INSERT INTO t1 VALUES(hex(randomblob(1000)));
000060 BEGIN;
000061 }
000062 execsql {
000063 CREATE TABLE t2 AS SELECT * FROM t1;
000064 }
000065 execsql {
000066 ROLLBACK;
000067 }
000068 execsql {
000069 PRAGMA integrity_check;
000070 }
000071 } {ok}
000072
000073 sqlite3_soft_heap_limit $cmdlinearg(soft-heap-limit)
000074 finish_test