interplane.Get Omega
Read in your language

sqlite

[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.

Brought by drakestapleton

branch master Branches Tags History

sqlite / test / walckptnoop.test

114 lines · 2376 bytes Raw Blame History
1# 2025 September 5
2#
3# The author disclaims copyright to this source code. In place of
4# a legal notice, here is a blessing:
5#
6# May you do good and not evil.
7# May you find forgiveness for yourself and forgive others.
8# May you share freely, never taking more than you give.
9#
10#***********************************************************************
11# This file implements regression tests for SQLite library. The
12# focus of this file is testing the operation of the library in
13# "PRAGMA wal_checkpoint = noop" mode.
14#
15
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18source $testdir/lock_common.tcl
19source $testdir/malloc_common.tcl
20source $testdir/wal_common.tcl
21
22set testprefix walckptnoop
23
24ifcapable !wal {finish_test ; return }
25
26set VAL 123
27
28proc myrand {} {
29 global VAL
30
31 set A 1103515245
32 set C 12345
33 set M 2147483648
34
35 set VAL [expr {($A * $VAL + $C) % $M}]
36 return $VAL
37}
38
39proc myrandomblob {n} {
40 set l [list]
41 for {set i 0} {$i < $n} {incr i} {
42 lappend l [expr [myrand] % 256]
43 }
44 binary format c* $l
45}
46
47db func myrandomblob myrandomblob
48
49
50do_execsql_test 1.0 {
51 PRAGMA page_size=1024;
52 PRAGMA auto_vacuum=NONE;
53 PRAGMA secure_delete=OFF;
54 VACUUM;
55 CREATE TABLE t1(x INTEGER PRIMARY KEY, y TEXT);
56 CREATE INDEX i1 ON t1(y);
57 PRAGMA journal_mode = wal;
58
59 WITH s(i) AS (
60 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000
61 )
62 INSERT INTO t1 SELECT NULL, hex(myrandomblob(64)) FROM s;
63} {0 wal}
64
65do_execsql_test 1.1 {
66 PRAGMA wal_checkpoint = noop;
67} {0 298 0}
68do_execsql_test 1.2 {
69 PRAGMA wal_checkpoint = noop;
70} {0 298 0}
71do_execsql_test 1.3 {
72 PRAGMA wal_checkpoint = passive;
73} {0 298 298}
74do_execsql_test 1.4 {
75 PRAGMA wal_checkpoint = noop;
76} {0 298 298}
77
78db_save_and_close
79db_restore_and_reopen
80do_execsql_test 1.5 {
81 PRAGMA wal_checkpoint = noop;
82} {0 298 0}
83
84db close
85sqlite3 db test.db
86db eval {
87 PRAGMA auto_vacuum=NONE;
88 PRAGMA secure_delete=OFF;
89}
90do_execsql_test 1.6 {
91 PRAGMA wal_checkpoint = noop;
92} {0 0 0}
93
94do_catchsql_test 1.7 {
95 BEGIN;
96 DELETE FROM t1;
97 PRAGMA wal_checkpoint = noop;
98} {1 {database table is locked}}
99
100do_catchsql_test 1.8 {
101 COMMIT;
102 PRAGMA wal_checkpoint = noop;
103} {0 {0 5 0}}
104
105do_test 1.9 {
106 sqlite3_wal_checkpoint_v2 db noop
107} {0 5 0}
108
109do_execsql_test 1.10 {
110 PRAGMA journal_mode = delete;
111 PRAGMA wal_checkpoint = noop;
112} {delete 0 -1 -1}
113
114finish_test