AryaWu/sqlite
0
1# 2024 January 232#3# The author disclaims copyright to this source code. In place of4# 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.tcl17set testprefix mmapcorrupt18 19ifcapable !mmap {20 finish_test21 return22}23database_may_be_corrupt24 25db close26sqlite3_shutdown27sqlite3_config_lookaside 0 028sqlite3_initialize29 30reset_db31do_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 close39 40set sz [file size test.db]41hexio_write test.db [expr $sz-3] 80038042 43sqlite3 db test.db44do_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_test55 56 