Add assert() statements to validate access to the SrcItem.u1.nRow union member.
[sqlite.git] / test / mmapcorrupt.test
blob70dbe8464710772c43cd35574c0291bbd4dc71f6
1 # 2024 January 23
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # Test special cases of corrupt database handling in mmap-mode.
15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl
17 set testprefix mmapcorrupt
19 database_may_be_corrupt
21 db close
22 sqlite3_shutdown
23 sqlite3_config_lookaside 0 0
24 sqlite3_initialize
26 reset_db
27 do_execsql_test 1.0 {
28   PRAGMA page_size = 16384;
29   CREATE TABLE tn1(a PRIMARY KEY) WITHOUT ROWID;
30   CREATE TABLE t0(a PRIMARY KEY) WITHOUT ROWID;
31   CREATE TABLE t1(a PRIMARY KEY) WITHOUT ROWID;
32   INSERT INTO t1 VALUES('B');
34 db close
36 set sz [file size test.db]
37 hexio_write test.db [expr $sz-3] 800380
39 sqlite3 db test.db
40 do_execsql_test 2.1 {
41   PRAGMA mmap_size = 1000000;
42   SELECT sql FROM sqlite_schema LIMIT 1;
43   SELECT * FROM t0;
44 } {1000000 {CREATE TABLE tn1(a PRIMARY KEY) WITHOUT ROWID}}
46 do_execsql_test 2.2 {
47   INSERT INTO t0 SELECT * FROM t1;
50 finish_test