os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt2920.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/tkt2920.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,78 @@
     1.4 +# 2008 Feb 1
     1.5 +#
     1.6 +# The author disclaims copyright to this source code. In place of
     1.7 +# a legal notice, here is a blessing:
     1.8 +#
     1.9 +#    May you do good and not evil.
    1.10 +#    May you find forgiveness for yourself and forgive others.
    1.11 +#    May you share freely, never taking more than you give.
    1.12 +#
    1.13 +#***********************************************************************
    1.14 +#
    1.15 +# This file is to test that ticket #2920 is fixed.
    1.16 +#
    1.17 +# $Id: tkt2920.test,v 1.1 2008/02/02 02:48:52 drh Exp $
    1.18 +#
    1.19 +
    1.20 +set testdir [file dirname $argv0]
    1.21 +source $testdir/tester.tcl
    1.22 +
    1.23 +# Create a database file that is full.
    1.24 +#
    1.25 +do_test tkt2920-1.1 {
    1.26 +  db eval {
    1.27 +    PRAGMA page_size=1024;
    1.28 +    PRAGMA max_page_count=40;
    1.29 +    PRAGMA auto_vacuum=0;
    1.30 +    CREATE TABLE filler (fill);
    1.31 +  }
    1.32 +  file size test.db
    1.33 +} {2048}
    1.34 +do_test tkt2920-1.2 {
    1.35 +  db eval BEGIN
    1.36 +  for {set i 0} {$i<34} {incr i} {
    1.37 +    db eval {INSERT INTO filler VALUES(randomblob(1024))}
    1.38 +  }
    1.39 +  db eval COMMIT
    1.40 +}  {}
    1.41 +
    1.42 +# Try to add a single new page to the full database.  We get
    1.43 +# a disk full error.  But this does not corrupt the database.
    1.44 +#
    1.45 +do_test tkt2920-1.3 {
    1.46 +  db eval BEGIN
    1.47 +  catchsql {
    1.48 +     INSERT INTO filler VALUES(randomblob(1024))
    1.49 +  }
    1.50 +} {1 {database or disk is full}}
    1.51 +integrity_check tkt2920-1.4
    1.52 +
    1.53 +# Increase the maximum size of the database file by 1 page,
    1.54 +# but then try to add a two-page record.  This also fails.
    1.55 +#
    1.56 +do_test tkt2920-1.5 {
    1.57 +  db eval {PRAGMA max_page_count=41}
    1.58 +  catchsql {
    1.59 +     INSERT INTO filler VALUES(randomblob(2048))
    1.60 +  }
    1.61 +} {1 {database or disk is full}}
    1.62 +integrity_check tkt2920-1.6
    1.63 +
    1.64 +# Increase the maximum size of the database by one more page.
    1.65 +# This time the insert works.
    1.66 +#
    1.67 +do_test tkt2920-1.7 {
    1.68 +  db eval {PRAGMA max_page_count=42}
    1.69 +  catchsql {
    1.70 +     INSERT INTO filler VALUES(randomblob(2048))
    1.71 +  }
    1.72 +} {0 {}}
    1.73 +integrity_check tkt2920-1.8
    1.74 +
    1.75 +# The previous errors cancelled the transaction.
    1.76 +#
    1.77 +do_test tkt2920-1.9 {
    1.78 +  catchsql {COMMIT}
    1.79 +} {1 {cannot commit - no transaction is active}}
    1.80 +
    1.81 +finish_test