From: dan Date: Thu, 9 May 2019 14:15:19 +0000 (+0000) Subject: Have ".recover" handle cases where the sqlite_master table contains malformed SQL... X-Git-Tag: version-3.29.0~125 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9877965f56dd0391242dab7617f2d8f06f3b4549;p=thirdparty%2Fsqlite.git Have ".recover" handle cases where the sqlite_master table contains malformed SQL statements. FossilOrigin-Name: e736da9c18fad138c5502d354c3553373cba15358b69e44b257f60def59422e2 --- diff --git a/manifest b/manifest index 96481ec49b..4b83c71c58 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\srunning\sthe\s".recover"\scommand\son\sa\sdatabase\sthat\sis\szero\spages\sin\ssize. -D 2019-05-09T11:45:21.441 +C Have\s".recover"\shandle\scases\swhere\sthe\ssqlite_master\stable\scontains\smalformed\sSQL\sstatements. +D 2019-05-09T14:15:19.691 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -522,7 +522,7 @@ F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c 408632d9531ca8f1df8591f00530797daaa7bde3fe0d3211de4d431cbb99347e F src/rowset.c d977b011993aaea002cab3e0bb2ce50cf346000dff94e944d547b989f4b1fe93 F src/select.c ef860c7e5882c89c030432a6d2cf13c67d1d51fd511cf45cbdfd5c2faf44d51d -F src/shell.c.in 517b3e2aa15329f391bde567c5a4a5aa8d1eeb9d12f175cbc4b89a9dc136a4d3 +F src/shell.c.in f5d3a1f3f99a198bb8335461f1426eec72092786c20f4937d842b6f4988a8f1a F src/sqlite.h.in 0605c88d98c85fbcba8bbd9716e7cc10b361e7b21cf2375171130f577388c943 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 9ecc93b8493bd20c0c07d52e2ac0ed8bab9b549c7f7955b59869597b650dd8b5 @@ -1825,7 +1825,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 d99bb0c11d62f629bf59da037827af73a9b814e65815006e0cbca1bc41f42e25 -R 4c080fc5e9ab944c47b4a994674f6f12 +P 47fa65343e46c7782a173174952c637c5621e16229ece258dc7e7a556683ca0c +R be79b692a16f80cd3224bf9c098d5fd5 U dan -Z 26f5a39683d1a25b78fcdb707e769b6d +Z 9d48ce941293959626321b38e8342e0f diff --git a/manifest.uuid b/manifest.uuid index e1ca85ea2b..5faf9c5ba6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -47fa65343e46c7782a173174952c637c5621e16229ece258dc7e7a556683ca0c \ No newline at end of file +e736da9c18fad138c5502d354c3553373cba15358b69e44b257f60def59422e2 \ No newline at end of file diff --git a/src/shell.c.in b/src/shell.c.in index 8edf33f381..1fe216557e 100644 --- a/src/shell.c.in +++ b/src/shell.c.in @@ -6388,7 +6388,7 @@ static RecoverTable *recoverNewTable( finished: sqlite3_close(dbtmp); *pRc = rc; - if( rc!=SQLITE_OK ){ + if( rc!=SQLITE_OK || (pTab && pTab->zQuoted==0) ){ recoverFreeTable(pTab); pTab = 0; } @@ -6680,8 +6680,7 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){ /* Figure out if an orphan table will be required. And if so, how many ** user columns it should contain */ shellPrepare(pState->db, &rc, - "SELECT coalesce(max(maxlen), -2) FROM recovery.map" - " WHERE root>1 AND root NOT IN (SELECT rootpage FROM recovery.schema)" + "SELECT coalesce(max(maxlen), -2) FROM recovery.map WHERE root>1" , &pLoop ); if( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pLoop) ){ @@ -6689,7 +6688,6 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){ } shellFinalize(&rc, pLoop); pLoop = 0; - pOrphan = recoverOrphanTable(pState, &rc, zLostAndFound, nOrphan); shellPrepare(pState->db, &rc, "SELECT pgno FROM recovery.map WHERE root=?", &pPages @@ -6716,7 +6714,13 @@ static int recoverDatabaseCmd(ShellState *pState, int nArg, char **azArg){ pTab = recoverFindTable(pState, &rc, iRoot, bIntkey, nCol, &bNoop); if( bNoop || rc ) continue; - if( pTab==0 ) pTab = pOrphan; + if( pTab==0 ){ + if( pOrphan==0 ){ + pOrphan = recoverOrphanTable(pState, &rc, zLostAndFound, nOrphan); + } + pTab = pOrphan; + if( pTab==0 ) break; + } if( 0==sqlite3_stricmp(pTab->zQuoted, "'sqlite_sequence'") ){ raw_printf(pState->out, "DELETE FROM sqlite_sequence;\n");