3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
11 # This file implements regression tests for SQLite library.
12 # This file implements tests for the page_size PRAGMA.
14 # $Id: pagesize.test,v 1.13 2008/08/26 21:07:27 drh Exp $
17 set testdir [file dirname $argv0]
18 source $testdir/tester.tcl
20 # This test script depends entirely on "PRAGMA page_size". So if this
21 # pragma is not available, omit the whole file.
22 ifcapable !pager_pragmas {
27 do_test pagesize-1.1 {
28 execsql {PRAGMA page_size}
31 do_test pagesize-1.2 {
32 catch {execsql {EXPLAIN PRAGMA page_size}}
35 do_test pagesize-1.3 {
38 PRAGMA page_size=2048;
43 do_test pagesize-1.4 {
45 file delete -force test.db
52 do_test pagesize-1.5 {
58 if {![info exists SQLITE_MAX_PAGE_SIZE] || $SQLITE_MAX_PAGE_SIZE>=8192} {
59 do_test pagesize-1.6 {
61 PRAGMA page_size=8192;
65 do_test pagesize-1.7 {
67 PRAGMA page_size=65537;
71 do_test pagesize-1.8 {
73 PRAGMA page_size=1234;
78 foreach PGSZ {512 2048 4096 8192} {
79 if {[info exists SQLITE_MAX_PAGE_SIZE]
80 && $SQLITE_MAX_PAGE_SIZE<$PGSZ} continue
82 do_test pagesize-2.$PGSZ.0.1 {
85 execsql "PRAGMA page_size=$PGSZ;"
86 execsql {PRAGMA page_size}
88 do_test pagesize-2.$PGSZ.0.2 {
89 execsql {CREATE TABLE t1(x UNIQUE, y UNIQUE, z UNIQUE)}
90 execsql {PRAGMA page_size}
92 do_test pagesize-2.$PGSZ.0.3 {
94 INSERT INTO t1 VALUES(1,2,3);
95 INSERT INTO t1 VALUES(2,3,4);
100 do_test pagesize-2.$PGSZ.1 {
102 file delete -force test.db
104 execsql "PRAGMA page_size=$PGSZ"
110 do_test pagesize-2.$PGSZ.2 {
117 do_test pagesize-2.$PGSZ.3 {
119 } [expr {$PGSZ*($AUTOVACUUM?3:2)}]
121 do_test pagesize-2.$PGSZ.4 {
125 integrity_check pagesize-2.$PGSZ.5
126 do_test pagesize-2.$PGSZ.6 {
129 execsql {PRAGMA page_size}
131 do_test pagesize-2.$PGSZ.7 {
133 INSERT INTO t1 VALUES(randstr(10,9000));
134 INSERT INTO t1 VALUES(randstr(10,9000));
135 INSERT INTO t1 VALUES(randstr(10,9000));
137 INSERT INTO t1 SELECT x||x FROM t1;
138 INSERT INTO t1 SELECT x||x FROM t1;
139 INSERT INTO t1 SELECT x||x FROM t1;
140 INSERT INTO t1 SELECT x||x FROM t1;
141 SELECT count(*) FROM t1;
144 do_test pagesize-2.$PGSZ.8 {
147 SELECT count(*) FROM t1;
150 integrity_check pagesize-2.$PGSZ.9
151 do_test pagesize-2.$PGSZ.10 {
154 execsql {PRAGMA page_size}
156 do_test pagesize-2.$PGSZ.11 {
158 INSERT INTO t1 SELECT x||x FROM t1;
159 INSERT INTO t1 SELECT x||x FROM t1;
160 INSERT INTO t1 SELECT x||x FROM t1;
161 INSERT INTO t1 SELECT x||x FROM t1;
162 INSERT INTO t1 SELECT x||x FROM t1;
163 INSERT INTO t1 SELECT x||x FROM t1;
164 SELECT count(*) FROM t1;
167 do_test pagesize-2.$PGSZ.12 {
170 DELETE FROM t1 WHERE rowid%5!=0;
171 SELECT count(*) FROM t1;
174 do_test pagesize-2.$PGSZ.13 {
177 SELECT count(*) FROM t1;
180 integrity_check pagesize-2.$PGSZ.14
181 do_test pagesize-2.$PGSZ.15 {
182 execsql {DELETE FROM t1 WHERE rowid%5!=0}
183 ifcapable {vacuum} {execsql VACUUM}
184 execsql {SELECT count(*) FROM t1}
186 do_test pagesize-2.$PGSZ.16 {
187 execsql {DROP TABLE t1}
188 ifcapable {vacuum} {execsql VACUUM}
190 integrity_check pagesize-2.$PGSZ.17
193 file delete -force test.db
195 do_test pagesize-2.$PGSZ.30 {
198 PRAGMA temp.page_size=$PGSZ;
199 CREATE TEMP TABLE t2(y);
200 PRAGMA main.page_size;
201 PRAGMA temp.page_size;
206 file delete -force test.db
208 do_test pagesize-2.$PGSZ.40 {
210 PRAGMA page_size=$PGSZ;
212 CREATE TEMP TABLE t2(y);
213 PRAGMA main.page_size;
214 PRAGMA temp.page_size;