2004-09-02 19:14:00 +04:00
|
|
|
# 2004 September 2
|
|
|
|
#
|
|
|
|
# The author disclaims copyright to this source code. In place of
|
|
|
|
# a legal notice, here is a blessing:
|
|
|
|
#
|
|
|
|
# May you do good and not evil.
|
|
|
|
# May you find forgiveness for yourself and forgive others.
|
|
|
|
# May you share freely, never taking more than you give.
|
|
|
|
#
|
|
|
|
#***********************************************************************
|
|
|
|
# This file implements regression tests for SQLite library.
|
|
|
|
# This file implements tests for the page_size PRAGMA.
|
|
|
|
#
|
2008-08-27 01:07:26 +04:00
|
|
|
# $Id: pagesize.test,v 1.13 2008/08/26 21:07:27 drh Exp $
|
2004-09-02 19:14:00 +04:00
|
|
|
|
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
|
|
|
|
2004-11-23 13:52:51 +03:00
|
|
|
# This test script depends entirely on "PRAGMA page_size". So if this
|
|
|
|
# pragma is not available, omit the whole file.
|
|
|
|
ifcapable !pager_pragmas {
|
|
|
|
finish_test
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2004-09-02 19:14:00 +04:00
|
|
|
do_test pagesize-1.1 {
|
|
|
|
execsql {PRAGMA page_size}
|
|
|
|
} 1024
|
2004-11-03 19:27:01 +03:00
|
|
|
ifcapable {explain} {
|
|
|
|
do_test pagesize-1.2 {
|
|
|
|
catch {execsql {EXPLAIN PRAGMA page_size}}
|
|
|
|
} 0
|
|
|
|
}
|
2004-09-02 19:14:00 +04:00
|
|
|
do_test pagesize-1.3 {
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE t1(a);
|
|
|
|
PRAGMA page_size=2048;
|
|
|
|
PRAGMA page_size;
|
|
|
|
}
|
|
|
|
} 1024
|
2004-09-05 04:33:43 +04:00
|
|
|
|
2004-09-02 19:14:00 +04:00
|
|
|
do_test pagesize-1.4 {
|
|
|
|
db close
|
|
|
|
file delete -force test.db
|
|
|
|
sqlite3 db test.db
|
|
|
|
execsql {
|
2004-09-05 04:33:43 +04:00
|
|
|
PRAGMA page_size=511;
|
2004-09-02 19:14:00 +04:00
|
|
|
PRAGMA page_size;
|
|
|
|
}
|
2004-09-05 04:33:43 +04:00
|
|
|
} 1024
|
2004-09-02 19:14:00 +04:00
|
|
|
do_test pagesize-1.5 {
|
|
|
|
execsql {
|
2004-09-05 04:33:43 +04:00
|
|
|
PRAGMA page_size=512;
|
|
|
|
PRAGMA page_size;
|
2004-09-02 19:14:00 +04:00
|
|
|
}
|
2004-09-05 04:33:43 +04:00
|
|
|
} 512
|
2007-04-07 01:42:22 +04:00
|
|
|
if {![info exists SQLITE_MAX_PAGE_SIZE] || $SQLITE_MAX_PAGE_SIZE>=8192} {
|
|
|
|
do_test pagesize-1.6 {
|
|
|
|
execsql {
|
|
|
|
PRAGMA page_size=8192;
|
|
|
|
PRAGMA page_size;
|
|
|
|
}
|
|
|
|
} 8192
|
|
|
|
do_test pagesize-1.7 {
|
|
|
|
execsql {
|
|
|
|
PRAGMA page_size=65537;
|
|
|
|
PRAGMA page_size;
|
|
|
|
}
|
|
|
|
} 8192
|
|
|
|
do_test pagesize-1.8 {
|
|
|
|
execsql {
|
|
|
|
PRAGMA page_size=1234;
|
|
|
|
PRAGMA page_size
|
|
|
|
}
|
|
|
|
} 8192
|
|
|
|
}
|
2004-11-02 17:24:33 +03:00
|
|
|
foreach PGSZ {512 2048 4096 8192} {
|
2007-04-07 01:42:22 +04:00
|
|
|
if {[info exists SQLITE_MAX_PAGE_SIZE]
|
|
|
|
&& $SQLITE_MAX_PAGE_SIZE<$PGSZ} continue
|
2006-01-17 12:35:01 +03:00
|
|
|
ifcapable memorydb {
|
2008-08-27 01:07:26 +04:00
|
|
|
do_test pagesize-2.$PGSZ.0.1 {
|
2006-01-17 12:35:01 +03:00
|
|
|
db close
|
|
|
|
sqlite3 db :memory:
|
|
|
|
execsql "PRAGMA page_size=$PGSZ;"
|
|
|
|
execsql {PRAGMA page_size}
|
2008-08-27 01:07:26 +04:00
|
|
|
} $PGSZ
|
|
|
|
do_test pagesize-2.$PGSZ.0.2 {
|
|
|
|
execsql {CREATE TABLE t1(x UNIQUE, y UNIQUE, z UNIQUE)}
|
|
|
|
execsql {PRAGMA page_size}
|
|
|
|
} $PGSZ
|
|
|
|
do_test pagesize-2.$PGSZ.0.3 {
|
|
|
|
execsql {
|
|
|
|
INSERT INTO t1 VALUES(1,2,3);
|
|
|
|
INSERT INTO t1 VALUES(2,3,4);
|
|
|
|
SELECT * FROM t1;
|
|
|
|
}
|
|
|
|
} {1 2 3 2 3 4}
|
2006-01-17 12:35:01 +03:00
|
|
|
}
|
2004-09-05 04:33:43 +04:00
|
|
|
do_test pagesize-2.$PGSZ.1 {
|
|
|
|
db close
|
|
|
|
file delete -force test.db
|
|
|
|
sqlite3 db test.db
|
|
|
|
execsql "PRAGMA page_size=$PGSZ"
|
|
|
|
execsql {
|
|
|
|
CREATE TABLE t1(x);
|
|
|
|
PRAGMA page_size;
|
|
|
|
}
|
|
|
|
} $PGSZ
|
|
|
|
do_test pagesize-2.$PGSZ.2 {
|
|
|
|
db close
|
|
|
|
sqlite3 db test.db
|
|
|
|
execsql {
|
|
|
|
PRAGMA page_size
|
|
|
|
}
|
|
|
|
} $PGSZ
|
|
|
|
do_test pagesize-2.$PGSZ.3 {
|
|
|
|
file size test.db
|
2004-11-10 18:27:38 +03:00
|
|
|
} [expr {$PGSZ*($AUTOVACUUM?3:2)}]
|
2004-11-04 07:42:28 +03:00
|
|
|
ifcapable {vacuum} {
|
|
|
|
do_test pagesize-2.$PGSZ.4 {
|
|
|
|
execsql {VACUUM}
|
|
|
|
} {}
|
|
|
|
}
|
2004-09-05 04:33:43 +04:00
|
|
|
integrity_check pagesize-2.$PGSZ.5
|
|
|
|
do_test pagesize-2.$PGSZ.6 {
|
|
|
|
db close
|
|
|
|
sqlite3 db test.db
|
|
|
|
execsql {PRAGMA page_size}
|
|
|
|
} $PGSZ
|
|
|
|
do_test pagesize-2.$PGSZ.7 {
|
|
|
|
execsql {
|
|
|
|
INSERT INTO t1 VALUES(randstr(10,9000));
|
|
|
|
INSERT INTO t1 VALUES(randstr(10,9000));
|
|
|
|
INSERT INTO t1 VALUES(randstr(10,9000));
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t1 SELECT x||x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT x||x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT x||x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT x||x FROM t1;
|
|
|
|
SELECT count(*) FROM t1;
|
|
|
|
}
|
|
|
|
} 48
|
|
|
|
do_test pagesize-2.$PGSZ.8 {
|
|
|
|
execsql {
|
|
|
|
ROLLBACK;
|
|
|
|
SELECT count(*) FROM t1;
|
|
|
|
}
|
|
|
|
} 3
|
|
|
|
integrity_check pagesize-2.$PGSZ.9
|
|
|
|
do_test pagesize-2.$PGSZ.10 {
|
|
|
|
db close
|
|
|
|
sqlite3 db test.db
|
|
|
|
execsql {PRAGMA page_size}
|
|
|
|
} $PGSZ
|
|
|
|
do_test pagesize-2.$PGSZ.11 {
|
|
|
|
execsql {
|
|
|
|
INSERT INTO t1 SELECT x||x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT x||x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT x||x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT x||x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT x||x FROM t1;
|
|
|
|
INSERT INTO t1 SELECT x||x FROM t1;
|
|
|
|
SELECT count(*) FROM t1;
|
|
|
|
}
|
|
|
|
} 192
|
|
|
|
do_test pagesize-2.$PGSZ.12 {
|
|
|
|
execsql {
|
|
|
|
BEGIN;
|
|
|
|
DELETE FROM t1 WHERE rowid%5!=0;
|
|
|
|
SELECT count(*) FROM t1;
|
|
|
|
}
|
|
|
|
} 38
|
|
|
|
do_test pagesize-2.$PGSZ.13 {
|
|
|
|
execsql {
|
|
|
|
ROLLBACK;
|
|
|
|
SELECT count(*) FROM t1;
|
|
|
|
}
|
|
|
|
} 192
|
|
|
|
integrity_check pagesize-2.$PGSZ.14
|
|
|
|
do_test pagesize-2.$PGSZ.15 {
|
2004-11-04 07:42:28 +03:00
|
|
|
execsql {DELETE FROM t1 WHERE rowid%5!=0}
|
|
|
|
ifcapable {vacuum} {execsql VACUUM}
|
|
|
|
execsql {SELECT count(*) FROM t1}
|
2004-09-05 04:33:43 +04:00
|
|
|
} 38
|
|
|
|
do_test pagesize-2.$PGSZ.16 {
|
2004-11-04 07:42:28 +03:00
|
|
|
execsql {DROP TABLE t1}
|
|
|
|
ifcapable {vacuum} {execsql VACUUM}
|
2004-09-05 04:33:43 +04:00
|
|
|
} {}
|
|
|
|
integrity_check pagesize-2.$PGSZ.17
|
2010-01-26 04:25:26 +03:00
|
|
|
|
|
|
|
db close
|
|
|
|
file delete -force test.db
|
|
|
|
sqlite3 db test.db
|
|
|
|
do_test pagesize-2.$PGSZ.30 {
|
|
|
|
execsql "
|
|
|
|
CREATE TABLE t1(x);
|
|
|
|
PRAGMA temp.page_size=$PGSZ;
|
|
|
|
CREATE TEMP TABLE t2(y);
|
|
|
|
PRAGMA main.page_size;
|
|
|
|
PRAGMA temp.page_size;
|
|
|
|
"
|
|
|
|
} [list 1024 $PGSZ]
|
|
|
|
|
|
|
|
db close
|
|
|
|
file delete -force test.db
|
|
|
|
sqlite3 db test.db
|
|
|
|
do_test pagesize-2.$PGSZ.40 {
|
|
|
|
execsql "
|
|
|
|
PRAGMA page_size=$PGSZ;
|
|
|
|
CREATE TABLE t1(x);
|
|
|
|
CREATE TEMP TABLE t2(y);
|
|
|
|
PRAGMA main.page_size;
|
|
|
|
PRAGMA temp.page_size;
|
|
|
|
"
|
|
|
|
} [list $PGSZ $PGSZ]
|
2004-09-05 04:33:43 +04:00
|
|
|
}
|
2004-09-02 19:14:00 +04:00
|
|
|
|
|
|
|
finish_test
|