os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt1667.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# 2006 February 10
sl@0
     2
#
sl@0
     3
# The author disclaims copyright to this source code.  In place of
sl@0
     4
# a legal notice, here is a blessing:
sl@0
     5
#
sl@0
     6
#    May you do good and not evil.
sl@0
     7
#    May you find forgiveness for yourself and forgive others.
sl@0
     8
#    May you share freely, never taking more than you give.
sl@0
     9
#
sl@0
    10
#***********************************************************************
sl@0
    11
# This file implements regression tests for SQLite library.
sl@0
    12
#
sl@0
    13
# This file implements tests to verify that ticket #1667 has been
sl@0
    14
# fixed.  
sl@0
    15
#
sl@0
    16
#
sl@0
    17
# $Id: tkt1667.test,v 1.3 2008/07/12 14:52:20 drh Exp $
sl@0
    18
sl@0
    19
set testdir [file dirname $argv0]
sl@0
    20
source $testdir/tester.tcl
sl@0
    21
sl@0
    22
ifcapable !autovacuum||!tclvar {
sl@0
    23
  finish_test
sl@0
    24
  return
sl@0
    25
}
sl@0
    26
sl@0
    27
db close
sl@0
    28
file delete -force test.db test.db-journal
sl@0
    29
sl@0
    30
# Set the pending byte offset such that the page it is on is
sl@0
    31
# the first autovacuum pointer map page in the file (assume a page 
sl@0
    32
# size of 1024).
sl@0
    33
sl@0
    34
set first_ptrmap_page   [expr 1024/5 + 3]
sl@0
    35
set sqlite_pending_byte [expr 1024 * ($first_ptrmap_page-1)]
sl@0
    36
sl@0
    37
sqlite db test.db
sl@0
    38
sl@0
    39
do_test tkt1667-1 {
sl@0
    40
  execsql {
sl@0
    41
    PRAGMA auto_vacuum = 1;
sl@0
    42
    BEGIN;
sl@0
    43
    CREATE TABLE t1(a, b);
sl@0
    44
  }
sl@0
    45
  for {set i 0} {$i < 500} {incr i} {
sl@0
    46
    execsql {
sl@0
    47
      INSERT INTO t1 VALUES($i, randstr(1000, 2000))
sl@0
    48
    }
sl@0
    49
  }
sl@0
    50
  execsql {
sl@0
    51
    COMMIT;
sl@0
    52
  }
sl@0
    53
} {}
sl@0
    54
for {set i 0} {$i < 500} {incr i} {
sl@0
    55
  do_test tkt1667-2.$i.1 {
sl@0
    56
    execsql {
sl@0
    57
      DELETE FROM t1 WHERE a = $i;
sl@0
    58
    }
sl@0
    59
  } {}
sl@0
    60
  integrity_check tkt1667-2.$i.2
sl@0
    61
}
sl@0
    62
sl@0
    63
do_test tkt1667-3 {
sl@0
    64
  execsql {
sl@0
    65
    BEGIN;
sl@0
    66
  }
sl@0
    67
  for {set i 0} {$i < 500} {incr i} {
sl@0
    68
    execsql {
sl@0
    69
      INSERT INTO t1 VALUES($i, randstr(1000, 2000))
sl@0
    70
    }
sl@0
    71
  }
sl@0
    72
  execsql {
sl@0
    73
    COMMIT;
sl@0
    74
  }
sl@0
    75
} {}
sl@0
    76
do_test tkt1667-4.1 {
sl@0
    77
  execsql {
sl@0
    78
    DELETE FROM t1;
sl@0
    79
  }
sl@0
    80
} {}
sl@0
    81
integrity_check tkt1667-4.2
sl@0
    82
sl@0
    83
finish_test