2011-05-19 05:21:42 +04:00
|
|
|
# 2011 May 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 regression tests for SQLite library. Specifically,
|
|
|
|
# it tests that ticket [2d1a5c67dfc2363e44f29d9bbd57f7331851390a] has
|
|
|
|
# been resolved.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
set testdir [file dirname $argv0]
|
|
|
|
source $testdir/tester.tcl
|
2011-05-19 11:53:23 +04:00
|
|
|
set testprefix tkt-2d1a5c67d
|
2011-05-19 05:21:42 +04:00
|
|
|
|
2021-11-08 22:35:26 +03:00
|
|
|
ifcapable {!vtab || !incrblob} {finish_test; return}
|
2016-04-27 21:54:49 +03:00
|
|
|
if {[wal_is_capable]==0} {finish_test; return}
|
2011-05-19 05:21:42 +04:00
|
|
|
|
|
|
|
for {set ii 1} {$ii<=10} {incr ii} {
|
|
|
|
do_test tkt-2d1a5c67d.1.$ii {
|
|
|
|
db close
|
|
|
|
forcedelete test.db test.db-wal
|
|
|
|
sqlite3 db test.db
|
|
|
|
db eval "PRAGMA cache_size=$::ii"
|
|
|
|
db eval {
|
|
|
|
PRAGMA journal_mode=WAL;
|
|
|
|
CREATE TABLE t1(a,b);
|
|
|
|
CREATE INDEX t1b ON t1(b);
|
|
|
|
CREATE TABLE t2(x,y UNIQUE);
|
|
|
|
INSERT INTO t2 VALUES(3,4);
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t1(a,b) VALUES(1,2);
|
|
|
|
SELECT 'A', * FROM t2 WHERE y=4;
|
|
|
|
SELECT 'B', * FROM t1;
|
|
|
|
COMMIT;
|
|
|
|
SELECT 'C', * FROM t1;
|
|
|
|
}
|
|
|
|
} {wal A 3 4 B 1 2 C 1 2}
|
|
|
|
}
|
|
|
|
|
|
|
|
db close
|
|
|
|
forcedelete test.db test.db-wal
|
|
|
|
sqlite3 db test.db
|
2013-04-25 15:58:36 +04:00
|
|
|
load_static_extension db wholenumber
|
2011-05-19 05:21:42 +04:00
|
|
|
db eval {
|
|
|
|
PRAGMA journal_mode=WAL;
|
|
|
|
CREATE TABLE t1(a,b);
|
|
|
|
CREATE INDEX t1b ON t1(b);
|
|
|
|
CREATE TABLE t2(x,y);
|
|
|
|
CREATE VIRTUAL TABLE nums USING wholenumber;
|
|
|
|
INSERT INTO t2 SELECT value, randomblob(1000) FROM nums
|
|
|
|
WHERE value BETWEEN 1 AND 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
for {set ii 1} {$ii<=10} {incr ii} {
|
|
|
|
do_test tkt-2d1a5c67d.2.$ii {
|
|
|
|
db eval "PRAGMA cache_size=$::ii"
|
|
|
|
db eval {
|
|
|
|
DELETE FROM t1;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t1(a,b) VALUES(1,2);
|
|
|
|
SELECT sum(length(y)) FROM t2;
|
|
|
|
COMMIT;
|
|
|
|
SELECT * FROM t1;
|
|
|
|
}
|
|
|
|
} {1000000 1 2}
|
|
|
|
}
|
|
|
|
|
2011-05-19 11:53:23 +04:00
|
|
|
db close
|
|
|
|
sqlite3 db test.db
|
|
|
|
|
|
|
|
|
|
|
|
do_execsql_test 3.1 {
|
|
|
|
PRAGMA cache_size = 10;
|
|
|
|
CREATE TABLE t3(a INTEGER PRIMARY KEY, b);
|
|
|
|
CREATE TABLE t4(a);
|
|
|
|
}
|
|
|
|
|
|
|
|
do_execsql_test 3.2 {
|
|
|
|
INSERT INTO t3 VALUES(NULL, randomblob(500));
|
|
|
|
INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 2
|
|
|
|
INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 4
|
|
|
|
INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 8
|
|
|
|
INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 16
|
|
|
|
INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 32
|
|
|
|
INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 64
|
|
|
|
INSERT INTO t3 SELECT NULL, b||b FROM t3; -- 128
|
|
|
|
}
|
|
|
|
|
|
|
|
do_execsql_test 3.3 {
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t4 VALUES('xyz');
|
|
|
|
}
|
|
|
|
|
|
|
|
do_test 3.4 {
|
|
|
|
set blobs [list]
|
|
|
|
for {set i 1} {$i<100} {incr i} {
|
|
|
|
set b [db incrblob -readonly t3 b $i]
|
|
|
|
read $b
|
|
|
|
lappend blobs $b
|
|
|
|
}
|
|
|
|
|
|
|
|
execsql COMMIT
|
|
|
|
execsql { SELECT * FROM t4 WHERE a = 'xyz' }
|
|
|
|
} {xyz}
|
|
|
|
|
|
|
|
do_test 3.5 {
|
|
|
|
foreach b $blobs { close $b }
|
|
|
|
execsql { SELECT * FROM t4 WHERE a = 'xyz' }
|
|
|
|
} {xyz}
|
|
|
|
|
|
|
|
# Check that recovery works on the WAL file.
|
|
|
|
#
|
|
|
|
forcedelete test.db2-wal test.db2
|
|
|
|
do_test 3.6 {
|
2011-08-02 04:57:34 +04:00
|
|
|
copy_file test.db-wal test.db2-wal
|
|
|
|
copy_file test.db test.db2
|
2011-05-19 11:53:23 +04:00
|
|
|
sqlite3 db2 test.db2
|
|
|
|
execsql { SELECT * FROM t4 WHERE a = 'xyz' } db2
|
|
|
|
} {xyz}
|
|
|
|
|
2011-05-19 05:21:42 +04:00
|
|
|
finish_test
|