sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
sqlite / test / mmapcorrupt.test
| 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 | |
| 15 | set testdir [file dirname $argv0] |
| 16 | source $testdir/tester.tcl |
| 17 | set testprefix mmapcorrupt |
| 18 | |
| 19 | ifcapable !mmap { |
| 20 | finish_test |
| 21 | return |
| 22 | } |
| 23 | database_may_be_corrupt |
| 24 | |
| 25 | db close |
| 26 | sqlite3_shutdown |
| 27 | sqlite3_config_lookaside 0 0 |
| 28 | sqlite3_initialize |
| 29 | |
| 30 | reset_db |
| 31 | do_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 | } |
| 38 | db close |
| 39 | |
| 40 | set sz [file size test.db] |
| 41 | hexio_write test.db [expr $sz-3] 800380 |
| 42 | |
| 43 | sqlite3 db test.db |
| 44 | do_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 | |
| 50 | do_execsql_test 2.2 { |
| 51 | INSERT INTO t0 SELECT * FROM t1; |
| 52 | } |
| 53 | |
| 54 | finish_test |
| 55 |