Annotation of embedaddon/sqlite3/test/ioerr4.test, revision 1.1

1.1     ! misho       1: # 2007 December 19
        !             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 I/O errors
        !            13: # during incremental vacuum with a shared cache.
        !            14: #
        !            15: # $Id: ioerr4.test,v 1.2 2008/05/08 01:11:42 drh Exp $
        !            16: 
        !            17: set testdir [file dirname $argv0]
        !            18: source $testdir/tester.tcl
        !            19: 
        !            20: # This test requires both shared cache and incremental vacuum.
        !            21: #
        !            22: ifcapable {!shared_cache || !autovacuum} {
        !            23:   finish_test
        !            24:   return
        !            25: }
        !            26: 
        !            27: # Enable shared cache mode and incremental vacuum.
        !            28: #
        !            29: do_test ioerr4-1.1 {
        !            30:   db close
        !            31:   set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
        !            32: } {0}
        !            33: do_test ioerr4-1.2 {
        !            34:   forcedelete test.db test.db-journal
        !            35:   sqlite3 db test.db
        !            36:   sqlite3 db2 test.db
        !            37:   db eval {
        !            38:     PRAGMA auto_vacuum=INCREMENTAL;
        !            39:     CREATE TABLE a(i INTEGER, b BLOB);
        !            40:   }
        !            41:   db2 eval {
        !            42:     SELECT name FROM sqlite_master
        !            43:   }
        !            44: } {a}
        !            45: do_test ioerr4-1.3 {
        !            46:   db eval {
        !            47:     PRAGMA auto_vacuum;
        !            48:   }
        !            49: } {2}
        !            50: 
        !            51: # Insert and delete many records in order to put lots of pages
        !            52: # on the freelist.
        !            53: #
        !            54: do_test ioerr4-1.4 {
        !            55:   db eval {
        !            56:     INSERT INTO a VALUES(1, zeroblob(2000));
        !            57:     INSERT INTO a VALUES(2, zeroblob(2000));
        !            58:     INSERT INTO a SELECT i+2, zeroblob(2000) FROM a;
        !            59:     INSERT INTO a SELECT i+4, zeroblob(2000) FROM a;
        !            60:     INSERT INTO a SELECT i+8, zeroblob(2000) FROM a;
        !            61:     INSERT INTO a SELECT i+16, zeroblob(2000) FROM a;
        !            62:     SELECT count(*) FROM a;
        !            63:   }
        !            64: } {32}
        !            65: do_test ioerr4-1.5 {
        !            66:   db eval {
        !            67:     PRAGMA freelist_count
        !            68:   }
        !            69: } {0}
        !            70: do_test ioerr4-1.6 {
        !            71:   db eval {
        !            72:     DELETE FROM a;
        !            73:     PRAGMA freelist_count;
        !            74:   }
        !            75: } {64}
        !            76: 
        !            77: # Set up for an I/O error on incremental vacuum
        !            78: # with two connections on shared cache.
        !            79: #
        !            80: db close
        !            81: db2 close
        !            82: forcecopy test.db test.db-bu
        !            83: do_ioerr_test ioerr4-2 -tclprep {
        !            84:   catch {db2 close}
        !            85:   db close
        !            86:   forcedelete test.db test.db-journal
        !            87:   forcecopy test.db-bu test.db
        !            88:   sqlite3_enable_shared_cache 1
        !            89:   set ::DB [sqlite3 db test.db; sqlite3_connection_pointer db]
        !            90:   db eval {PRAGMA auto_vacuum=INCREMENTAL}
        !            91:   sqlite3 db2 test.db
        !            92: } -tclbody {
        !            93:   db eval {PRAGMA incremental_vacuum(5)}
        !            94: }
        !            95: 
        !            96: db2 close
        !            97: forcedelete test.db-bu
        !            98: sqlite3_enable_shared_cache $::enable_shared_cache
        !            99: 
        !           100: finish_test

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