1f7e74904Sdrh# 2012-12-13 2f7e74904Sdrh# 3f7e74904Sdrh# The author disclaims copyright to this source code. In place of 4f7e74904Sdrh# a legal notice, here is a blessing: 5f7e74904Sdrh# 6f7e74904Sdrh# May you do good and not evil. 7f7e74904Sdrh# May you find forgiveness for yourself and forgive others. 8f7e74904Sdrh# May you share freely, never taking more than you give. 9f7e74904Sdrh# 10f7e74904Sdrh#*********************************************************************** 11f7e74904Sdrh# 12f7e74904Sdrh# Test cases for corrupt database files. 13f7e74904Sdrh 14f7e74904Sdrhset testdir [file dirname $argv0] 15f7e74904Sdrhsource $testdir/tester.tcl 16f7e74904Sdrh 17f7e74904Sdrhifcapable !deserialize { 18f7e74904Sdrh finish_test 19f7e74904Sdrh return 20f7e74904Sdrh} 216301c43fSdrhdatabase_may_be_corrupt 22f7e74904Sdrh 231641f11fSdrh# In the following database file, there is 384 bytes of free space 241641f11fSdrh# on page 8 that does not appear on the freeblock list. 251641f11fSdrh# 26f7e74904Sdrhdo_test dbfuzz001-100 { 27f7e74904Sdrh sqlite3 db {} 28f7e74904Sdrh db deserialize [decode_hexdb { 29f7e74904Sdrh | size 5632 pagesize 512 filename c4.db 30f7e74904Sdrh | page 1 offset 0 31f7e74904Sdrh | 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. 32f7e74904Sdrh | 16: 02 00 01 01 00 40 20 20 00 00 00 02 00 00 00 0b .....@ ........ 33f7e74904Sdrh | 32: 00 00 00 06 00 00 00 01 00 00 00 28 00 00 00 04 ...........(.... 34f7e74904Sdrh | 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ................ 35f7e74904Sdrh | 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 ................ 36f7e74904Sdrh | 96: 00 2e 30 38 0d 00 00 00 06 01 06 00 01 da 01 b0 ..08............ 37f7e74904Sdrh | 112: 01 56 01 86 01 2a 01 06 00 00 00 00 00 00 00 00 .V...*.......... 38f7e74904Sdrh | 256: 00 00 00 00 00 00 22 07 06 17 11 11 01 31 74 61 ......"......1ta 39f7e74904Sdrh | 272: 62 6c 65 74 34 74 34 07 43 52 45 41 54 45 20 54 blet4t4.CREATE T 40f7e74904Sdrh | 288: 41 42 4c 45 20 74 34 28 78 29 2a 06 06 17 13 11 ABLE t4(x)*..... 41f7e74904Sdrh | 304: 01 3f 69 6e 64 65 78 00 00 00 00 00 00 00 00 00 .?index......... 42f7e74904Sdrh | 336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e t3(x).......Ein 43f7e74904Sdrh | 352: 64 65 78 74 32 63 64 74 32 05 43 52 45 41 54 45 dext2cdt2.CREATE 44f7e74904Sdrh | 368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74 INDEX t2cd ON t 45f7e74904Sdrh | 384: 32 28 63 2c 64 29 28 05 06 17 11 11 01 3d 74 61 2(c,d)(......=ta 46f7e74904Sdrh | 400: 62 6c 65 74 33 74 33 04 43 52 45 41 54 45 20 54 blet3t3.CREATE T 47f7e74904Sdrh | 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f) 48f7e74904Sdrh | 432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74 (......=tablet2t 49f7e74904Sdrh | 448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 2.CREATE TABLE t 50f7e74904Sdrh | 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$..... 51f7e74904Sdrh | 480: 01 35 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 .5tablet1t1.CREA 52f7e74904Sdrh | 496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 29 TE TABLE t1(a,b) 53f7e74904Sdrh | page 2 offset 512 54f7e74904Sdrh | 0: 0d 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ................ 55f7e74904Sdrh | page 3 offset 1024 56f7e74904Sdrh | 0: 0d 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ................ 57f7e74904Sdrh | page 4 offset 1536 58f7e74904Sdrh | 0: 05 00 00 00 03 01 f1 00 00 00 00 0b 01 fb 01 f6 ................ 59f7e74904Sdrh | 16: 01 f1 00 16 00 00 09 06 05 01 01 01 01 04 04 03 ................ 60f7e74904Sdrh | 32: 03 07 05 05 01 01 09 09 02 02 19 04 05 17 17 17 ................ 61f7e74904Sdrh | 48: 17 73 65 76 65 6e 65 69 67 68 74 65 69 67 68 74 .seveneighteight 62f7e74904Sdrh | 64: 73 65 76 65 6e 25 03 05 07 07 07 07 40 14 00 00 seven%......@... 63f7e74904Sdrh | 80: 00 00 00 00 40 18 00 00 00 00 00 00 40 18 00 00 ....@.......@... 64f7e74904Sdrh | 96: 00 00 00 00 40 14 00 00 00 00 00 00 09 02 05 01 ....@........... 65f7e74904Sdrh | 112: 01 01 01 03 04 04 03 07 01 05 09 01 01 09 02 02 ................ 66f7e74904Sdrh | 352: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1a ................ 67f7e74904Sdrh | 496: 00 00 00 00 0a 3e 00 00 00 09 21 00 00 00 08 06 .....>....!..... 68f7e74904Sdrh | page 5 offset 2048 69f7e74904Sdrh | 0: 0a 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ................ 70f7e74904Sdrh | page 7 offset 3072 71f7e74904Sdrh | 0: 0d 00 00 00 08 01 c2 00 01 fb 01 f6 01 f1 01 ec ................ 72f7e74904Sdrh | 16: 01 e0 01 d4 01 cb 01 c2 00 00 00 00 00 00 00 00 ................ 73f7e74904Sdrh | 96: 00 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 ................ 74f7e74904Sdrh | 224: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 ................ 75f7e74904Sdrh | 288: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 03 ................ 76f7e74904Sdrh | 448: 00 00 07 08 02 17 65 69 67 68 74 07 07 02 17 65 ......eight....e 77f7e74904Sdrh | 464: 69 67 68 74 0a 06 02 07 40 18 00 00 00 00 00 00 ight....@....... 78f7e74904Sdrh | 480: 0a 05 02 07 40 18 00 00 00 00 00 00 03 04 02 01 ....@........... 79f7e74904Sdrh | 496: 04 03 03 02 01 04 03 02 02 01 02 03 01 02 01 02 ................ 80f7e74904Sdrh | page 8 offset 3584 81f7e74904Sdrh | 0: 0d 00 21 00 01 00 16 00 00 16 00 16 00 16 00 16 ..!............. 82f7e74904Sdrh | 16: 00 16 00 16 00 00 09 06 05 01 01 01 01 04 04 03 ................ 83f7e74904Sdrh | 32: 03 00 00 00 5f 01 09 09 02 02 00 00 00 56 17 17 ...._........V.. 84f7e74904Sdrh | 48: 17 73 65 76 65 6e 65 69 67 68 74 65 69 67 68 74 .seveneighteight 85f7e74904Sdrh | 64: 73 65 76 65 6e 00 00 00 3b 07 07 07 40 14 00 00 seven...;...@... 86f7e74904Sdrh | 80: 00 00 00 00 40 18 00 00 00 00 00 00 40 18 00 00 ....@.......@... 87f7e74904Sdrh | 96: 00 00 00 00 40 14 00 00 00 00 00 00 00 00 00 14 ....@........... 88f7e74904Sdrh | 112: 01 01 01 03 04 04 03 00 00 00 09 01 01 09 02 02 ................ 89f7e74904Sdrh | 352: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1a ................ 90f7e74904Sdrh | page 9 offset 4096 91f7e74904Sdrh | 0: 0d 00 00 00 1b 00 47 00 01 d9 01 be 01 af 01 a0 ......G......... 92f7e74904Sdrh | 16: 01 91 01 82 01 73 01 64 01 55 01 46 01 37 01 28 .....s.d.U.F.7.( 93f7e74904Sdrh | 32: 01 19 01 0a 00 fb 00 ec 00 dd 00 ce 00 bf 00 b0 ................ 94f7e74904Sdrh | 48: 00 a1 00 92 00 83 00 74 00 65 00 56 00 47 00 00 .......t.e.V.G.. 95f7e74904Sdrh | 64: 00 00 00 00 00 00 00 0d 21 00 00 48 01 54 00 01 ........!..H.T.. 96f7e74904Sdrh | 80: f7 01 ec 01 c5 01 0d 20 00 00 48 01 54 00 01 f7 ....... ..H.T... 97f7e74904Sdrh | 96: 01 ec 01 c5 01 0d 1f 00 00 48 01 54 00 01 f7 01 .........H.T.... 98f7e74904Sdrh | 112: ec 01 c5 01 0d 1e 00 00 48 01 54 00 01 f7 01 ec ........H.T..... 99f7e74904Sdrh | 128: 01 c5 01 0d 1d 00 00 48 01 54 00 01 f7 01 ec 01 .......H.T...... 100f7e74904Sdrh | 144: c5 01 0d 1c 00 00 48 01 54 00 01 f7 01 ec 01 c5 ......H.T....... 101f7e74904Sdrh | 160: 01 0d 1b 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 .....H.T........ 102f7e74904Sdrh | 176: 0d 1a 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d ....H.T......... 103f7e74904Sdrh | 192: 19 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 18 ...H.T.......... 104f7e74904Sdrh | 208: 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 17 00 ..H.T........... 105f7e74904Sdrh | 224: 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 16 00 00 .H.T............ 106f7e74904Sdrh | 240: 48 01 54 00 01 f7 01 ec 01 c5 01 0d 15 00 00 48 H.T............H 107f7e74904Sdrh | 256: 01 54 00 01 f7 01 ec 01 c5 01 0d 14 00 00 48 01 .T............H. 108f7e74904Sdrh | 272: 54 00 01 f7 01 ec 01 c5 01 0d 13 00 00 48 01 54 T............H.T 109f7e74904Sdrh | 288: 00 01 f7 01 ec 01 c5 01 0d 12 00 00 48 01 54 00 ............H.T. 110f7e74904Sdrh | 304: 01 f7 01 ec 01 c5 01 0d 11 00 00 48 01 54 00 01 ...........H.T.. 111f7e74904Sdrh | 320: f7 01 ec 01 c5 01 0d 10 00 00 48 01 54 00 01 f7 ..........H.T... 112f7e74904Sdrh | 336: 01 ec 01 c5 01 0d 0f 00 00 48 01 54 00 01 f7 01 .........H.T.... 113f7e74904Sdrh | 352: ec 01 c5 01 0d 0e 00 00 48 01 54 00 01 f7 01 ec ........H.T..... 114f7e74904Sdrh | 368: 01 c5 01 0d 0d 00 00 48 01 54 00 01 f7 01 ec 01 .......H.T...... 115f7e74904Sdrh | 384: c5 01 0d 0c 00 00 48 01 54 00 01 f7 01 ec 01 c5 ......H.T....... 116f7e74904Sdrh | 400: 01 0d 0b 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 .....H.T........ 117f7e74904Sdrh | 416: 0d 0a 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d ....H.T......... 118f7e74904Sdrh | 432: 09 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 19 08 ...H.T.......... 119f7e74904Sdrh | 448: 05 17 17 17 17 65 69 67 68 74 65 69 67 68 74 73 .....eighteights 120f7e74904Sdrh | 464: 65 76 65 6e 73 65 76 65 6e 25 07 05 07 07 07 07 evenseven%...... 121f7e74904Sdrh | 480: 40 18 00 00 00 00 00 00 40 18 00 00 00 00 00 00 @.......@....... 122f7e74904Sdrh | 496: 40 14 00 00 00 00 00 00 40 14 00 00 00 00 00 00 @.......@....... 123f7e74904Sdrh | page 10 offset 4608 124f7e74904Sdrh | 0: 0d 00 00 00 1d 00 4d 00 01 f1 01 e2 01 d3 01 c4 ......M......... 125f7e74904Sdrh | 16: 01 b5 01 a6 01 97 01 88 01 79 01 6a 01 5b 01 4c .........y.j.[.L 126f7e74904Sdrh | 32: 01 3d 01 2e 01 1f 01 10 01 01 00 f2 00 e3 00 d4 .=.............. 127f7e74904Sdrh | 48: 00 c5 00 b6 00 a7 00 98 00 89 00 7a 00 6b 00 5c ...........z.k.\ 128f7e74904Sdrh | 64: 00 4d 00 00 00 00 00 00 00 00 00 00 00 0d 3e 00 .M............>. 129f7e74904Sdrh | 80: 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 3d 00 00 .H.T.........=.. 130f7e74904Sdrh | 96: 48 01 54 00 01 f7 01 ec 01 c5 01 0d 3c 00 00 48 H.T.........<..H 131f7e74904Sdrh | 112: 01 54 00 01 f7 01 ec 01 c5 01 0d 3b 00 00 48 01 .T.........;..H. 132f7e74904Sdrh | 128: 54 00 01 f7 01 ec 01 c5 01 0d 3a 00 00 48 01 54 T.........:..H.T 133f7e74904Sdrh | 144: 00 01 f7 01 ec 01 c5 01 0d 39 00 00 48 01 54 00 .........9..H.T. 134f7e74904Sdrh | 160: 01 f7 01 ec 01 c5 01 0d 38 00 00 48 01 54 00 01 ........8..H.T.. 135f7e74904Sdrh | 176: f7 01 ec 01 c5 01 0d 37 00 00 48 01 54 00 01 f7 .......7..H.T... 136f7e74904Sdrh | 192: 01 ec 01 c5 01 0d 36 00 00 48 01 54 00 01 f7 01 ......6..H.T.... 137f7e74904Sdrh | 208: ec 01 c5 01 0d 35 00 00 48 01 54 00 01 f7 01 ec .....5..H.T..... 138f7e74904Sdrh | 224: 01 c5 01 0d 34 00 00 48 01 54 00 01 f7 01 ec 01 ....4..H.T...... 139f7e74904Sdrh | 240: c5 01 0d 33 00 00 48 01 54 00 01 f7 01 ec 01 c5 ...3..H.T....... 140f7e74904Sdrh | 256: 01 0d 32 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 ..2..H.T........ 141f7e74904Sdrh | 272: 0d 31 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d .1..H.T......... 142f7e74904Sdrh | 288: 30 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 2f 0..H.T........./ 143f7e74904Sdrh | 304: 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 2e 00 ..H.T........... 144f7e74904Sdrh | 320: 00 48 01 54 00 01 f7 01 ec 01 c5 01 0d 2d 00 00 .H.T.........-.. 145f7e74904Sdrh | 336: 48 01 54 00 01 f7 01 ec 01 c5 01 0d 2c 00 00 48 H.T.........,..H 146f7e74904Sdrh | 352: 01 54 00 01 f7 01 ec 01 c5 01 0d 2b 00 00 48 01 .T.........+..H. 147f7e74904Sdrh | 368: 54 00 01 f7 01 ec 01 c5 01 0d 2a 00 00 48 01 54 T.........*..H.T 148f7e74904Sdrh | 384: 00 01 f7 01 ec 01 c5 01 0d 29 00 00 48 01 54 00 .........)..H.T. 149f7e74904Sdrh | 400: 01 f7 01 ec 01 c5 01 0d 28 00 00 48 01 54 00 01 ........(..H.T.. 150f7e74904Sdrh | 416: f7 01 ec 01 c5 01 0d 27 00 00 48 01 54 00 01 f7 .......'..H.T... 151f7e74904Sdrh | 432: 01 ec 01 c5 01 0d 26 00 00 48 01 54 00 01 f7 01 ......&..H.T.... 152f7e74904Sdrh | 448: ec 01 c5 01 0d 25 00 00 48 01 54 00 01 f7 01 ec .....%..H.T..... 153f7e74904Sdrh | 464: 01 c5 01 0d 24 00 00 48 01 54 00 01 f7 01 ec 01 ....$..H.T...... 154f7e74904Sdrh | 480: c5 01 0d 23 00 00 48 01 54 00 01 f7 01 ec 01 c5 ...#..H.T....... 155f7e74904Sdrh | 496: 01 0d 22 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 .."..H.T........ 156f7e74904Sdrh | page 11 offset 5120 157f7e74904Sdrh | 0: 0d 00 00 00 0a 01 6a 00 01 f1 01 e2 01 d3 01 c4 ......j......... 158f7e74904Sdrh | 16: 01 b5 01 a6 01 97 01 88 01 79 01 6a 00 00 00 00 .........y.j.... 159f7e74904Sdrh | 352: 00 00 00 00 00 00 00 00 00 00 0d 48 00 00 48 01 ...........H..H. 160f7e74904Sdrh | 368: 54 00 01 f7 01 ec 01 c5 01 0d 47 00 00 48 01 54 T.........G..H.T 161f7e74904Sdrh | 384: 00 01 f7 01 ec 01 c5 01 0d 46 00 00 48 01 54 00 .........F..H.T. 162f7e74904Sdrh | 400: 01 f7 01 ec 01 c5 01 0d 45 00 00 48 01 54 00 01 ........E..H.T.. 163f7e74904Sdrh | 416: f7 01 ec 01 c5 01 0d 44 00 00 48 01 54 00 01 f7 .......D..H.T... 164f7e74904Sdrh | 432: 01 ec 01 c5 01 0d 43 00 00 48 01 54 00 01 f7 01 ......C..H.T.... 165f7e74904Sdrh | 448: ec 01 c5 01 0d 42 00 00 48 01 54 00 01 f7 01 ec .....B..H.T..... 166f7e74904Sdrh | 464: 01 c5 01 0d 41 00 00 48 01 54 00 01 f7 01 ec 01 ....A..H.T...... 167f7e74904Sdrh | 480: c5 01 0d 40 00 00 48 01 54 00 01 f7 01 ec 01 c5 [email protected]....... 168f7e74904Sdrh | 496: 01 0d 3f 00 00 48 01 54 00 01 f7 01 ec 01 c5 01 ..?..H.T........ 169f7e74904Sdrh | end c4.db 170f7e74904Sdrh }] 1716e08c4a5Sdan} {} 1726e08c4a5Sdan 1736e08c4a5Sdanifcapable !oversize_cell_check { 1746e08c4a5Sdan # Non SQLITE_ENABLE_OVERSIZE_CELL_CHECK builds: 1756e08c4a5Sdan do_test dbfuzz001-101a { 17669ab18d2Sdrh db eval {PRAGMA writable_schema=on; PRAGMA integrity_check} 177f7e74904Sdrh } {/Fragmentation of 384 bytes reported as 0 on page 8/} 1786e08c4a5Sdan} else { 1796e08c4a5Sdan # SQLITE_ENABLE_OVERSIZE_CELL_CHECK builds: 1806e08c4a5Sdan do_catchsql_test dbfuzz001-101b { 1816e08c4a5Sdan PRAGMA writable_schema=on; 1826e08c4a5Sdan PRAGMA integrity_check; 1836e08c4a5Sdan } {1 {database disk image is malformed}} 1846e08c4a5Sdan} 185f7e74904Sdrh 1861641f11fSdrh# The DELETE query below deletes the very last cell from page 8. 1871641f11fSdrh# Prior to a certain fix to sqlite3BtreeDelete() and because of the 1881641f11fSdrh# corruption to the freeblock list on page 8, this would fail to 1891641f11fSdrh# cause a rebalance operation, which would leave the btree in a weird 1901641f11fSdrh# state that would lead to segfaults and or assertion faults. 1911641f11fSdrh# 192e2081dd8Sdando_execsql_test dbfuzz001-110 { 1931641f11fSdrh DELETE FROM t3 WHERE x IS NOT NULL AND +rowid=6; 194e2081dd8Sdan} {} 1951641f11fSdrh 1966301c43fSdrh# This is a dbfuzz2-generate test case that can cause a page with 1976301c43fSdrh# pPage->nCell==0 to enter the balancer. 1986301c43fSdrh# 1996301c43fSdrhdo_test dbfuzz001-200 { 2006301c43fSdrh db deserialize [decode_hexdb { 2016301c43fSdrh | size 3076 pagesize 512 filename c03.db 2026301c43fSdrh | page 1 offset 0 2036301c43fSdrh | 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. 2046301c43fSdrh | 16: 02 00 01 01 00 40 20 20 00 00 00 0c 00 00 00 07 .....@ ........ 2056301c43fSdrh | 32: 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 04 ................ 2066301c43fSdrh | 48: 00 00 00 00 00 00 00 03 e8 00 00 01 00 00 00 00 ................ 2076301c43fSdrh | 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c ................ 2086301c43fSdrh | 96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0 ..,P............ 2096301c43fSdrh | 112: 01 56 01 86 01 2a 01 06 00 00 00 00 00 00 00 00 .V...*.......... 2106301c43fSdrh | 128: 00 00 00 00 00 00 00 00 ef 00 00 00 00 00 00 00 ................ 2116301c43fSdrh | 192: 00 7f 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 2126301c43fSdrh | 224: 00 00 00 00 00 00 00 00 00 00 00 00 00 ff e9 00 ................ 2136301c43fSdrh | 256: 00 00 00 00 00 00 22 07 06 17 11 11 01 31 74 61 ......"......1ta 2146301c43fSdrh | 272: 62 6c 65 74 34 74 34 07 43 52 45 41 54 45 20 54 blet4t4.CREATE T 2156301c43fSdrh | 288: 41 42 4c 45 20 74 34 28 78 29 2a 06 06 17 13 11 ABLE t4(x)*..... 2166301c43fSdrh | 304: 01 3f 69 6e 64 65 78 74 33 78 74 33 06 43 52 45 .?indext3xt3.CRE 2176301c43fSdrh | 320: 41 54 45 20 49 4e 44 45 58 20 74 33 64 20 4f 4e ATE INDEX t3d ON 2186301c43fSdrh | 336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e t3(x).......Ein 2196301c43fSdrh | 352: 64 65 78 74 32 63 64 74 32 05 43 52 45 41 54 45 dext2cdt2.CREATE 2206301c43fSdrh | 368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74 INDEX t2cd ON t 2216301c43fSdrh | 384: 32 28 63 2c 64 29 28 05 06 17 11 11 01 3d 74 61 2(c,d)(......=ta 2226301c43fSdrh | 400: 62 6c 65 74 33 74 33 04 43 52 45 41 54 45 20 54 blet3t3.CREATE T 2236301c43fSdrh | 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f) 2246301c43fSdrh | 432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74 (......=tablet2t 2256301c43fSdrh | 448: 32 03 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 2.CREATE TABLE t 2266301c43fSdrh | 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$..... 2276301c43fSdrh | 480: 01 35 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 .5tablet1t1.CREA 2286301c43fSdrh | 496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 29 TE TABLE t1(a,b) 2296301c43fSdrh | page 2 offset 512 2306301c43fSdrh | 0: 0d 00 00 00 04 01 cf 00 01 fa 01 f3 01 de 01 cf ................ 2316301c43fSdrh | 176: 10 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 2326301c43fSdrh | 256: 00 00 14 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 2336301c43fSdrh | 368: 00 00 00 00 00 00 00 00 00 00 00 00 1e 00 00 00 ................ 2346301c43fSdrh | 416: 00 00 00 1b 00 00 00 00 04 00 00 00 00 00 00 00 ................ 2356301c43fSdrh | 448: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d ................ 2366301c43fSdrh | 464: 04 03 17 17 73 65 76 65 6e 65 69 67 68 74 13 03 ....seveneight.. 2376301c43fSdrh | 480: 03 07 07 40 14 00 00 00 00 00 00 40 18 00 00 00 ...@.......@.... 2386301c43fSdrh | 496: 00 00 00 05 02 03 01 01 03 04 04 01 03 09 01 02 ................ 2396301c43fSdrh | page 3 offset 1024 2406301c43fSdrh | 0: 0d 00 00 00 08 01 54 00 01 f7 01 ec 01 c5 01 aa ......T......... 2416301c43fSdrh | 16: 01 a1 01 96 01 6f 01 54 00 00 00 00 00 00 00 00 .....o.T........ 2426301c43fSdrh | 32: 00 00 00 00 00 00 00 03 e8 00 00 00 00 00 00 00 ................ 2436301c43fSdrh | 336: 00 00 00 00 19 08 05 16 17 17 17 65 69 67 68 74 ...........eight 2446301c43fSdrh | 352: 65 69 67 68 74 73 65 76 65 6e 73 65 76 ff ff ff eightsevensev... 2456301c43fSdrh | 368: 0e 05 07 07 07 07 40 18 00 00 00 00 00 00 40 18 ......@.......@. 2466301c43fSdrh | 384: 00 00 00 00 00 00 40 14 00 00 00 00 00 00 40 14 ......@.......@. 2476301c43fSdrh | 400: 00 00 00 00 00 00 09 06 05 01 01 01 01 04 04 03 ................ 2486301c43fSdrh | 416: 03 07 05 05 01 01 09 09 02 02 19 04 05 17 17 17 ................ 2496301c43fSdrh | 432: 17 73 65 6f 65 6e 65 69 67 68 74 65 69 67 68 74 .seoeneighteight 2506301c43fSdrh | 448: 73 65 76 65 6e 25 03 05 07 07 07 07 40 14 00 00 seven%......@... 2516301c43fSdrh | 464: 00 00 00 00 40 18 00 00 00 00 00 00 40 18 00 00 ....@.......@... 2526301c43fSdrh | 480: 00 00 00 00 40 14 00 00 00 00 00 00 09 02 05 01 ....@........... 2536301c43fSdrh | 496: 01 01 01 03 04 04 03 07 01 05 09 01 01 09 02 02 ................ 2546301c43fSdrh | page 4 offset 1536 2556301c43fSdrh | 0: 0d 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 ................ 2566301c43fSdrh | 160: 00 00 00 ea 00 00 00 00 00 00 00 00 00 00 00 00 ................ 2576301c43fSdrh | 336: 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 00 ............ ... 2586301c43fSdrh | page 5 offset 2048 2596301c43fSdrh | 0: 0a 00 00 00 08 01 96 00 01 fa 01 c4 01 f2 01 bc ................ 2606301c43fSdrh | 16: 01 dc 01 a6 01 96 01 cc 00 00 00 00 00 00 00 00 ................ 2616301c43fSdrh | 48: 00 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 ................ 2626301c43fSdrh | 288: 00 00 00 00 00 00 00 00 00 64 00 00 00 2b 00 00 .........d...+.. 2636301c43fSdrh | 400: 00 00 00 00 00 00 0f 04 17 17 01 65 69 67 68 74 ...........eight 2646301c43fSdrh | 416: 65 69 6f 68 74 08 15 04 07 07 01 40 18 00 00 00 eioht......@.... 2656301c43fSdrh | 432: 00 00 00 40 18 00 00 00 00 00 00 07 07 04 01 01 ...@............ 2666301c43fSdrh | 448: 01 04 04 06 07 04 01 01 01 02 02 05 0f 04 17 17 ................ 2676301c43fSdrh | 464: 01 73 65 76 65 6e 65 69 67 68 74 04 15 04 07 07 .seveneight..... 2686301c43fSdrh | 480: 01 40 14 00 00 00 00 00 00 40 18 00 00 00 00 00 .@.......@...... 2696301c43fSdrh | 496: 00 03 07 04 01 01 01 03 04 02 05 04 09 01 09 02 ................ 2706301c43fSdrh | page 6 offset 2560 2716301c43fSdrh | 0: 0a 00 00 00 00 02 00 00 00 00 00 00 00 0d 00 00 ................ 2726301c43fSdrh | 16: 00 08 01 c2 00 01 fb 01 f6 01 f1 01 ec 01 e0 01 ................ 2736301c43fSdrh | 32: d4 01 cb 01 c2 00 00 00 00 00 00 00 00 00 00 00 ................ 2746301c43fSdrh | 160: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 ................ 2756301c43fSdrh | 448: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07 ................ 2766301c43fSdrh | 464: 08 02 17 65 69 67 68 74 07 07 02 17 65 69 67 68 ...eight....eigh 2776301c43fSdrh | 480: 74 0a 06 02 07 40 18 00 00 00 00 00 00 0a 05 02 t....@.......... 2786301c43fSdrh | 496: 07 40 18 00 04 02 01 04 03 03 02 01 04 03 02 02 .@.............. 2796301c43fSdrh | end x/c03.db 2806301c43fSdrh }] 2816301c43fSdrh catchsql {INSERT INTO t3 SELECT * FROM t2;} 2826301c43fSdrh} {1 {database disk image is malformed}} 2836301c43fSdrh 284fffaf230Sdan 2856e08c4a5Sdando_test dbfuzz001-310 { 286fffaf230Sdan sqlite3 db {} 287fffaf230Sdan db deserialize [decode_hexdb { 288fffaf230Sdan| size 3584 pagesize 512 filename x/c02.db 289fffaf230Sdan| page 1 offset 0 290fffaf230Sdan| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00 SQLite format 3. 291fffaf230Sdan| 16: 02 00 01 01 00 40 20 20 00 00 00 0c 00 00 00 07 .....@ ........ 292fffaf230Sdan| 32: 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 04 ................ 293fffaf230Sdan| 48: 00 00 00 00 00 00 00 04 00 00 00 01 00 00 00 00 ................ 294fffaf230Sdan| 80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0c ................ 295fffaf230Sdan| 96: 00 2e 2c 50 0d 00 00 00 06 01 06 00 01 da 01 b0 ..,P............ 296fffaf230Sdan| 112: 01 56 01 86 01 2a 01 06 00 00 00 00 00 00 00 00 .V...*.......... 297fffaf230Sdan| 256: 00 00 00 00 00 00 22 07 06 17 11 11 01 31 74 61 ......"......1ta 298fffaf230Sdan| 272: 62 6c 65 74 34 74 34 07 43 52 45 41 54 45 20 54 blet4t4.CREATE T 299fffaf230Sdan| 288: 41 42 4c 45 20 74 34 28 78 29 2a 06 06 17 13 11 ABLE t4(x)*..... 300fffaf230Sdan| 304: 01 3f 69 6e 64 65 78 74 33 78 74 33 05 43 52 45 .?indext3xt3.CRE 301fffaf230Sdan| 320: 41 54 45 20 49 4e 44 45 58 20 74 33 78 20 4f 4e ATE INDEX t3x ON 302fffaf230Sdan| 336: 20 74 33 28 78 29 2e 04 06 17 15 11 01 45 69 6e t3(x).......Ein 303fffaf230Sdan| 352: 64 65 78 74 32 63 64 74 32 05 43 52 45 41 54 45 dext2cdt2.CREATE 304fffaf230Sdan| 368: 20 49 4e 44 45 58 20 74 32 63 64 20 4f 4e 20 74 INDEX t2cd ON t 305fffaf230Sdan| 384: 32 28 63 2c 64 29 28 05 06 17 11 11 01 3d 74 61 2(c,d)(......=ta 306fffaf230Sdan| 400: 62 6c 65 74 33 74 33 07 43 52 45 41 54 45 20 54 blet3t3.CREATE T 307fffaf230Sdan| 416: 41 42 4c 45 20 74 33 28 63 2c 78 2c 65 2c 66 29 ABLE t3(c,x,e,f) 308c5a93d4cSdrh| 432: 28 02 06 17 11 11 01 3d 74 61 62 6c 65 74 32 74 (......=tablet2t 309fffaf230Sdan| 448: 32 32 43 52 45 41 54 45 20 54 41 42 4c 45 20 74 22CREATE TABLE t 310fffaf230Sdan| 464: 32 28 63 2c 64 2c 65 2c 66 29 24 01 06 17 11 11 2(c,d,e,f)$..... 311fffaf230Sdan| 480: 01 35 74 61 62 6c 65 74 31 74 31 02 43 52 45 41 .5tablet1t1.CREA 312fffaf230Sdan| 496: 54 45 20 54 41 42 4c 45 20 74 31 28 61 2c 62 29 TE TABLE t1(a,b) 313fffaf230Sdan| page 2 offset 512 314fffaf230Sdan| 0: 0d 00 00 00 04 01 cf 00 01 fa 01 f3 01 de 01 cf ................ 315fffaf230Sdan| 160: 00 00 20 00 00 00 00 00 00 00 00 00 00 00 00 00 .. ............. 316fffaf230Sdan| 448: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 0d ................ 317fffaf230Sdan| 464: 04 03 17 17 73 65 76 65 6e 65 69 67 68 74 13 03 ....seveneight.. 318fffaf230Sdan| 480: 03 07 07 40 14 00 00 00 00 00 00 40 18 00 00 00 ...@.......@.... 319fffaf230Sdan| 496: 00 00 00 05 02 03 01 01 03 04 04 01 03 09 01 02 ................ 320fffaf230Sdan| page 3 offset 1024 321fffaf230Sdan| 0: 0d 00 00 00 08 01 54 00 01 f7 01 ec 01 c5 01 aa ......T......... 322fffaf230Sdan| 16: 01 a1 01 96 01 6f 01 54 00 00 00 00 00 00 00 00 .....o.T........ 323fffaf230Sdan| 112: 00 00 dd 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 324fffaf230Sdan| 336: 00 00 00 00 19 08 05 17 17 17 17 65 69 67 68 74 ...........eight 325fffaf230Sdan| 352: 65 69 67 68 74 73 65 76 65 6e 73 65 76 65 6e 25 eightsevenseven% 326fffaf230Sdan| 368: 07 05 07 07 07 07 40 18 00 00 00 00 00 00 40 18 ......@.......@. 327fffaf230Sdan| 384: 00 00 00 00 00 00 40 14 00 00 00 00 00 00 40 14 ......@.......@. 328fffaf230Sdan| 400: 00 00 00 00 00 00 09 06 05 01 01 01 01 04 04 03 ................ 329fffaf230Sdan| 416: 03 07 05 05 01 01 09 09 02 02 19 04 05 17 17 17 ................ 330fffaf230Sdan| 432: 17 73 65 76 65 6e 65 69 67 68 74 65 69 67 68 74 .seveneighteight 331fffaf230Sdan| 448: 73 65 76 65 6e 25 03 05 07 07 07 07 40 14 00 00 seven%......@... 332fffaf230Sdan| 464: 00 00 00 00 40 18 00 00 00 00 00 00 40 18 00 00 ....@.......@... 333fffaf230Sdan| 480: 00 00 00 00 40 14 00 00 00 00 00 00 09 02 05 01 ....@........... 334fffaf230Sdan| 496: 01 01 01 03 04 04 03 07 01 05 09 01 01 09 02 02 ................ 335fffaf230Sdan| page 4 offset 1536 336fffaf230Sdan| 0: 0d 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ................ 337fffaf230Sdan| 192: 00 00 00 00 00 00 7f 00 00 00 00 00 00 00 00 00 ................ 338fffaf230Sdan| 208: 00 e5 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 339fffaf230Sdan| page 5 offset 2048 340fffaf230Sdan| 0: 0a 00 00 00 08 01 96 00 01 fa 01 c4 01 f2 01 bc ................ 341fffaf230Sdan| 16: 01 dc 01 a6 01 96 01 cc 00 00 00 00 00 00 00 00 ................ 342fffaf230Sdan| 240: 00 00 00 00 00 00 00 00 00 00 00 00 00 0e 00 00 ................ 343fffaf230Sdan| 400: 00 00 00 00 00 00 0f 04 17 07 01 65 69 67 68 74 ...........eight 344fffaf230Sdan| 416: 65 69 67 68 74 08 15 04 07 07 01 40 18 00 00 00 eight......@.... 345fffaf230Sdan| 432: 00 00 00 40 18 00 00 00 00 00 00 07 07 04 01 01 ...@............ 346fffaf230Sdan| 448: 01 04 04 06 07 04 01 01 01 02 02 05 0f 04 17 17 ................ 347fffaf230Sdan| 464: 01 73 65 76 65 6e 65 69 67 68 74 04 15 04 07 07 .seveneight..... 348fffaf230Sdan| 480: 01 40 14 00 00 00 00 00 00 40 18 00 00 00 00 00 .@.......@...... 349fffaf230Sdan| 496: 00 03 07 04 01 01 01 03 04 02 05 04 09 01 09 02 ................ 350fffaf230Sdan| page 6 offset 2560 351fffaf230Sdan| 0: 0a 00 00 00 00 02 00 00 00 00 00 00 00 00 00 00 ................ 352fffaf230Sdan| 464: 00 00 00 00 00 00 00 00 00 00 7f 00 00 00 00 00 ................ 353fffaf230Sdan| page 7 offset 3072 354fffaf230Sdan| 0: 0d 00 00 00 08 01 c2 00 01 fb 01 f6 01 f1 01 ec ................ 355fffaf230Sdan| 16: 01 e0 01 d4 01 cb 01 c2 00 00 00 00 00 00 00 00 ................ 356fffaf230Sdan| 448: 00 00 07 08 02 17 65 69 67 68 74 07 07 02 17 65 ......eight....e 357fffaf230Sdan| 464: 69 67 68 74 0a 06 02 07 40 18 00 00 00 00 00 00 ight....@....... 358fffaf230Sdan| 480: 0a 05 02 07 40 18 00 00 00 00 00 00 03 04 02 01 ....@........... 359fffaf230Sdan| 496: 04 03 03 02 01 04 03 02 02 01 02 03 01 02 01 02 ................ 360fffaf230Sdan| end x/c02.db 361fffaf230Sdan }] 362fffaf230Sdan} {} 363fffaf230Sdan 364*ca439a49Sdrhextra_schema_checks 0 3656e08c4a5Sdando_catchsql_test dbfuzz001-320 { 366b0c4c949Sdan PRAGMA integrity_check; 367b0c4c949Sdan} {1 {database disk image is malformed}} 368b0c4c949Sdan 3696e08c4a5Sdando_catchsql_test dbfuzz001-330 { 370b0c4c949Sdan DELETE FROM t3 WHERE x IN (SELECT x FROM t4); 371b0c4c949Sdan} {1 {database disk image is malformed}} 372*ca439a49Sdrhextra_schema_checks 1 373b0c4c949Sdan 374f7e74904Sdrhfinish_test 375