Annotation of embedaddon/sqlite3/test/diskfull.test, revision 1.1.1.1

1.1       misho       1: # 2001 October 12
                      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.  The
                     12: # focus of this file is testing for correct handling of disk full
                     13: # errors.
                     14: # 
                     15: # $Id: diskfull.test,v 1.8 2008/07/12 14:52:20 drh Exp $
                     16: 
                     17: set testdir [file dirname $argv0]
                     18: source $testdir/tester.tcl
                     19: 
                     20: set sqlite_io_error_persist 0
                     21: set sqlite_io_error_hit 0
                     22: set sqlite_io_error_pending 0
                     23: do_test diskfull-1.1 {
                     24:   execsql {
                     25:     CREATE TABLE t1(x);
                     26:     INSERT INTO t1 VALUES(randstr(1000,1000));
                     27:     INSERT INTO t1 SELECT * FROM t1;
                     28:     INSERT INTO t1 SELECT * FROM t1;
                     29:     INSERT INTO t1 SELECT * FROM t1;
                     30:     INSERT INTO t1 SELECT * FROM t1;
                     31:     CREATE INDEX t1i1 ON t1(x);
                     32:     CREATE TABLE t2 AS SELECT x AS a, x AS b FROM t1;
                     33:     CREATE INDEX t2i1 ON t2(b);
                     34:   }
                     35: } {}
                     36: set sqlite_diskfull_pending 0
                     37: integrity_check diskfull-1.2
                     38: do_test diskfull-1.3 {
                     39:   set sqlite_diskfull_pending 1
                     40:   catchsql {
                     41:     INSERT INTO t1 SELECT * FROM t1;
                     42:   }
                     43: } {1 {database or disk is full}}
                     44: set sqlite_diskfull_pending 0
                     45: integrity_check diskfull-1.4
                     46: do_test diskfull-1.5 {
                     47:   set sqlite_diskfull_pending 1
                     48:   catchsql {
                     49:     DELETE FROM t1;
                     50:   }
                     51: } {1 {database or disk is full}}
                     52: set sqlite_diskfull_pending 0
                     53: set sqlite_io_error_hit 0
                     54: integrity_check diskfull-1.6
                     55: 
                     56: proc do_diskfull_test {prefix sql} {
                     57:   set ::go 1
                     58:   set ::sql $sql
                     59:   set ::i 1
                     60:   while {$::go} {
                     61:     incr ::i
                     62:     do_test ${prefix}.$::i.1 {
                     63:       set ::sqlite_diskfull_pending $::i
                     64:       set ::sqlite_diskfull 0
                     65:       set r [catchsql $::sql]
                     66:       if {!$::sqlite_diskfull} {
                     67:         set r {1 {database or disk is full}}
                     68:         set ::go 0
                     69:       }
                     70:       if {$r=="1 {disk I/O error}"} {
                     71:         set r {1 {database or disk is full}}
                     72:       }
                     73:       set r
                     74:     } {1 {database or disk is full}}
                     75:     set ::sqlite_diskfull_pending 0
                     76:     db close
                     77:     sqlite3 db test.db
                     78:     integrity_check ${prefix}.$::i.2
                     79:   }
                     80: }
                     81: 
                     82: do_diskfull_test diskfull-2 VACUUM
                     83: 
                     84: # db close
                     85: # forcedelete test.db
                     86: # forcedelete test.db-journal
                     87: # sqlite3 db test.db
                     88: # 
                     89: # do_test diskfull-3.1 {
                     90: #   execsql {
                     91: #     PRAGMA default_cache_size = 10;
                     92: #     CREATE TABLE t3(a, b, UNIQUE(a, b));
                     93: #     INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
                     94: #     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
                     95: #     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
                     96: #     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
                     97: #     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
                     98: #     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
                     99: #     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
                    100: #     INSERT INTO t3 SELECT randstr(100, 100), randstr(100, 100) FROM t3;
                    101: #     UPDATE t3 
                    102: #     SET b = (SELECT a FROM t3 WHERE rowid = (SELECT max(rowid)-1 FROM t3))
                    103: #     WHERE rowid = (SELECT max(rowid) FROM t3);
                    104: #     PRAGMA cache_size;
                    105: #   }
                    106: # } {10}
                    107: # 
                    108: # do_diskfull_test diskfull-3.2 {
                    109: #   BEGIN;
                    110: #     INSERT INTO t3 VALUES( randstr(100, 100), randstr(100, 100) );
                    111: #     UPDATE t3 SET a = b;
                    112: #   COMMIT;
                    113: # }
                    114: 
                    115: finish_test

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>