0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-12-01 17:23:42 +01:00
sqlite/test/pagesize.test
drh 6bf895708c Update tests to work even if some features of the library are disabled. (CVS 2050)
FossilOrigin-Name: b11fc9b3f3a2711f98e7e45724aa1d30081197f3
2004-11-03 16:27:01 +00:00

167 lines
3.6 KiB
Plaintext

# 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.
#
# $Id: pagesize.test,v 1.6 2004/11/03 16:27:02 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
do_test pagesize-1.1 {
execsql {PRAGMA page_size}
} 1024
ifcapable {explain} {
do_test pagesize-1.2 {
catch {execsql {EXPLAIN PRAGMA page_size}}
} 0
}
do_test pagesize-1.3 {
execsql {
CREATE TABLE t1(a);
PRAGMA page_size=2048;
PRAGMA page_size;
}
} 1024
do_test pagesize-1.4 {
db close
file delete -force test.db
sqlite3 db test.db
execsql {
PRAGMA page_size=511;
PRAGMA page_size;
}
} 1024
do_test pagesize-1.5 {
execsql {
PRAGMA page_size=512;
PRAGMA page_size;
}
} 512
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
foreach PGSZ {512 2048 4096 8192} {
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
} [expr {$PGSZ*2}]
do_test pagesize-2.$PGSZ.4 {
execsql {VACUUM}
} {}
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 {
execsql {
DELETE FROM t1 WHERE rowid%5!=0;
VACUUM;
SELECT count(*) FROM t1;
}
} 38
do_test pagesize-2.$PGSZ.16 {
execsql {
DROP TABLE t1;
VACUUM;
}
} {}
integrity_check pagesize-2.$PGSZ.17
}
finish_test