os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt2920.test
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200 (2012-06-15)
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
# 2008 Feb 1
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
#
sl@0
    12
# This file is to test that ticket #2920 is fixed.
sl@0
    13
#
sl@0
    14
# $Id: tkt2920.test,v 1.1 2008/02/02 02:48:52 drh Exp $
sl@0
    15
#
sl@0
    16
sl@0
    17
set testdir [file dirname $argv0]
sl@0
    18
source $testdir/tester.tcl
sl@0
    19
sl@0
    20
# Create a database file that is full.
sl@0
    21
#
sl@0
    22
do_test tkt2920-1.1 {
sl@0
    23
  db eval {
sl@0
    24
    PRAGMA page_size=1024;
sl@0
    25
    PRAGMA max_page_count=40;
sl@0
    26
    PRAGMA auto_vacuum=0;
sl@0
    27
    CREATE TABLE filler (fill);
sl@0
    28
  }
sl@0
    29
  file size test.db
sl@0
    30
} {2048}
sl@0
    31
do_test tkt2920-1.2 {
sl@0
    32
  db eval BEGIN
sl@0
    33
  for {set i 0} {$i<34} {incr i} {
sl@0
    34
    db eval {INSERT INTO filler VALUES(randomblob(1024))}
sl@0
    35
  }
sl@0
    36
  db eval COMMIT
sl@0
    37
}  {}
sl@0
    38
sl@0
    39
# Try to add a single new page to the full database.  We get
sl@0
    40
# a disk full error.  But this does not corrupt the database.
sl@0
    41
#
sl@0
    42
do_test tkt2920-1.3 {
sl@0
    43
  db eval BEGIN
sl@0
    44
  catchsql {
sl@0
    45
     INSERT INTO filler VALUES(randomblob(1024))
sl@0
    46
  }
sl@0
    47
} {1 {database or disk is full}}
sl@0
    48
integrity_check tkt2920-1.4
sl@0
    49
sl@0
    50
# Increase the maximum size of the database file by 1 page,
sl@0
    51
# but then try to add a two-page record.  This also fails.
sl@0
    52
#
sl@0
    53
do_test tkt2920-1.5 {
sl@0
    54
  db eval {PRAGMA max_page_count=41}
sl@0
    55
  catchsql {
sl@0
    56
     INSERT INTO filler VALUES(randomblob(2048))
sl@0
    57
  }
sl@0
    58
} {1 {database or disk is full}}
sl@0
    59
integrity_check tkt2920-1.6
sl@0
    60
sl@0
    61
# Increase the maximum size of the database by one more page.
sl@0
    62
# This time the insert works.
sl@0
    63
#
sl@0
    64
do_test tkt2920-1.7 {
sl@0
    65
  db eval {PRAGMA max_page_count=42}
sl@0
    66
  catchsql {
sl@0
    67
     INSERT INTO filler VALUES(randomblob(2048))
sl@0
    68
  }
sl@0
    69
} {0 {}}
sl@0
    70
integrity_check tkt2920-1.8
sl@0
    71
sl@0
    72
# The previous errors cancelled the transaction.
sl@0
    73
#
sl@0
    74
do_test tkt2920-1.9 {
sl@0
    75
  catchsql {COMMIT}
sl@0
    76
} {1 {cannot commit - no transaction is active}}
sl@0
    77
sl@0
    78
finish_test