Improve the ".recover" command so that it handles intkey pages linked into non-intkey b-trees, and vice-versa, better.

FossilOrigin-Name: 9c458acba5a100a76148a3efb78ea9f57b85751e80788e4532694bd8976608a0
This commit is contained in:
dan 2019-07-24 20:10:27 +00:00
parent 01c08bcacd
commit 9443dbc493
3 changed files with 23 additions and 11 deletions

View File

@ -1,5 +1,5 @@
C Improve\sthe\s".recover"\scommand's\shandling\sof\scorrupt\sdatabase\sschemas.
D 2019-07-24T19:20:30.855
C Improve\sthe\s".recover"\scommand\sso\sthat\sit\shandles\sintkey\spages\slinked\sinto\snon-intkey\sb-trees,\sand\svice-versa,\sbetter.
D 2019-07-24T20:10:27.248
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -523,7 +523,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384
F src/resolve.c edf29463177e9fa9dad5346e9adf482f24db9f180c693d0ba993e25dc797f6b7
F src/rowset.c d977b011993aaea002cab3e0bb2ce50cf346000dff94e944d547b989f4b1fe93
F src/select.c 9817d812b13c956ac28d27390602751a8add217f87224d2636fb3ef7e4d646a7
F src/shell.c.in 8bc78eac52d6b5adc304202eb7e5ac9030b60c4acf6afab17dd2d670bdc5ff46
F src/shell.c.in 9c203a8c643fd638ab67a911e1fad1f51138c13a4d0ea3cedf7526fba5de60f2
F src/sqlite.h.in 83ebc8ab1a2e82d92214006ea2c15bf8a0604f3fac2c31dd9ce9021f568c71f2
F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8
F src/sqlite3ext.h 9ecc93b8493bd20c0c07d52e2ac0ed8bab9b549c7f7955b59869597b650dd8b5
@ -1837,7 +1837,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
P 87d76047d6a3df31bc9b7c0cffa7b758236c124f87263a520850b019cbbc4c6e
R f8528eeb79eb9ec604f822a0670c03c6
P becaaa4d29d17ad613f2a120f0b173e53403b3de26f22beaf83f66ebf369bf60
R 94d74886c98500c187a9db329f6aede4
U dan
Z c89bea65b11e28d9fe37e4838d0f8004
Z 32ff5ab3849650d0809e5271f9614a81

View File

@ -1 +1 @@
becaaa4d29d17ad613f2a120f0b173e53403b3de26f22beaf83f66ebf369bf60
9c458acba5a100a76148a3efb78ea9f57b85751e80788e4532694bd8976608a0

View File

@ -6740,6 +6740,7 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
);
shellPrepare(pState->db, &rc,
"SELECT max(field), group_concat(shell_escape_crnl(quote(value)), ', ')"
", min(field) "
"FROM sqlite_dbdata WHERE pgno = ? AND field != ?"
"GROUP BY cell", &pCells
);
@ -6758,6 +6759,7 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
int bNoop = 0;
RecoverTable *pTab;
assert( bIntkey==0 || bIntkey==1 );
pTab = recoverFindTable(pState, &rc, iRoot, bIntkey, nCol, &bNoop);
if( bNoop || rc ) continue;
if( pTab==0 ){
@ -6779,18 +6781,28 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){
sqlite3_bind_int(pCells, 1, iPgno);
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pCells) ){
int nField = sqlite3_column_int(pCells, 0);
int iMin = sqlite3_column_int(pCells, 2);
const char *zVal = (const char*)sqlite3_column_text(pCells, 1);
RecoverTable *pTab2 = pTab;
if( pTab!=pOrphan && (iMin<0)!=bIntkey ){
if( pOrphan==0 ){
pOrphan = recoverOrphanTable(pState, &rc, zLostAndFound, nOrphan);
}
pTab2 = pOrphan;
if( pTab2==0 ) break;
}
nField = nField+1;
if( pTab==pOrphan ){
if( pTab2==pOrphan ){
raw_printf(pState->out,
"INSERT INTO %s VALUES(%d, %d, %d, %s%s%s);\n",
pTab->zQuoted, iRoot, iPgno, nField,
bIntkey ? "" : "NULL, ", zVal, pTab->azlCol[nField]
pTab2->zQuoted, iRoot, iPgno, nField,
iMin<0 ? "" : "NULL, ", zVal, pTab2->azlCol[nField]
);
}else{
raw_printf(pState->out, "INSERT INTO %s(%s) VALUES( %s );\n",
pTab->zQuoted, pTab->azlCol[nField], zVal
pTab2->zQuoted, pTab2->azlCol[nField], zVal
);
}
}