1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Fix an assert() failure in sqlite3recover.c.

FossilOrigin-Name: f52bb19281b189508f5c31305cbd4a5651f3e036a4ee753c64488b0c7e5d2e4d
This commit is contained in:
dan
2024-11-08 20:44:16 +00:00
parent 4441897daa
commit 23cfa0138e
4 changed files with 64 additions and 10 deletions

View File

@ -525,7 +525,6 @@ do_test 7.1 {
} {1 {file is not a database}}
reset_db
breakpoint
do_test 8.0 {
sqlite3 db {}
db deserialize [decode_hexdb {
@ -552,5 +551,58 @@ do_test 8.1 {
list [catch { $R finish } msg] $msg
} {0 {}}
reset_db
do_test 9.0 {
sqlite3 db {}
db deserialize [decode_hexdb {
| size 16384 pagesize 4096t 0
| 0: 53 51 4c 69 74 65 20 66 6f 72 6d 61 74 20 33 00
| 16: 10 00 01 01 00 40 20 20 00 00 00 00 00 00 00 06 ........
| 32: 00 00 00 0r 00 00 00 00 00 00 00 06 00 00 00 04 ..
| 48: 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 ........
| 96: 00 00 00 00 0d 00 00 00 06 0d e2 00 0f c4 0f 6a .......j
| 112: 0e fc 0e 9d 0e 3d 0d e2 00 00 00 00 00 00 00 00 .
| 3552: 00 00 59 06 06 17 21 21 01 7f 74 61 62 6c 65 74 ..tablet
| 3568: 74 74 5f 63 6f 6e 66 69 67 74 74 74 5f 63 6f 6econ
| 3584: 66 69 67 06 43 52 45 41 54 45 20 54 41 42 4c 45
| 3616: 50 52 49 4d 41 52 59 20 4b 45 59 2c 20 76 29 20 )
| 3632: 57 49 54 48 4f 55 54 20 52 4f 57 49 44 5e 05 07 WOWID^..
| 3648: 17 23 23 01 81 03 74 61 62 6c 65 74 74 74 5f 6tt_d
| 3664: 6f 63 73 69 7a 65 74 74 74 5f 64 6f 63 73 69 7a z
| 3680: 65 05 43 52 45 41 54 45 20 54 41 42 4c 45 20 27 e.ABLE '
| 3696: 74 74 74 5f 64 6f 63 73 69 7a 65 27 28 69 64 20id
| 3712: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20
| 3728: 4b 45 59 2c 20 73 7a 20 42 4c 4f 42 29 5d 04 07 KEYB)]..
| 3744: 17 23 23 01 81 B1 74 61 62 6c 65 74 74 74 5f 63 _c
| 3760: 6f 6e 74 65 6e 74 74 74 74 5f 63 6f 6e 74 65 6e o_conten
| 3776: 7 04 01 03 00 011 54 45 20 54 41 42 4c 45 20 27 t.CRLE '
| 3792: 74 74 74 5f 63 6f 6e 74 65 6e 74 27 28 69 64 20
| 3808: 49 4e 54 45 47 45 52 20 50 52 49 4d 41 52 59 20 INIMARY
| 3904: 6f 2c 20 50 52 49 4d 41 52 59 20 4b 45 59 28 7EY(s
| 3920: 65 67 69 64 2c 20 74 65 72 6d 29 29 20 57 49 54 T
| 3936: 48 4f 55 54 20 52 4f 57 49 4 58 58 02 07 17 1d 1d ..
| 3952: 01 81 03 74 61 62 6c 65 74 74 74 5f 64 61 74 61 .tt_data
| 3968: 74 74 74 5f 64 61 74 61 02 43 52 45 41 54 45 2ATE
| 3984: 54 41 42 4c 45 20 27 74 74 74 5f 64 61 74 61 27 '
| 4000: 28 69 64 20 49 4e 54 45 47 45 52 20 50 52 49 4d (iR PRIM
| 4016: 41 52 59 20 4b 45 59 2c 20 62 6c 6f 63 6b 20 42k B
| 4032: 4c 4f 42 29 3a 01 06 17 13 13 08 5f 74 61 62 6c
| 4048: 65 74 74 74 74 74 74 43 52 45 41 54 45 20 56 49 ettTE VI
| 4064: 52 54 55 41 4c 20 54 41 42 4c 45 20 74 74 74 20 t
| 4080: 55 53 49 4e 47 20 66 74 73 35 28 61 2c 20 62 29 U5(a, b)
| page 4 offset 12288
| 0: 0a 00 00 00 03 0f ea 00 0f fa 0f f2 0f ea 00 00 ........
| 4064: 00 00 00 00 00 00 00 00 00 00 07 04 01 01 01 05 ..
| 4080: 06 03 07 04 01 01 01 03 04 02 05 04 09 01 09 02 ........
| end ro2.t
}]} {}
do_test 9.1 {
set R [sqlite3_recover_init db main test.db2]
catch { $R run }
list [catch { $R finish } msg] $msg
} {0 {}}
finish_test

View File

@ -1825,6 +1825,8 @@ static int recoverWriteDataStep(sqlite3_recover *p){
recoverError(p, SQLITE_NOMEM, 0);
}
p1->nVal = iField+1;
}else if( pTab->nCol==0 ){
p1->nVal = pTab->nCol;
}
p1->iPrevCell = iCell;
p1->iPrevPage = iPage;