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 / cksumvfs.test

100 lines · 1897 bytes Raw Blame History
1# 2024 March 19
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#
12
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15set testprefix cksumvfs
16
17
18db close
19sqlite3_shutdown
20#test_sqlite3_log logfunc
21sqlite3_initialize
22
23proc logfunc {args} {
24 puts "LOG: $args"
25}
26
27do_test 0.1 {
28 sqlite3_register_cksumvfs
29} {SQLITE_OK}
30do_test 0.2 {
31 # Multiple registrations of cksumvfs are harmless. Bug 2026-07-29T06:28:31Z
32 sqlite3_register_cksumvfs
33} {SQLITE_OK}
34
35sqlite3 db test.db
36
37file_control_reservebytes db 8
38execsql {
39 PRAGMA page_size = 4096;
40}
41
42set text [db one "SELECT hex(randomblob(5000))"]
43
44do_execsql_test 1.0 {
45 CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c);
46 INSERT INTO t1 VALUES(1, $text, NULL);
47}
48
49do_execsql_test 1.1 {
50 SELECT * FROM t1;
51} [list 1 $text {}]
52
53do_execsql_test 1.2 {
54 DELETE FROM t1;
55}
56
57do_test 1.3 {
58 execsql BEGIN
59 for {set ii 1500} {$ii < 10000} {incr ii} {
60 execsql { INSERT INTO t1 VALUES(NULL, randomblob(5000), randomblob($ii)) }
61 }
62 execsql COMMIT
63} {}
64
65do_execsql_test 1.4 {
66 SELECT count(b) FROM t1
67} {8500}
68
69do_execsql_test 1.5 {
70 PRAGMA journal_mode = wal;
71 DELETE FROM t1;
72} {wal}
73
74do_execsql_test 1.6 {
75 PRAGMA wal_checkpoint;
76} {/0 # #/}
77
78do_execsql_test 1.7 {
79 WITH s(i) AS (
80 VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100
81 )
82 INSERT INTO t1 SELECT NULL, randomblob(5000), randomblob(i) FROM s;
83 SELECT count(*) FROM t1;
84} {100}
85
86db_save_and_close
87db_restore_and_reopen
88
89do_execsql_test 1.8 {
90 SELECT count(*) FROM t1;
91} {100}
92
93db close
94sqlite3 db test.db
95
96do_execsql_test 1.9 {
97 SELECT count(*) FROM t1;
98} {100}
99
100finish_test