sqlite
[Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI.
Brought by drakestapleton
| 1 | # 2024 February 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 | # This file implements tests for PRAGMAs quick_check and integrity_check. |
| 12 | # |
| 13 | |
| 14 | set testdir [file dirname $argv0] |
| 15 | source $testdir/tester.tcl |
| 16 | set testprefix pragma6 |
| 17 | |
| 18 | database_may_be_corrupt |
| 19 | |
| 20 | #------------------------------------------------------------------------- |
| 21 | # |
| 22 | do_test 1.0 { |
| 23 | sqlite3 db {} |
| 24 | db deserialize [decode_hexdb { |
| 25 | .open --hexdb |
| 26 | | size 12288 pagesize 4096 filename crash-540f4c1eb1e7ac.db |
| 27 | | page 1 offset 0 |
| 28 | | 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. |
| 29 | | 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 03 .....@ ........ |
| 30 | | 32: 00 bb 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ |
| 31 | | 96: 00 00 00 00 0d 00 00 00 02 0f 7f 00 0f c3 0f 7f ................ |
| 32 | | 3952: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 42 ...............B |
| 33 | | 3968: 02 06 17 11 11 01 71 74 61 62 6c 65 74 32 74 32 ......qtablet2t2 |
| 34 | | 3984: 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 32 .CREATE TABLE t2 |
| 35 | | 4000: 28 61 20 49 4e 54 2c 20 62 20 41 53 20 28 61 2a (a INT, b AS (a* |
| 36 | | 4016: 32 29 20 53 54 4f 52 45 44 20 4e 4f 54 20 4e 55 2) STORED NOT NU |
| 37 | | 4032: 4c 4c 29 3b 01 06 17 11 11 01 63 74 61 62 6c 65 LL);......ctable |
| 38 | | 4048: 74 31 74 31 02 43 52 45 41 54 45 20 54 41 42 4c t1t1.CREATE TABL |
| 39 | | 4064: 45 20 74 31 28 61 20 49 4e 54 2c 20 62 20 41 53 E t1(a INT, b AS |
| 40 | | 4080: 20 28 61 2a 32 29 20 4e 4f 54 20 4e 55 4c 4c 29 (a*2) NOT NULL) |
| 41 | | page 2 offset 4096 |
| 42 | | 0: 0d 00 00 00 05 0f e7 00 00 00 00 00 00 00 00 00 ................ |
| 43 | | 4064: 00 00 00 00 00 00 00 00 03 05 02 01 05 03 04 02 ................ |
| 44 | | 4080: 01 04 03 03 02 01 03 03 02 02 01 02 02 01 02 09 ................ |
| 45 | | page 3 offset 8192 |
| 46 | | 0: 0d 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ |
| 47 | | 4048: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 05 05 ................ |
| 48 | | 4064: 03 01 01 05 0a 05 04 03 01 01 04 08 05 03 03 01 ................ |
| 49 | | 4080: 01 03 06 05 02 03 00 00 00 00 00 00 00 00 00 00 ................ |
| 50 | | end crash-540f4c1eb1e7ac.db |
| 51 | }] |
| 52 | } {} |
| 53 | |
| 54 | do_test 1.1 { |
| 55 | execsql { |
| 56 | CREATE TEMP TABLE t2( |
| 57 | a t1 PRIMARY KEY default 27, |
| 58 | b default(current_timestamp), |
| 59 | d TEXT UNIQUE DEFAULT 'ch`arlie', |
| 60 | c TEXT UNIQUE DEFAULT 084, |
| 61 | UNIQUE(c,b,b,a,b) |
| 62 | ) WITHOUT ROWID; |
| 63 | } |
| 64 | catchsql { INSERT INTO t1(a) VALUES(zeroblob(40000)) } |
| 65 | set {} {} |
| 66 | } {} |
| 67 | |
| 68 | do_test 1.2 { |
| 69 | execsql { PRAGMA cell_size_check=OFF; } |
| 70 | execsql { PRAGMA integrity_check; } |
| 71 | execsql { PRAGMA quick_check; } |
| 72 | set {} {} |
| 73 | } {} |
| 74 | |
| 75 | finish_test |