From: dan Date: Tue, 4 Aug 2015 15:23:49 +0000 (+0000) Subject: Update the [showdb] program so that the database file is read directly (bypassing... X-Git-Tag: version-3.9.0~240^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8fb1bd2bc40036dc70575d03aa7f4a129ac9895a;p=thirdparty%2Fsqlite.git Update the [showdb] program so that the database file is read directly (bypassing the SQLite VFS) only if the --raw option is specified. Otherwise, it is read using the default VFS. An alternative VFS may be specified by specifying the database file to open using the URI syntax. FossilOrigin-Name: 9699e9bd9a0e813d04c9d37422920670697c46ed --- diff --git a/manifest b/manifest index a955e956d3..8f78b59000 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"--uri"\soption\sto\sutility\sprogram\s"showdb".\sThis\soption\scauses\sshowdb\sto\suse\ssqlite\swith\sthe\sSQLITE_OPEN_URI\soption\sto\sopen\sthe\sdatabase\sfile,\sinstead\sof\sopening\sit\sdirectly\susing\sthe\sOS\sopen()\sfunction. -D 2015-08-03T17:03:31.462 +C Update\sthe\s[showdb]\sprogram\sso\sthat\sthe\sdatabase\sfile\sis\sread\sdirectly\s(bypassing\sthe\sSQLite\sVFS)\sonly\sif\sthe\s--raw\soption\sis\sspecified.\sOtherwise,\sit\sis\sread\susing\sthe\sdefault\sVFS.\sAn\salternative\sVFS\smay\sbe\sspecified\sby\sspecifying\sthe\sdatabase\sfile\sto\sopen\susing\sthe\sURI\ssyntax. +D 2015-08-04T15:23:49.470 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4de3ef40c8b3b75c0c55ff4242a43c8ce1ad90ee F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1343,7 +1343,7 @@ F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/pagesig.c ff0ca355fd3c2398e933da5e22439bbff89b803b F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 -F tool/showdb.c 8b65966a80f30b95d3dcd9d7c13caaeb4dc21473 +F tool/showdb.c 95ed172060f91dd881c65f3906cbb8a43861f3ac F tool/showjournal.c 053eb1cc774710c6890b7dd6293300cc297b16a5 F tool/showlocks.c 9920bcc64f58378ff1118caead34147201f48c68 F tool/showstat4.c 9515faa8ec176599d4a8288293ba8ec61f7b728a @@ -1368,10 +1368,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 70b57dafb3216feb21091883196831fa1252e7bf -R 16122b1df3219db3f18abec519d4455c -T *branch * showdb-uri-option -T *sym-showdb-uri-option * -T -sym-trunk * +P 90e34d5119f720496e86a3a6de7771ea87b7dcbb +R 9d7c9f8de5d6d6fb5bb80e2cb324c919 U dan -Z 0bf8c605dcc175d4e077bbfb11ad015a +Z dbdc532b6b382833636acb3f205bead9 diff --git a/manifest.uuid b/manifest.uuid index 7c6c134c80..1b21715e9c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -90e34d5119f720496e86a3a6de7771ea87b7dcbb \ No newline at end of file +9699e9bd9a0e813d04c9d37422920670697c46ed \ No newline at end of file diff --git a/tool/showdb.c b/tool/showdb.c index 8f5f533293..0b88282f1c 100644 --- a/tool/showdb.c +++ b/tool/showdb.c @@ -24,8 +24,7 @@ static struct GlobalData { int dbfd; /* File descriptor for reading the DB */ int mxPage; /* Last page number */ int perLine; /* HEX elements to print per line */ - - int bUri; /* True for URI mode */ + int bRaw; /* True to access db file via OS APIs */ sqlite3_file *pFd; /* File descriptor for URI mode */ sqlite3 *pDb; /* Database handle that owns pFd */ } g = {1024, -1, 0, 16, 0, 0, 0}; @@ -97,7 +96,7 @@ static sqlite3 *openDatabase(const char *zPrg, const char *zName){ */ static void fileOpen(const char *zPrg, const char *zName){ assert( g.dbfd<0 ); - if( g.bUri ){ + if( g.bRaw==0 ){ int rc; void *pArg = (void *)(&g.pFd); g.pDb = openDatabase(zPrg, zName); @@ -121,7 +120,7 @@ static void fileOpen(const char *zPrg, const char *zName){ ** Close the database file opened by fileOpen() */ static void fileClose(){ - if( g.bUri ){ + if( g.bRaw==0 ){ sqlite3_close(g.pDb); g.pDb = 0; g.pFd = 0; @@ -143,7 +142,7 @@ static unsigned char *fileRead(sqlite3_int64 ofst, int nByte){ aData = sqlite3_malloc(nByte+32); if( aData==0 ) out_of_memory(); memset(aData, 0, nByte+32); - if( g.bUri ){ + if( g.bRaw==0 ){ int rc = g.pFd->pMethods->xRead(g.pFd, (void*)aData, nByte, ofst); if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){ fprintf(stderr, "error in xRead() - %d\n", rc); @@ -162,7 +161,7 @@ static unsigned char *fileRead(sqlite3_int64 ofst, int nByte){ */ static sqlite3_int64 fileGetsize(void){ sqlite3_int64 res = 0; - if( g.bUri ){ + if( g.bRaw==0 ){ int rc = g.pFd->pMethods->xFileSize(g.pFd, &res); if( rc!=SQLITE_OK ){ fprintf(stderr, "error in xFileSize() - %d\n", rc); @@ -1048,7 +1047,7 @@ static void usage(const char *argv0){ fprintf(stderr, "Usage %s ?--uri? FILENAME ?args...?\n\n", argv0); fprintf(stderr, "switches:\n" - " --uri FILENAME is a URI\n" + " --raw Read db file directly, bypassing SQLite VFS\n" "args:\n" " dbheader Show database header\n" " pgidx Index of how each page is used\n" @@ -1074,10 +1073,10 @@ int main(int argc, char **argv){ /* Check for the "--uri" or "-uri" switch. */ if( nArg>1 ){ - if( sqlite3_stricmp("-uri", azArg[1])==0 - || sqlite3_stricmp("--uri", azArg[1])==0 + if( sqlite3_stricmp("-raw", azArg[1])==0 + || sqlite3_stricmp("--raw", azArg[1])==0 ){ - g.bUri = 1; + g.bRaw = 1; azArg++; nArg--; } @@ -1088,7 +1087,7 @@ int main(int argc, char **argv){ exit(1); } - fileOpen(azArg[0], azArg[1]); + fileOpen(zPrg, azArg[1]); szFile = fileGetsize(); zPgSz = fileRead(16, 2); @@ -1121,11 +1120,11 @@ int main(int argc, char **argv){ continue; } if( strcmp(azArg[i], "help")==0 ){ - usage(azArg[0]); + usage(zPrg); continue; } if( !isdigit(azArg[i][0]) ){ - fprintf(stderr, "%s: unknown option: [%s]\n", azArg[0], azArg[i]); + fprintf(stderr, "%s: unknown option: [%s]\n", zPrg, azArg[i]); continue; } iStart = strtol(azArg[i], &zLeft, 0);