1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/pragma2.test Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,119 @@
1.4 +# 2002 March 6
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.
1.15 +#
1.16 +# This file implements tests for the PRAGMA command.
1.17 +#
1.18 +# $Id: pragma2.test,v 1.4 2007/10/09 08:29:33 danielk1977 Exp $
1.19 +
1.20 +set testdir [file dirname $argv0]
1.21 +source $testdir/tester.tcl
1.22 +
1.23 +# Test organization:
1.24 +#
1.25 +# pragma2-1.*: Test freelist_count pragma on the main database.
1.26 +# pragma2-2.*: Test freelist_count pragma on an attached database.
1.27 +# pragma2-3.*: Test trying to write to the freelist_count is a no-op.
1.28 +#
1.29 +
1.30 +ifcapable !pragma||!schema_pragmas {
1.31 + finish_test
1.32 + return
1.33 +}
1.34 +
1.35 +# Delete the preexisting database to avoid the special setup
1.36 +# that the "all.test" script does.
1.37 +#
1.38 +db close
1.39 +file delete test.db test.db-journal
1.40 +file delete test3.db test3.db-journal
1.41 +sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
1.42 +db eval {PRAGMA auto_vacuum=0}
1.43 +
1.44 +do_test pragma2-1.1 {
1.45 + execsql {
1.46 + PRAGMA freelist_count;
1.47 + }
1.48 +} {0}
1.49 +do_test pragma2-1.2 {
1.50 + execsql {
1.51 + CREATE TABLE abc(a, b, c);
1.52 + PRAGMA freelist_count;
1.53 + }
1.54 +} {0}
1.55 +do_test pragma2-1.3 {
1.56 + execsql {
1.57 + DROP TABLE abc;
1.58 + PRAGMA freelist_count;
1.59 + }
1.60 +} {1}
1.61 +do_test pragma2-1.4 {
1.62 + execsql {
1.63 + PRAGMA main.freelist_count;
1.64 + }
1.65 +} {1}
1.66 +
1.67 +file delete -force test2.db
1.68 +file delete -force test2.db-journal
1.69 +
1.70 +ifcapable attach {
1.71 + do_test pragma2-2.1 {
1.72 + execsql {
1.73 + ATTACH 'test2.db' AS aux;
1.74 + PRAGMA aux.auto_vacuum=OFF;
1.75 + PRAGMA aux.freelist_count;
1.76 + }
1.77 + } {0}
1.78 + do_test pragma2-2.2 {
1.79 + execsql {
1.80 + CREATE TABLE aux.abc(a, b, c);
1.81 + PRAGMA aux.freelist_count;
1.82 + }
1.83 + } {0}
1.84 + do_test pragma2-2.3 {
1.85 + set ::val [string repeat 0123456789 1000]
1.86 + execsql {
1.87 + INSERT INTO aux.abc VALUES(1, 2, $::val);
1.88 + PRAGMA aux.freelist_count;
1.89 + }
1.90 + } {0}
1.91 + do_test pragma2-2.4 {
1.92 + expr {[file size test2.db] / 1024}
1.93 + } {11}
1.94 + do_test pragma2-2.5 {
1.95 + execsql {
1.96 + DELETE FROM aux.abc;
1.97 + PRAGMA aux.freelist_count;
1.98 + }
1.99 + } {9}
1.100 +
1.101 + do_test pragma2-3.1 {
1.102 + execsql {
1.103 + PRAGMA aux.freelist_count;
1.104 + PRAGMA main.freelist_count;
1.105 + PRAGMA freelist_count;
1.106 + }
1.107 + } {9 1 1}
1.108 + do_test pragma2-3.2 {
1.109 + execsql {
1.110 + PRAGMA freelist_count = 500;
1.111 + PRAGMA freelist_count;
1.112 + }
1.113 + } {1 1}
1.114 + do_test pragma2-3.3 {
1.115 + execsql {
1.116 + PRAGMA aux.freelist_count = 500;
1.117 + PRAGMA aux.freelist_count;
1.118 + }
1.119 + } {9 9}
1.120 +}
1.121 +
1.122 +finish_test