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

1.1     ! misho       1: # 2002 March 6
        !             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.
        !            12: #
        !            13: # This file implements tests for the PRAGMA command.
        !            14: #
        !            15: # $Id: pragma2.test,v 1.4 2007/10/09 08:29:33 danielk1977 Exp $
        !            16: 
        !            17: set testdir [file dirname $argv0]
        !            18: source $testdir/tester.tcl
        !            19: 
        !            20: # Test organization:
        !            21: #
        !            22: # pragma2-1.*: Test freelist_count pragma on the main database.
        !            23: # pragma2-2.*: Test freelist_count pragma on an attached database.
        !            24: # pragma2-3.*: Test trying to write to the freelist_count is a no-op.
        !            25: #
        !            26: 
        !            27: ifcapable !pragma||!schema_pragmas {
        !            28:   finish_test
        !            29:   return
        !            30: }
        !            31: 
        !            32: # Delete the preexisting database to avoid the special setup
        !            33: # that the "all.test" script does.
        !            34: #
        !            35: db close
        !            36: delete_file test.db test.db-journal
        !            37: delete_file test3.db test3.db-journal
        !            38: sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
        !            39: db eval {PRAGMA auto_vacuum=0}
        !            40: 
        !            41: do_test pragma2-1.1 {
        !            42:   execsql {
        !            43:     PRAGMA freelist_count;
        !            44:   }
        !            45: } {0}
        !            46: do_test pragma2-1.2 {
        !            47:   execsql {
        !            48:     CREATE TABLE abc(a, b, c);
        !            49:     PRAGMA freelist_count;
        !            50:   }
        !            51: } {0}
        !            52: do_test pragma2-1.3 {
        !            53:   execsql {
        !            54:     DROP TABLE abc;
        !            55:     PRAGMA freelist_count;
        !            56:   }
        !            57: } {1}
        !            58: do_test pragma2-1.4 {
        !            59:   execsql {
        !            60:     PRAGMA main.freelist_count;
        !            61:   }
        !            62: } {1}
        !            63: 
        !            64: forcedelete test2.db
        !            65: forcedelete test2.db-journal
        !            66: 
        !            67: ifcapable attach {
        !            68:   do_test pragma2-2.1 {
        !            69:     execsql {
        !            70:       ATTACH 'test2.db' AS aux;
        !            71:       PRAGMA aux.auto_vacuum=OFF;
        !            72:       PRAGMA aux.freelist_count;
        !            73:     }
        !            74:   } {0}
        !            75:   do_test pragma2-2.2 {
        !            76:     execsql {
        !            77:       CREATE TABLE aux.abc(a, b, c);
        !            78:       PRAGMA aux.freelist_count;
        !            79:     }
        !            80:   } {0}
        !            81:   do_test pragma2-2.3 {
        !            82:     set ::val [string repeat 0123456789 1000]
        !            83:     execsql {
        !            84:       INSERT INTO aux.abc VALUES(1, 2, $::val);
        !            85:       PRAGMA aux.freelist_count;
        !            86:     }
        !            87:   } {0}
        !            88:   do_test pragma2-2.4 {
        !            89:     expr {[file size test2.db] / 1024}
        !            90:   } {11}
        !            91:   do_test pragma2-2.5 {
        !            92:     execsql {
        !            93:       DELETE FROM aux.abc;
        !            94:       PRAGMA aux.freelist_count;
        !            95:     }
        !            96:   } {9}
        !            97:   
        !            98:   do_test pragma2-3.1 {
        !            99:     execsql {
        !           100:       PRAGMA aux.freelist_count;
        !           101:       PRAGMA main.freelist_count;
        !           102:       PRAGMA freelist_count;
        !           103:     }
        !           104:   } {9 1 1}
        !           105:   do_test pragma2-3.2 {
        !           106:     execsql {
        !           107:       PRAGMA freelist_count = 500;
        !           108:       PRAGMA freelist_count;
        !           109:     }
        !           110:   } {1 1}
        !           111:   do_test pragma2-3.3 {
        !           112:     execsql {
        !           113:       PRAGMA aux.freelist_count = 500;
        !           114:       PRAGMA aux.freelist_count;
        !           115:     }
        !           116:   } {9 9}
        !           117: }
        !           118: 
        !           119: finish_test

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