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 / reservebytes.test
| 1 | # 2025 August 27 |
| 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 | |
| 13 | set testdir [file dirname $argv0] |
| 14 | source $testdir/tester.tcl |
| 15 | set testprefix reservebytes |
| 16 | |
| 17 | |
| 18 | |
| 19 | reset_db |
| 20 | file_control_reservebytes db 0 |
| 21 | |
| 22 | |
| 23 | do_execsql_test 1.0 { |
| 24 | CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c); |
| 25 | CREATE INDEX i1 ON t1(b, c); |
| 26 | WITH s(i) AS ( |
| 27 | VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<1000 |
| 28 | ) |
| 29 | INSERT INTO t1 SELECT NULL, i, hex(randomblob(500)) FROM s; |
| 30 | } |
| 31 | |
| 32 | sqlite3 db2 test.db |
| 33 | if {[permutation]=="prepare"} { db2 cache size 0 } |
| 34 | |
| 35 | do_execsql_test -db db2 1.1 { PRAGMA integrity_check } {ok} |
| 36 | |
| 37 | file_control_reservebytes db 8 |
| 38 | do_test 1.2.1 { hexio_read test.db 20 1 } {00} |
| 39 | do_execsql_test -db db2 1.2.2 { PRAGMA integrity_check } {ok} |
| 40 | |
| 41 | do_execsql_test 1.3.2 { VACUUM } |
| 42 | do_execsql_test -db db2 1.3.4 { PRAGMA integrity_check } {ok} |
| 43 | do_test 1.3.5 { hexio_read test.db 20 1 } {08} |
| 44 | |
| 45 | file_control_reservebytes db 16 |
| 46 | do_test 1.4.1 { hexio_read test.db 20 1 } {08} |
| 47 | do_execsql_test 1.4.2 { VACUUM } |
| 48 | do_execsql_test -db db2 1.4.3 { PRAGMA integrity_check } {ok} |
| 49 | do_test 1.4.4 { hexio_read test.db 20 1 } {10} |
| 50 | |
| 51 | finish_test |