0
0
mirror of https://github.com/sqlite/sqlite.git synced 2024-12-01 17:23:42 +01:00
sqlite/test/vacuum6.test
dan ebbf36878c Avoid loading large intkey rows when VACUUMing, even if the page-size is changing.
FossilOrigin-Name: 0d2c3776065dc94119899ae4164995193b82fca7ac31868f3141b729d0b65ab9
2020-12-09 16:32:11 +00:00

95 lines
2.0 KiB
Plaintext

# 2016-08-19
#
# 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 a test for VACUUM on attached databases.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix vacuum6
# If the VACUUM statement is disabled in the current build, skip all
# the tests in this file.
#
ifcapable !vacuum {
finish_test
return
}
do_execsql_test 1.0 {
CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
INSERT INTO t1 VALUES(1, 1);
} {}
do_execsql_test 1.1 {
VACUUM
}
#-------------------------------------------------------------------------
reset_db
foreach {tn sz} {1 400 2 4000 3 9999} {
reset_db
do_execsql_test 2.$tn.1 {
CREATE TABLE t1(a INTEGER PRIMARY KEY, b);
WITH s(i) AS (
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<100
)
INSERT INTO t1 SELECT i, randomblob($sz) FROM s;
}
do_execsql_test 2.$tn.2 {
vacuum;
}
do_execsql_test 2.$tn.3 {
PRAGMA integrity_check;
} {ok}
}
reset_db
do_execsql_test 3.0 {
PRAGMA page_size = 1024;
CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
INSERT INTO t1 VALUES(2, randomblob(1200));
} {}
do_execsql_test 3.1 {
PRAGMA page_size = 512;
VACUUM;
}
do_execsql_test 3.2 {
PRAGMA integrity_check
} {ok}
#-------------------------------------------------------------------------
reset_db
do_execsql_test 4.0 {
CREATE TABLE tx(a, b);
CREATE INDEX i1 ON tx(b);
WITH s(i) AS (
SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10000
)
INSERT INTO tx SELECT i, randomblob(i) FROM s;
}
foreach {tn pgsz} {
1 2048
2 1024
3 65536
4 8192
} {
do_execsql_test 4.1.$tn.1 "
PRAGMA page_size = $pgsz
"
do_execsql_test 4.1.$tn.2 VACUUM
integrity_check 4.1.$tn.3
}
finish_test