sl@0: # 2002 March 6 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file implements regression tests for SQLite library. sl@0: # sl@0: # This file implements tests for the PRAGMA command. sl@0: # sl@0: # $Id: pragma2.test,v 1.4 2007/10/09 08:29:33 danielk1977 Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: # Test organization: sl@0: # sl@0: # pragma2-1.*: Test freelist_count pragma on the main database. sl@0: # pragma2-2.*: Test freelist_count pragma on an attached database. sl@0: # pragma2-3.*: Test trying to write to the freelist_count is a no-op. sl@0: # sl@0: sl@0: ifcapable !pragma||!schema_pragmas { sl@0: finish_test sl@0: return sl@0: } sl@0: sl@0: # Delete the preexisting database to avoid the special setup sl@0: # that the "all.test" script does. sl@0: # sl@0: db close sl@0: file delete test.db test.db-journal sl@0: file delete test3.db test3.db-journal sl@0: sqlite3 db test.db; set DB [sqlite3_connection_pointer db] sl@0: db eval {PRAGMA auto_vacuum=0} sl@0: sl@0: do_test pragma2-1.1 { sl@0: execsql { sl@0: PRAGMA freelist_count; sl@0: } sl@0: } {0} sl@0: do_test pragma2-1.2 { sl@0: execsql { sl@0: CREATE TABLE abc(a, b, c); sl@0: PRAGMA freelist_count; sl@0: } sl@0: } {0} sl@0: do_test pragma2-1.3 { sl@0: execsql { sl@0: DROP TABLE abc; sl@0: PRAGMA freelist_count; sl@0: } sl@0: } {1} sl@0: do_test pragma2-1.4 { sl@0: execsql { sl@0: PRAGMA main.freelist_count; sl@0: } sl@0: } {1} sl@0: sl@0: file delete -force test2.db sl@0: file delete -force test2.db-journal sl@0: sl@0: ifcapable attach { sl@0: do_test pragma2-2.1 { sl@0: execsql { sl@0: ATTACH 'test2.db' AS aux; sl@0: PRAGMA aux.auto_vacuum=OFF; sl@0: PRAGMA aux.freelist_count; sl@0: } sl@0: } {0} sl@0: do_test pragma2-2.2 { sl@0: execsql { sl@0: CREATE TABLE aux.abc(a, b, c); sl@0: PRAGMA aux.freelist_count; sl@0: } sl@0: } {0} sl@0: do_test pragma2-2.3 { sl@0: set ::val [string repeat 0123456789 1000] sl@0: execsql { sl@0: INSERT INTO aux.abc VALUES(1, 2, $::val); sl@0: PRAGMA aux.freelist_count; sl@0: } sl@0: } {0} sl@0: do_test pragma2-2.4 { sl@0: expr {[file size test2.db] / 1024} sl@0: } {11} sl@0: do_test pragma2-2.5 { sl@0: execsql { sl@0: DELETE FROM aux.abc; sl@0: PRAGMA aux.freelist_count; sl@0: } sl@0: } {9} sl@0: sl@0: do_test pragma2-3.1 { sl@0: execsql { sl@0: PRAGMA aux.freelist_count; sl@0: PRAGMA main.freelist_count; sl@0: PRAGMA freelist_count; sl@0: } sl@0: } {9 1 1} sl@0: do_test pragma2-3.2 { sl@0: execsql { sl@0: PRAGMA freelist_count = 500; sl@0: PRAGMA freelist_count; sl@0: } sl@0: } {1 1} sl@0: do_test pragma2-3.3 { sl@0: execsql { sl@0: PRAGMA aux.freelist_count = 500; sl@0: PRAGMA aux.freelist_count; sl@0: } sl@0: } {9 9} sl@0: } sl@0: sl@0: finish_test