aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/sqlite/unix/sqlite-3.5.1/test/pragma2.test
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/sqlite/unix/sqlite-3.5.1/test/pragma2.test')
-rw-r--r--libraries/sqlite/unix/sqlite-3.5.1/test/pragma2.test117
1 files changed, 117 insertions, 0 deletions
diff --git a/libraries/sqlite/unix/sqlite-3.5.1/test/pragma2.test b/libraries/sqlite/unix/sqlite-3.5.1/test/pragma2.test
new file mode 100644
index 0000000..faf04c0
--- /dev/null
+++ b/libraries/sqlite/unix/sqlite-3.5.1/test/pragma2.test
@@ -0,0 +1,117 @@
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.3 2007/09/12 17:01:45 danielk1977 Exp $
16
17set testdir [file dirname $argv0]
18source $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
27ifcapable !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#
35db close
36file delete test.db test.db-journal
37file delete test3.db test3.db-journal
38sqlite3 db test.db; set DB [sqlite3_connection_pointer db]
39db eval {PRAGMA auto_vacuum=0}
40
41do_test pragma2-1.1 {
42 execsql {
43 PRAGMA freelist_count;
44 }
45} {0}
46do_test pragma2-1.2 {
47 execsql {
48 CREATE TABLE abc(a, b, c);
49 PRAGMA freelist_count;
50 }
51} {0}
52do_test pragma2-1.3 {
53 execsql {
54 DROP TABLE abc;
55 PRAGMA freelist_count;
56 }
57} {1}
58do_test pragma2-1.4 {
59 execsql {
60 PRAGMA main.freelist_count;
61 }
62} {1}
63
64file delete -force test2.db
65file delete -force test2.db-journal
66
67do_test pragma2-2.1 {
68 execsql {
69 ATTACH 'test2.db' AS aux;
70 PRAGMA aux.auto_vacuum=OFF;
71 PRAGMA aux.freelist_count;
72 }
73} {0}
74do_test pragma2-2.2 {
75 execsql {
76 CREATE TABLE aux.abc(a, b, c);
77 PRAGMA aux.freelist_count;
78 }
79} {0}
80do_test pragma2-2.3 {
81 set ::val [string repeat 0123456789 1000]
82 execsql {
83 INSERT INTO aux.abc VALUES(1, 2, $::val);
84 PRAGMA aux.freelist_count;
85 }
86} {0}
87do_test pragma2-2.4 {
88 expr {[file size test2.db] / 1024}
89} {11}
90do_test pragma2-2.5 {
91 execsql {
92 DELETE FROM aux.abc;
93 PRAGMA aux.freelist_count;
94 }
95} {9}
96
97do_test pragma2-3.1 {
98 execsql {
99 PRAGMA aux.freelist_count;
100 PRAGMA main.freelist_count;
101 PRAGMA freelist_count;
102 }
103} {9 1 1}
104do_test pragma2-3.2 {
105 execsql {
106 PRAGMA freelist_count = 500;
107 PRAGMA freelist_count;
108 }
109} {1 1}
110do_test pragma2-3.3 {
111 execsql {
112 PRAGMA aux.freelist_count = 500;
113 PRAGMA aux.freelist_count;
114 }
115} {9 9}
116
117finish_test