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

71 lines · 1994 bytes Raw Blame History
1# 2026 July 21
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.
12#
13
14set testdir [file dirname $argv0]
15source $testdir/tester.tcl
16set testprefix crash9
17
18forcedelete test.db2
19
20#-------------------------------------------------------------------------
21# The following test is to hit the bug reported here:
22#
23# https://sqlite.org/forum/info/2026-07-20T18:27:00Z
24#
25# Essentially, when a super-journal record is appended to a journal file,
26# if the write() calls that set the super-journal magic values and length
27# succeed, but the calls that write the super-journal name and checksum
28# fail and end up writing zeroes into the file, then the super-journal
29# checksum appears to match (because 0 is the checksum for a zero length
30# string). This was confusing SQLite, preventing it from rolling the
31# journal back later on.
32#
33do_execsql_test 1.0 {
34 CREATE TABLE t1(x INTEGER PRIMARY KEY, y);
35 CREATE INDEX i1 ON t1(y);
36 WITH s(i) AS (
37 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<10
38 )
39 INSERT INTO t1 SELECT i, randomblob(900) FROM s;
40
41 ATTACH 'test.db2' AS aux;
42 CREATE TABLE aux.t2(x, y);
43}
44db_save_and_close
45for {set ii 0} {$ii < 200} {incr ii} {
46 set iDelay 1
47
48 while 1 {
49 db_restore
50 set c [crashsql -delay $iDelay -file test.db-journal -seed $ii "
51 ATTACH 'test.db2' AS aux;
52 PRAGMA cache_size = 5;
53 BEGIN;
54 INSERT INTO aux.t2 VALUES(1, 2);
55 UPDATE t1 SET y=randomblob(901);
56 COMMIT;
57 "]
58
59 if {$c!="1 {child process exited abnormally}"} break
60
61 sqlite3 db test.db
62 do_execsql_test 1.1.$ii.$iDelay { PRAGMA integrity_check } ok
63 incr iDelay
64 db close
65 }
66}
67
68finish_test
69
70
71