From 40942f22f1d4adcd3c1053e4655f0287d33215b4 Mon Sep 17 00:00:00 2001 From: drh <> Date: Mon, 8 Mar 2021 12:59:16 +0000 Subject: [PATCH] Minor comment and formatting changes. FossilOrigin-Name: cf2add064f70c477fee1473c3196b72deb41222eb0cdbbdbdcf4a79995184e2b --- ext/misc/appendvfs.c | 38 ++++++++++++++++++-------------------- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 26 insertions(+), 28 deletions(-) diff --git a/ext/misc/appendvfs.c b/ext/misc/appendvfs.c index b7641c4853..8d62318a55 100644 --- a/ext/misc/appendvfs.c +++ b/ext/misc/appendvfs.c @@ -21,18 +21,16 @@ ** ** When opening a database using this VFS, the connection might treat ** the file as an ordinary SQLite database, or it might treat it as a -** database appended onto some other file. Here are the rules: +** database appended onto some other file. The decision is made by +** applying the following rules in order: ** -** (1) When opening a new empty file, that file is treated as an ordinary -** database. +** (1) An empty file is an ordinary database. ** -** (2) When opening a file that ends with the appendvfs trailer string -** "Start-Of-SQLite3-NNNNNNNN" that file is treated as an appended -** database, even if rule 3 otherwise applies. +** (2) If the file begins with the standard SQLite prefix string +** "SQLite format 3", that file is an ordinary database. ** -** (3) When opening a file that begins with the standard SQLite prefix -** string "SQLite format 3", that file is treated as an ordinary -** database, unless rule 2 applies. +** (2) If the file ends with the appendvfs trailer string +** "Start-Of-SQLite3-NNNNNNNN" that file is an appended database. ** ** (4) If none of the above apply and the SQLITE_OPEN_CREATE flag is ** set, then a new database is appended to the already existing file. @@ -46,7 +44,7 @@ ** database, then keep it in a separate file. ** ** If the file being opened is a plain database (not an appended one), then -** this shim is a pass-through into the default underlying VFS. (rule 3) +** this shim is a pass-through into the default underlying VFS. (rule 2) **/ #include "sqlite3ext.h" SQLITE_EXTENSION_INIT1 @@ -351,7 +349,7 @@ static int apndFileControl(sqlite3_file *pFile, int op, void *pArg){ pFile = ORIGFILE(pFile); rc = pFile->pMethods->xFileControl(pFile, op, pArg); if( rc==SQLITE_OK && op==SQLITE_FCNTL_VFSNAME ){ - *(char**)pArg = sqlite3_mprintf("apnd(%lld)/%z", paf->iPgOne, *(char**)pArg); + *(char**)pArg = sqlite3_mprintf("apnd(%lld)/%z", paf->iPgOne,*(char**)pArg); } return rc; } @@ -474,12 +472,15 @@ static int apndIsAppendvfsDatabase(sqlite3_int64 sz, sqlite3_file *pFile){ */ static int apndIsOrdinaryDatabaseFile(sqlite3_int64 sz, sqlite3_file *pFile){ char zHdr[16]; - if( apndIsAppendvfsDatabase(sz, pFile) /* rule 2 */ - || (sz & 0x1ff) != 0 - || SQLITE_OK!=pFile->pMethods->xRead(pFile, zHdr, sizeof(zHdr), 0) - || memcmp(zHdr, apvfsSqliteHdr, sizeof(zHdr))!=0 ) + if( apndIsAppendvfsDatabase(sz, pFile) /* rule 3 */ + || (sz & 0x1ff) != 0 + || SQLITE_OK!=pFile->pMethods->xRead(pFile, zHdr, sizeof(zHdr), 0) + || memcmp(zHdr, apvfsSqliteHdr, sizeof(zHdr))!=0 + ){ return 0; - return 1; + }else{ + return 1; + } } /* Round-up used to get appendvfs portion to begin at a page boundary. */ @@ -502,11 +503,8 @@ static int apndOpen( int rc; sqlite3_int64 sz; pSubVfs = ORIGVFS(pVfs); - /* The appendvfs is not to be used for auxillary DB files. - * Attempting such will result in simply opening the named - * file however the underlying VFS does that. - */ if( (flags & SQLITE_OPEN_MAIN_DB)==0 ){ + /* The appendvfs is not to be used for transient or temporary databases. */ return pSubVfs->xOpen(pSubVfs, zName, pFile, flags, pOutFlags); } p = (ApndFile*)pFile; diff --git a/manifest b/manifest index 1e949582e2..e7c0b96cdc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sfor\ssqlite3\sshell\swith\s-append\sflag. -D 2021-03-08T01:31:53.568 +C Minor\scomment\sand\sformatting\schanges. +D 2021-03-08T12:59:16.579 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -286,7 +286,7 @@ F ext/lsm1/tool/mklsm1c.tcl f31561bbee5349f0a554d1ad7236ac1991fc09176626f529f607 F ext/misc/README.md d6dd0fe1d8af77040216798a6a2b0c46c73054d2f0ea544fbbcdccf6f238c240 F ext/misc/amatch.c e3ad5532799cee9a97647f483f67f43b38796b84b5a8c60594fe782a4338f358 F ext/misc/anycollseq.c 5ffdfde9829eeac52219136ad6aa7cd9a4edb3b15f4f2532de52f4a22525eddb -F ext/misc/appendvfs.c 747f1ee3d0cd708426f8569bc5a74f76a6c5c9a9effd9dbbdb1d72ebef978f25 +F ext/misc/appendvfs.c 8c55f1dfca78069dccb39a6500044b2a5f1750001c716bdcf826f8eac84b1a4b F ext/misc/blobio.c a867c4c4617f6ec223a307ebfe0eabb45e0992f74dd47722b96f3e631c0edb2a F ext/misc/btreeinfo.c d28ce349b40054eaa9473e835837bad7a71deec33ba13e39f963d50933bfa0f9 F ext/misc/carray.c b75a0f207391038bf1540d3372f482a95c3613511c7c474db51ede1196321c7c @@ -1910,7 +1910,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 c9521fa55620d0cb3cec20db7b42bc5f18876b42dca07811d1cd0f4b2907eab2 -R 23f68eed98007d707ef4373f281e795f -U larrybr -Z 8c93033ed5f0b875a3a05a4dccf1c0c4 +P d1790288729441d53603709df02aa5fb5f04714e2da86ce128ca81840b0b545f +R f2bae5e6acbf372112d893828920ec3e +U drh +Z 7017ad4c0c56b9068565f01b047d25a0 diff --git a/manifest.uuid b/manifest.uuid index a953a68833..3b17ded62a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d1790288729441d53603709df02aa5fb5f04714e2da86ce128ca81840b0b545f \ No newline at end of file +cf2add064f70c477fee1473c3196b72deb41222eb0cdbbdbdcf4a79995184e2b \ No newline at end of file