xref: /sqlite-3.40.0/test/tkt1667.test (revision fda06bef)
1# 2006 February 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# This file implements regression tests for SQLite library.
12#
13# This file implements tests to verify that ticket #1667 has been
14# fixed.
15#
16#
17# $Id: tkt1667.test,v 1.4 2009/02/05 17:00:54 drh Exp $
18
19set testdir [file dirname $argv0]
20source $testdir/tester.tcl
21
22ifcapable !autovacuum||!tclvar {
23  finish_test
24  return
25}
26
27db close
28forcedelete test.db test.db-journal
29
30# Set the pending byte offset such that the page it is on is
31# the first autovacuum pointer map page in the file (assume a page
32# size of 1024).
33
34set first_ptrmap_page   [expr 1024/5 + 3]
35sqlite3_test_control_pending_byte [expr 1024 * ($first_ptrmap_page-1)]
36
37sqlite3 db test.db
38
39do_test tkt1667-1 {
40  execsql {
41    PRAGMA auto_vacuum = 1;
42    BEGIN;
43    CREATE TABLE t1(a, b);
44  }
45  for {set i 0} {$i < 500} {incr i} {
46    execsql {
47      INSERT INTO t1 VALUES($i, randstr(1000, 2000))
48    }
49  }
50  execsql {
51    COMMIT;
52  }
53} {}
54for {set i 0} {$i < 500} {incr i} {
55  do_test tkt1667-2.$i.1 {
56    execsql {
57      DELETE FROM t1 WHERE a = $i;
58    }
59  } {}
60  integrity_check tkt1667-2.$i.2
61}
62
63do_test tkt1667-3 {
64  execsql {
65    BEGIN;
66  }
67  for {set i 0} {$i < 500} {incr i} {
68    execsql {
69      INSERT INTO t1 VALUES($i, randstr(1000, 2000))
70    }
71  }
72  execsql {
73    COMMIT;
74  }
75} {}
76do_test tkt1667-4.1 {
77  execsql {
78    DELETE FROM t1;
79  }
80} {}
81integrity_check tkt1667-4.2
82
83finish_test
84