1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00
Files
sqlite/test/wal2savepoint.test
dan 855e3792bd Merge the latest trunk enhancements, via the wal2 branch, into the bedrock branch.
FossilOrigin-Name: fd6ff55141be82ba36513ba6273a60c6d8b3c496ed7890ab47cccb05bec7f7c2
2024-09-30 17:57:58 +00:00

75 lines
2.1 KiB
Plaintext

# 2018 December 13
#
# 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. The
# focus of this file is testing the operation of the library in
# "PRAGMA journal_mode=WAL2" mode.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
source $testdir/lock_common.tcl
source $testdir/malloc_common.tcl
source $testdir/wal_common.tcl
set testprefix wal2savepoint
ifcapable !wal {finish_test ; return }
reset_prng_state
do_execsql_test 1.0 {
CREATE TABLE t1(a, b, c);
CREATE INDEX t1a ON t1(a);
CREATE INDEX t1b ON t1(b);
CREATE INDEX t1c ON t1(c);
PRAGMA journal_mode = wal2;
PRAGMA journal_size_limit = 15000;
PRAGMA wal_autocheckpoint = 0;
PRAGMA cache_size = 5;
} {wal2 15000 0}
do_execsql_test 1.1 {
WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s where i < 200)
INSERT INTO t1 SELECT random(), random(), random() FROM s;
} {}
do_test 1.2 {
list [file size test.db] [file size test.db-wal2] \
[expr [file size test.db-wal]>20000]
} {5120 0 1}
do_execsql_test 1.3 {
BEGIN;
SAVEPOINT abc;
WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s where i < 100)
INSERT INTO t1 SELECT random(), random(), random() FROM s;
ROLLBACK TO abc;
WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s where i < 10)
INSERT INTO t1 SELECT random(), random(), random() FROM s;
COMMIT;
SELECT count(*) FROM t1;
PRAGMA integrity_check;
} {210 ok}
do_execsql_test 1.4 {
BEGIN;
SAVEPOINT abc;
WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s where i < 100)
INSERT INTO t1 SELECT random(), random(), random() FROM s;
ROLLBACK TO abc;
WITH s(i) AS ( SELECT 1 UNION ALL SELECT i+1 FROM s where i < 10)
INSERT INTO t1 SELECT random(), random(), random() FROM s;
COMMIT;
SELECT count(*) FROM t1;
PRAGMA integrity_check;
} {220 ok}
finish_test