From: drh Date: Sat, 22 Jul 2017 16:32:33 +0000 (+0000) Subject: Keep batch-atomic-writes turned on for journal_mode=MEMORY, but turn them X-Git-Tag: version-3.19.4~1^2~1^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2df9478f5ff2702331500362e9854159ab38936b;p=thirdparty%2Fsqlite.git Keep batch-atomic-writes turned on for journal_mode=MEMORY, but turn them off for synchronous=OFF. Refuse to compile with both SQLITE_MMAP_READWRITE and SQLITE_ENABLE_BATCH_ATOMIC_WRITE. Fix up some comments in the commit logic. FossilOrigin-Name: 2e80e19e4faac30947ed56aa3601c45c758cafb27f84780df255fdbcdc9a6999 --- diff --git a/manifest b/manifest index 5dff1f3bd3..918df0b47f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Omit\sunused\sbatch-atomic-write\scode\sif\sSQLITE_ENABLE_BATCH_ATOMIC_WRITE\sis\nnot\sdefined. -D 2017-07-22T16:00:34.947 +C Keep\sbatch-atomic-writes\sturned\son\sfor\sjournal_mode=MEMORY,\sbut\sturn\sthem\noff\sfor\ssynchronous=OFF.\s\sRefuse\sto\scompile\swith\sboth\sSQLITE_MMAP_READWRITE\nand\sSQLITE_ENABLE_BATCH_ATOMIC_WRITE.\s\sFix\sup\ssome\scomments\sin\sthe\scommit\nlogic. +D 2017-07-22T16:32:33.230 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -439,7 +439,7 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c 9e7300ba4564bf1b95ef6f4ea5635a55d5b609fb8ec621183e7aadd48930ae45 F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c 5e5e39f192e714ff1c07ea5b892da91db0cd824b58c4d1c389d141c3d82a8671 +F src/pager.c 1e63b0299cf123cf38c48413ec03190f56c1e7d0ccc6573c467d8ac240b898e9 F src/pager.h f2a99646c5533ffe11afa43e9e0bea74054e4efa F src/parse.y e384cb73f99e1b074085c974b37f4d830e885359e4b60837e30f7d67c16ba65b F src/pcache.c 62835bed959e2914edd26afadfecce29ece0e870 @@ -458,7 +458,7 @@ F src/shell.c.in b5725acacba95ccefa57b6d068f710e29ba8239c3aa704628a1902a1f729c17 F src/sqlite.h.in eacc9cd3fa971f6056c0a312a61430df7c8d0b1fc01774e9209becf2c184b251 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 967154985ed2ae62f90d9029bb5b5071793d847f1696a2ebe9e8cc0b042ae60b -F src/sqliteInt.h 437217b5d22e9c8f3c53f90324915a535f649262b1281eaabed4e31653576b51 +F src/sqliteInt.h 3cbbcb67ba66ffe44a6768c95df22137335e9ef167d5da93bf0c1ed20a91b992 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 @@ -1637,7 +1637,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 532bbf1f2b1028db4e581c756533aa660e482d833caaed4eafb299ef9b584f3a -R f8cc85762105a69ca21fc4aefd58063e +P a89b62c4966cd297326e8712da40e0962d2328d7ba1f201d5abcec911eeef347 +R 88801a01fa2ca8fc5930da1c8e878132 U drh -Z 90f565a84bb7c55ed3503f958b4951cd +Z dd2162169e6c906aa4638965a08ee342 diff --git a/manifest.uuid b/manifest.uuid index ffe8f301e4..2b11e3dfa2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a89b62c4966cd297326e8712da40e0962d2328d7ba1f201d5abcec911eeef347 \ No newline at end of file +2e80e19e4faac30947ed56aa3601c45c758cafb27f84780df255fdbcdc9a6999 \ No newline at end of file diff --git a/src/pager.c b/src/pager.c index ca2479f791..51661044d2 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6369,6 +6369,21 @@ int sqlite3PagerCommitPhaseOne( sqlite3PcacheCleanAll(pPager->pPCache); } }else{ + /* The bBatch boolean is true if the batch-atomic-write commit method + ** should be used. No rollback journal is created if batch-atomic-write + ** is enabled. + */ + sqlite3_file *fd = pPager->fd; +#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE + const int bBatch = zMaster==0 /* An SQLITE_IOCAP_BATCH_ATOMIC commit */ + && (sqlite3OsDeviceCharacteristics(fd) & SQLITE_IOCAP_BATCH_ATOMIC) + && !pPager->noSync + && sqlite3JournalIsInMemory(pPager->jfd); +#else +# define bBatch 0 +#endif + +#ifdef SQLITE_ENABLE_ATOMIC_WRITE /* The following block updates the change-counter. Exactly how it ** does this depends on whether or not the atomic-update optimization ** was enabled at compile time, and if this transaction meets the @@ -6392,17 +6407,6 @@ int sqlite3PagerCommitPhaseOne( ** in 'direct' mode. In this case the journal file will never be ** created for this transaction. */ - sqlite3_file *fd = pPager->fd; -#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE - const int bBatch = zMaster==0 /* An SQLITE_IOCAP_BATCH_ATOMIC commit */ - && (sqlite3OsDeviceCharacteristics(fd) & SQLITE_IOCAP_BATCH_ATOMIC) - && pPager->journalMode!=PAGER_JOURNALMODE_MEMORY - && sqlite3JournalIsInMemory(pPager->jfd); -#else -# define bBatch 0 -#endif - -#ifdef SQLITE_ENABLE_ATOMIC_WRITE if( bBatch==0 ){ PgHdr *pPg; assert( isOpen(pPager->jfd) diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 6e232e890f..9379d1ab45 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -630,6 +630,15 @@ # define SQLITE_DEFAULT_PCACHE_INITSZ 20 #endif +/* +** The compile-time options SQLITE_MMAP_READWRITE and +** SQLITE_ENABLE_BATCH_ATOMIC_WRITE are not compatible with one another. +** You must choose one or the other (or neither) but not both. +*/ +#if defined(SQLITE_MMAP_READWRITE) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) +#error Cannot use both SQLITE_MMAP_READWRITE and SQLITE_ENABLE_BATCH_ATOMIC_WRITE +#endif + /* ** GCC does not define the offsetof() macro so we'll have to do it ** ourselves.