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

55 lines · 1241 bytes Raw Blame History
1# 2024 January 23
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# Test special cases of corrupt database handling in mmap-mode.
13#
14
15set testdir [file dirname $argv0]
16source $testdir/tester.tcl
17set testprefix mmapcorrupt
18
19ifcapable !mmap {
20 finish_test
21 return
22}
23database_may_be_corrupt
24
25db close
26sqlite3_shutdown
27sqlite3_config_lookaside 0 0
28sqlite3_initialize
29
30reset_db
31do_execsql_test 1.0 {
32 PRAGMA page_size = 16384;
33 CREATE TABLE tn1(a PRIMARY KEY) WITHOUT ROWID;
34 CREATE TABLE t0(a PRIMARY KEY) WITHOUT ROWID;
35 CREATE TABLE t1(a PRIMARY KEY) WITHOUT ROWID;
36 INSERT INTO t1 VALUES('B');
37}
38db close
39
40set sz [file size test.db]
41hexio_write test.db [expr $sz-3] 800380
42
43sqlite3 db test.db
44do_execsql_test 2.1 {
45 PRAGMA mmap_size = 1000000;
46 SELECT sql FROM sqlite_schema LIMIT 1;
47 SELECT * FROM t0;
48} {1000000 {CREATE TABLE tn1(a PRIMARY KEY) WITHOUT ROWID}}
49
50do_execsql_test 2.2 {
51 INSERT INTO t0 SELECT * FROM t1;
52}
53
54finish_test
55