From: drh Date: Thu, 27 Sep 2018 14:24:22 +0000 (+0000) Subject: Minor enhancement to the pager so that it remembers if the underlying database X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fheads%2Fimmutable-pager;p=thirdparty%2Fsqlite.git Minor enhancement to the pager so that it remembers if the underlying database files is immutable. FossilOrigin-Name: 64db614eddd664e074021ce2fab123efc49eb250f70e55fed96f7d5ea2a32747 --- diff --git a/manifest b/manifest index afd4f4d11e..b31c846fff 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disallow\sthe\suse\sof\swindow\sfunctions\sin\sthe\srecursive\spart\sof\sa\srecursive\sCTE. -D 2018-09-27T12:14:15.056 +C Minor\senhancement\sto\sthe\spager\sso\sthat\sit\sremembers\sif\sthe\sunderlying\sdatabase\nfiles\sis\simmutable. +D 2018-09-27T14:24:22.733 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F Makefile.in 01e95208a78b57d056131382c493c963518f36da4c42b12a97eb324401b3a334 @@ -489,8 +489,8 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 7cfd67db0e2f926243f646db7ec1caa33ca9bee45799b0160ddfcd6ccfc175d2 F src/os_win.c 070cdbb400097c6cda54aa005356095afdc2f3ee691d17192c54724ef146a971 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c a0d8f686ef64549ad5b356fd30429bd9ee7a06dd42b4d6faa096352ff26b1c5b -F src/pager.h ecc554a55bc55d1c4ba5e17137b72e238e00bd81e72ff2662d8b9c8c10ae3963 +F src/pager.c 09621e99f96e34529b5ed61b4c1ba87743917cf3f06b00ff4bedb67124e51228 +F src/pager.h d141d2f2f7024d3988b6e03068d25cb8100846c9ab8a0338a3f3c07c43a00da8 F src/parse.y 6840fe7c0b5eb4dd25ee5d075213bc8255ed4c0678d71bfb6744d0520d91c179 F src/pcache.c 4196eb6ed3bbf00b80596c8e0b4f50e57eb7d890c19fb27a7354306abb7f983d F src/pcache.h 072f94d29281cffd99e46c1539849f248c4b56ae7684c1f36626797fee375170 @@ -1769,7 +1769,10 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P bd250533a06e4a11c1f548c3de66b8562fc627383848570d7d030cf132fd336f -R f859da5dfe791e15b8e90067f7a4610e -U dan -Z 08a7f25691627dd6eb8a24e372187fa8 +P 7fc2994434c7d9ed29c96a69c07e8eb4e97be776473c170c63f9a1bbaa09fa68 +R e6d82739c190925225a822d1b7e6dedb +T *branch * immutable-pager +T *sym-immutable-pager * +T -sym-trunk * +U drh +Z f57501b34f168481651a726b32cc4ecd diff --git a/manifest.uuid b/manifest.uuid index cddb301ade..b8881a0cf9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7fc2994434c7d9ed29c96a69c07e8eb4e97be776473c170c63f9a1bbaa09fa68 \ No newline at end of file +64db614eddd664e074021ce2fab123efc49eb250f70e55fed96f7d5ea2a32747 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index 92d32fd275..b89a762abe 100644 --- a/src/pager.c +++ b/src/pager.c @@ -4729,7 +4729,7 @@ int sqlite3PagerOpen( #else # define memJM 0 #endif - int readOnly = 0; /* True if this is a read-only file */ + int readOnly = PAGER_READWRITE; /* True if this is a read-only file */ int journalFileSize; /* Bytes to allocate for each journal fd */ char *zPathname = 0; /* Full path to database file */ int nPathname = 0; /* Number of bytes in zPathname */ @@ -4860,6 +4860,7 @@ int sqlite3PagerOpen( memJM = (fout&SQLITE_OPEN_MEMORY)!=0; #endif readOnly = (fout&SQLITE_OPEN_READONLY)!=0; + assert( readOnly==PAGER_READWRITE || readOnly==PAGER_READONLY ); /* If the file was successfully opened for read/write access, ** choose a default page size in case we have to create the @@ -4899,6 +4900,7 @@ int sqlite3PagerOpen( if( (iDc & SQLITE_IOCAP_IMMUTABLE)!=0 || sqlite3_uri_boolean(zFilename, "immutable", 0) ){ vfsFlags |= SQLITE_OPEN_READONLY; + readOnly = PAGER_IMMUTABLE; goto act_like_temp_file; } } @@ -4918,7 +4920,9 @@ act_like_temp_file: pPager->eState = PAGER_READER; /* Pretend we already have a lock */ pPager->eLock = EXCLUSIVE_LOCK; /* Pretend we are in EXCLUSIVE mode */ pPager->noLock = 1; /* Do no locking */ - readOnly = (vfsFlags&SQLITE_OPEN_READONLY); + if( (vfsFlags & SQLITE_OPEN_READONLY)!=0 && readOnly==PAGER_READWRITE ){ + readOnly = PAGER_READONLY; + } } /* The following call to PagerSetPagesize() serves to set the value of @@ -6696,6 +6700,12 @@ int sqlite3PagerRollback(Pager *pPager){ /* ** Return TRUE if the database file is opened read-only. Return FALSE ** if the database is (in theory) writable. +** +** Actually, the return value is one of: +** +** PAGER_READWRITE (value 0 - false) +** PAGER_READONLY (value 1 - true) +** PAGER_IMMUTABLE (value 2 - also true) */ u8 sqlite3PagerIsreadonly(Pager *pPager){ return pPager->readOnly; diff --git a/src/pager.h b/src/pager.h index 5b07a226b8..887f60fc1a 100644 --- a/src/pager.h +++ b/src/pager.h @@ -199,6 +199,10 @@ int sqlite3PagerSharedLock(Pager *pPager); /* Functions used to query pager state and configuration. */ u8 sqlite3PagerIsreadonly(Pager*); +/* Return values from sqlite3PagerIsreadonly() */ +#define PAGER_READWRITE 0 /* Read/write database */ +#define PAGER_READONLY 1 /* Read only but might change by outside forces */ +#define PAGER_IMMUTABLE 2 /* Guaranteed to never change */ u32 sqlite3PagerDataVersion(Pager*); #ifdef SQLITE_DEBUG int sqlite3PagerRefcount(Pager*);