os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/autovacuum_ioerr2.test
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/autovacuum_ioerr2.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,132 @@
1.4 +# 2001 October 12
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 +# This file implements regression tests for SQLite library. The
1.15 +# focus of this file is testing for correct handling of I/O errors
1.16 +# such as writes failing because the disk is full.
1.17 +#
1.18 +# The tests in this file use special facilities that are only
1.19 +# available in the SQLite test fixture.
1.20 +#
1.21 +# $Id: autovacuum_ioerr2.test,v 1.7 2008/07/12 14:52:20 drh Exp $
1.22 +
1.23 +set testdir [file dirname $argv0]
1.24 +source $testdir/tester.tcl
1.25 +
1.26 +# If this build of the library does not support auto-vacuum, omit this
1.27 +# whole file.
1.28 +ifcapable {!autovacuum} {
1.29 + finish_test
1.30 + return
1.31 +}
1.32 +
1.33 +do_ioerr_test autovacuum-ioerr2-1 -sqlprep {
1.34 + PRAGMA auto_vacuum = 1;
1.35 + CREATE TABLE abc(a);
1.36 + INSERT INTO abc VALUES(randstr(1500,1500));
1.37 +} -sqlbody {
1.38 + CREATE TABLE abc2(a);
1.39 + BEGIN;
1.40 + DELETE FROM abc;
1.41 + INSERT INTO abc VALUES(randstr(1500,1500));
1.42 + CREATE TABLE abc3(a);
1.43 + COMMIT;
1.44 +}
1.45 +
1.46 +do_ioerr_test autovacuum-ioerr2-2 -tclprep {
1.47 + execsql {
1.48 + PRAGMA auto_vacuum = 1;
1.49 + PRAGMA cache_size = 10;
1.50 + BEGIN;
1.51 + CREATE TABLE abc(a);
1.52 + INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 4 is overflow
1.53 + INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 5 is overflow
1.54 + }
1.55 + for {set i 0} {$i<150} {incr i} {
1.56 + execsql {
1.57 + INSERT INTO abc VALUES(randstr(100,100));
1.58 + }
1.59 + }
1.60 + execsql COMMIT
1.61 +} -sqlbody {
1.62 + BEGIN;
1.63 + DELETE FROM abc WHERE length(a)>100;
1.64 + UPDATE abc SET a = randstr(90,90);
1.65 + CREATE TABLE abc3(a);
1.66 + COMMIT;
1.67 +}
1.68 +
1.69 +do_ioerr_test autovacuum-ioerr2-3 -sqlprep {
1.70 + PRAGMA auto_vacuum = 1;
1.71 + CREATE TABLE abc(a);
1.72 + CREATE TABLE abc2(b);
1.73 +} -sqlbody {
1.74 + BEGIN;
1.75 + INSERT INTO abc2 VALUES(10);
1.76 + DROP TABLE abc;
1.77 + COMMIT;
1.78 + DROP TABLE abc2;
1.79 +}
1.80 +
1.81 +file delete -force backup.db
1.82 +ifcapable subquery {
1.83 + do_ioerr_test autovacuum-ioerr2-4 -tclprep {
1.84 + if {![file exists backup.db]} {
1.85 + sqlite3 dbb backup.db
1.86 + execsql {
1.87 + PRAGMA auto_vacuum = 1;
1.88 + BEGIN;
1.89 + CREATE TABLE abc(a);
1.90 + INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 4 is overflow
1.91 + INSERT INTO abc VALUES(randstr(1100,1100)); -- Page 5 is overflow
1.92 + } dbb
1.93 + for {set i 0} {$i<2500} {incr i} {
1.94 + execsql {
1.95 + INSERT INTO abc VALUES(randstr(100,100));
1.96 + } dbb
1.97 + }
1.98 + execsql {
1.99 + COMMIT;
1.100 + PRAGMA cache_size = 10;
1.101 + } dbb
1.102 + dbb close
1.103 + }
1.104 + db close
1.105 + file delete -force test.db
1.106 + file delete -force test.db-journal
1.107 + copy_file backup.db test.db
1.108 + set ::DB [sqlite3 db test.db]
1.109 + execsql {
1.110 + PRAGMA cache_size = 10;
1.111 + }
1.112 + } -sqlbody {
1.113 + BEGIN;
1.114 + DELETE FROM abc WHERE oid < 3;
1.115 + UPDATE abc SET a = randstr(100,100) WHERE oid > 2300;
1.116 + UPDATE abc SET a = randstr(1100,1100) WHERE oid =
1.117 + (select max(oid) from abc);
1.118 + COMMIT;
1.119 + }
1.120 +}
1.121 +
1.122 +do_ioerr_test autovacuum-ioerr2-1 -sqlprep {
1.123 + PRAGMA auto_vacuum = 1;
1.124 + CREATE TABLE abc(a);
1.125 + INSERT INTO abc VALUES(randstr(1500,1500));
1.126 +} -sqlbody {
1.127 + CREATE TABLE abc2(a);
1.128 + BEGIN;
1.129 + DELETE FROM abc;
1.130 + INSERT INTO abc VALUES(randstr(1500,1500));
1.131 + CREATE TABLE abc3(a);
1.132 + COMMIT;
1.133 +}
1.134 +
1.135 +finish_test