From 466004d5a474eaf82344c0c4fb3c005fe4590ff4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 19 Jul 2017 11:20:32 +0000 Subject: [PATCH 01/17] Add VFS interfaces needed to make use of batch atomic write capabilities in the underlying filesystem. FossilOrigin-Name: 929bc46b8be0111a7b6e3d6fe129f0cad869c6a551bd47569c122742597b9f1c --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 21 +++++++++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index aed1eb2c5a..08cb95d385 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\scrash\sin\sunionvtab\scaused\sby\sa\smisconfiguration.\sAdd\sother\stest\scases\nfor\sthe\ssame. -D 2017-07-18T21:19:17.472 +C Add\sVFS\sinterfaces\sneeded\sto\smake\suse\sof\sbatch\satomic\swrite\scapabilities\nin\sthe\sunderlying\sfilesystem. +D 2017-07-19T11:20:32.402 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -455,7 +455,7 @@ F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c c6bf96a7f9d7d68f929de84738c599a30d0a725ab0b54420e70545743cd5ee7b F src/shell.c dd4494287b22ac5ab0654fdd5acb1f2172d2fe621f673a39229ddc31bd8d598f F src/shell.c.in b5725acacba95ccefa57b6d068f710e29ba8239c3aa704628a1902a1f729c175 -F src/sqlite.h.in dad804d4e1979a2ddec33cc8da6aa50c04e6ba0dcb4058e7b3609588d010e041 +F src/sqlite.h.in d11303f0c79ce08edb57893ee5eb168e83cdc6d0cad973da5957b954d0ff950e F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 967154985ed2ae62f90d9029bb5b5071793d847f1696a2ebe9e8cc0b042ae60b F src/sqliteInt.h 0ba730cdc8afa723a5642380712f8bb33abd6a69218571c18b94acf3562de22a @@ -1636,7 +1636,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 505fdc8ff5150276d3c6ab6135a542b791e9e79e2f76323e592b73b3fdc9bc2a -R 8a8c551ade3a7904ad53bd61f1cbe08d -U dan -Z 3243e7bcd67f989b9bcab9c5c686c467 +P 255d6b99de2bb210c09ebee9f9481ba3d1130fda47e6e01b4cc8411d00679d09 +R fcea2dbde9fcd8d5a84c03eddfc73a94 +T *branch * batch-atomic-write +T *sym-batch-atomic-write * +T -sym-trunk * +U drh +Z 449d02eadec688967e645655067d23f3 diff --git a/manifest.uuid b/manifest.uuid index 516ce5aff9..ea184f4bf7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -255d6b99de2bb210c09ebee9f9481ba3d1130fda47e6e01b4cc8411d00679d09 \ No newline at end of file +929bc46b8be0111a7b6e3d6fe129f0cad869c6a551bd47569c122742597b9f1c \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 427b6f747e..7c3f0f73d1 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -580,6 +580,11 @@ int sqlite3_exec( ** SQLITE_IOCAP_IMMUTABLE flag indicates that the file is on ** read-only media and cannot be changed even by processes with ** elevated privileges. +** +** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying +** filesystem can multiple write operations atomically when those +** write operations are bracketed by [SQLITE_IOCAP_BEGIN_ATOMIC_WRITE] and +** [SQLITE_IOCAP_ATOMIC_WRITE_COMMIT]. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 @@ -595,6 +600,7 @@ int sqlite3_exec( #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 #define SQLITE_IOCAP_IMMUTABLE 0x00002000 +#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 /* ** CAPI3REF: File Locking Levels @@ -1012,6 +1018,19 @@ struct sqlite3_io_methods { ** The [SQLITE_FCNTL_RBU] opcode is implemented by the special VFS used by ** the RBU extension only. All other VFS should return SQLITE_NOTFOUND for ** this opcode. +** +**
  • [[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]] +** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, that +** means all subsequent write operations will be deferred and done +** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. Systems +** that do not support batch atomic writes will return SQLITE_NOTFOUND. +** +**
  • [[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]] +** If the [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write +** operations since the previous successful call to +** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically. +** This file control returns [SQLITE_OK] if and only if the writes were +** all performed successfully and have been committed to persistent storage. ** */ #define SQLITE_FCNTL_LOCKSTATE 1 @@ -1043,6 +1062,8 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_JOURNAL_POINTER 28 #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 +#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 +#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE From efe16971913201fd678f6159cc92fe41aaf49384 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 20 Jul 2017 19:49:14 +0000 Subject: [PATCH 02/17] Add support for F2FS atomic writes. Untested at this point. FossilOrigin-Name: 416973ede3bde8567d1f2699728f72352979e054ef988d1c1e1cfe4290f6f8b8 --- manifest | 26 ++++++----- manifest.uuid | 2 +- src/memjournal.c | 13 +++--- src/os_unix.c | 111 ++++++++++++++++++++++++++++++++-------------- src/pager.c | 90 ++++++++++++++++++++++++++----------- src/sqlite.h.in | 6 +++ test/syscall.test | 2 +- 7 files changed, 171 insertions(+), 79 deletions(-) diff --git a/manifest b/manifest index 4932481eb6..008f47a0b9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\sthe\sbuilt-in\sdate/time\sfunctions\sso\sthat\sthey\scan\sbe\sused\sin\nCHECK\sconstraints,\sin\sthe\sWHERE\sclause\sor\spartial\sindexes,\sand\sindex\nexpressions,\sprovided\sthat\snone\sof\sthe\snon-deterministic\skeywords\n("now",\s"localtime",\s"utc")\sare\sused\sas\sarguments. -D 2017-07-20T15:08:43.378 +C Add\ssupport\sfor\sF2FS\satomic\swrites.\sUntested\sat\sthis\spoint. +D 2017-07-20T19:49:14.731 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -424,7 +424,7 @@ F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944 -F src/memjournal.c 95752936c11dc6995672d1dd783cd633eea0cc95 +F src/memjournal.c 3f1d95947cd39b35a6375b2ca384bac904f16353bd54995e9bff78161463ac1c F src/msvc.h 4942752b6a253116baaa8de75256c51a459a5e81 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85 @@ -436,10 +436,10 @@ F src/os.c add02933b1dce7a39a005b00a2f5364b763e9a24 F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c 30e2c43e4955db990e5b5a81e901f8aa74cc8820 +F src/os_unix.c eca7004f2cde959ed233951256e22aa4169c72f69b831e14276d0bdded4372f5 F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c 14f6982c470c05b8e85575c69e9c1712010602e20400f8670d8699e21283e0e4 +F src/pager.c 7ab906445447d5374971986de3525350d18c0e256723cd5a2456a429cd372f6c F src/pager.h f2a99646c5533ffe11afa43e9e0bea74054e4efa F src/parse.y e384cb73f99e1b074085c974b37f4d830e885359e4b60837e30f7d67c16ba65b F src/pcache.c 62835bed959e2914edd26afadfecce29ece0e870 @@ -455,7 +455,7 @@ F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c c6bf96a7f9d7d68f929de84738c599a30d0a725ab0b54420e70545743cd5ee7b F src/shell.c bd6a37cbe8bf64ef6a6a74fdc50f067d3148149b4ce2b4d03154663e66ded55f F src/shell.c.in b5725acacba95ccefa57b6d068f710e29ba8239c3aa704628a1902a1f729c175 -F src/sqlite.h.in dad804d4e1979a2ddec33cc8da6aa50c04e6ba0dcb4058e7b3609588d010e041 +F src/sqlite.h.in 51541eacdbbd26afcb5933ea4fadf9952fa9b3e4d7277c2b7983bf2b4a09a0bf F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 967154985ed2ae62f90d9029bb5b5071793d847f1696a2ebe9e8cc0b042ae60b F src/sqliteInt.h 96197a18f041b9ab99e6cee0db39dbf771ac7762d9f0f63d9e719285f0478664 @@ -1232,7 +1232,7 @@ F test/superlock.test ec94f0556b6488d97f71c79f9061ae08d9ab8f12 F test/symlink.test c9ebe7330d228249e447038276bfc8a7b22f4849 F test/sync.test 2f84bdbc2b2df1fcb0220575b4b9f8cea94b7529 F test/sync2.test 6be8ed007fa063b147773c1982b5bdba97a32badc536bdc6077eff5cf8710ece -F test/syscall.test 7a60601770172a8014a4d222d5f3d95a5d2b5c47fbb0374e2698e89c99e37256 +F test/syscall.test a39d9a36f852ae6e4800f861bc2f2e83f68bbc2112d9399931ecfadeabd2d69d F test/sysfault.test c9f2b0d8d677558f74de750c75e12a5454719d04 F test/tabfunc01.test c47171c36b3d411df2bd49719dcaa5d034f8d277477fd41d253940723b969a51 F test/table.test b708f3e5fa2542fa51dfab21fc07b36ea445cb2f @@ -1637,8 +1637,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 d14fc621e918915bbf8e04597eb238ea78dff3d9c5eb4402cb88692d00dbdfee b7f70c7fcabc10b8b3e62fe5ac68476cec23acaee037c7250ff70bca3f3ab541 -R 636bb2618e46215e27cfa1dc613ec36a -T +closed b7f70c7fcabc10b8b3e62fe5ac68476cec23acaee037c7250ff70bca3f3ab541 -U drh -Z 8d21c041010891259262753e78bdd45f +P a90c062d46c63a1e6f83064b1c5afb26a16e93b6ee8620ca46d169fdb325c488 +R 83821cb44cbf5af73c5132cb66d20c9f +T *branch * f2fs-support +T *sym-f2fs-support * +T -sym-trunk * +U dan +Z 66fb297e5afae668d4c6aa465d37e6d1 diff --git a/manifest.uuid b/manifest.uuid index 9f9976a109..8e1f9a8e9c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a90c062d46c63a1e6f83064b1c5afb26a16e93b6ee8620ca46d169fdb325c488 \ No newline at end of file +416973ede3bde8567d1f2699728f72352979e054ef988d1c1e1cfe4290f6f8b8 \ No newline at end of file diff --git a/src/memjournal.c b/src/memjournal.c index cd8b87d8aa..cc5f73e227 100644 --- a/src/memjournal.c +++ b/src/memjournal.c @@ -388,13 +388,16 @@ void sqlite3MemJournalOpen(sqlite3_file *pJfd){ /* ** If the argument p points to a MemJournal structure that is not an ** in-memory-only journal file (i.e. is one that was opened with a +ve -** nSpill parameter), and the underlying file has not yet been created, -** create it now. +** nSpill parameter or as SQLITE_OPEN_MAIN_JOURNAL), and the underlying +** file has not yet been created, create it now. */ -int sqlite3JournalCreate(sqlite3_file *p){ +int sqlite3JournalCreate(sqlite3_file *pJfd){ int rc = SQLITE_OK; - if( p->pMethods==&MemJournalMethods && ((MemJournal*)p)->nSpill>0 ){ - rc = memjrnlCreateFile((MemJournal*)p); + MemJournal *p = (MemJournal*)pJfd; + if( p->pMethod==&MemJournalMethods + && (p->nSpill>0 || (p->flags & SQLITE_OPEN_MAIN_JOURNAL)) + ){ + rc = memjrnlCreateFile(p); } return rc; } diff --git a/src/os_unix.c b/src/os_unix.c index 7f0ebdba6f..3397b3a213 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -90,6 +90,7 @@ #include #include #include +#include #include #include #include @@ -220,10 +221,8 @@ struct unixFile { sqlite3_int64 mmapSizeMax; /* Configured FCNTL_MMAP_SIZE value */ void *pMapRegion; /* Memory mapped region */ #endif -#ifdef __QNXNTO__ int sectorSize; /* Device sector size */ int deviceCharacteristics; /* Precomputed device characteristics */ -#endif #if SQLITE_ENABLE_LOCKING_STYLE int openFlags; /* The flags specified at open() */ #endif @@ -328,6 +327,13 @@ static pid_t randomnessPid = 0; # define lseek lseek64 #endif +#define F2FS_IOCTL_MAGIC 0xf5 +#define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1) +#define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2) +#define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3) +#define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5) + + /* ** Different Unix systems declare open() in different ways. Same use ** open(const char*,int,mode_t). Others use open(const char*,int,...). @@ -500,6 +506,9 @@ static struct unix_syscall { #endif #define osLstat ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent) + { "ioctl", (sqlite3_syscall_ptr)ioctl, 0 }, +#define osIoctl ((int(*)(int,int))aSyscall[28].pCurrent) + }; /* End of the overrideable system calls */ @@ -3777,6 +3786,19 @@ static int unixGetTempname(int nBuf, char *zBuf); static int unixFileControl(sqlite3_file *id, int op, void *pArg){ unixFile *pFile = (unixFile*)id; switch( op ){ + case SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: { + int rc = osIoctl(pFile->h, F2FS_IOC_START_ATOMIC_WRITE); + return rc ? SQLITE_ERROR : SQLITE_OK; + } + case SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: { + int rc = osIoctl(pFile->h, F2FS_IOC_COMMIT_ATOMIC_WRITE); + return rc ? SQLITE_ERROR : SQLITE_OK; + } + case SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: { + int rc = osIoctl(pFile->h, F2FS_IOC_ABORT_VOLATILE_WRITE); + return rc ? SQLITE_ERROR : SQLITE_OK; + } + case SQLITE_FCNTL_LOCKSTATE: { *(int*)pArg = pFile->eFileLock; return SQLITE_OK; @@ -3860,30 +3882,43 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ } /* -** Return the sector size in bytes of the underlying block device for -** the specified file. This is almost always 512 bytes, but may be -** larger for some devices. +** If pFd->sectorSize is non-zero when this function is called, it is a +** no-op. Otherwise, the values of pFd->sectorSize and +** pFd->deviceCharacteristics are set according to the file-system +** characteristics. ** -** SQLite code assumes this function cannot fail. It also assumes that -** if two files are created in the same file-system directory (i.e. -** a database and its journal file) that the sector size will be the -** same for both. +** There are two versions of this function. One for QNX and one for all +** other systems. */ -#ifndef __QNXNTO__ -static int unixSectorSize(sqlite3_file *NotUsed){ - UNUSED_PARAMETER(NotUsed); - return SQLITE_DEFAULT_SECTOR_SIZE; -} -#endif +#ifndef __QNXNTO__ +static void setDeviceCharacteristics(unixFile *pFd){ + if( pFd->sectorSize==0 ){ + int res; + assert( pFd->deviceCharacteristics==0 ); -/* -** The following version of unixSectorSize() is optimized for QNX. -*/ -#ifdef __QNXNTO__ + /* Check for support for F2FS atomic batch writes. */ + res = osIoctl(pFd->h, F2FS_IOC_START_VOLATILE_WRITE); + if( res==SQLITE_OK ){ + osIoctl(pFd->h, F2FS_IOC_ABORT_VOLATILE_WRITE); + pFd->deviceCharacteristics = + SQLITE_IOCAP_BATCH_ATOMIC | + SQLITE_IOCAP_ATOMIC | + SQLITE_IOCAP_SEQUENTIAL | + SQLITE_IOCAP_SAFE_APPEND; + } + + /* Set the POWERSAFE_OVERWRITE flag if requested. */ + if( pFd->ctrlFlags & UNIXFILE_PSOW ){ + pFd->deviceCharacteristics |= SQLITE_IOCAP_POWERSAFE_OVERWRITE; + } + + pFd->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; + } +} +#else #include #include -static int unixSectorSize(sqlite3_file *id){ - unixFile *pFile = (unixFile*)id; +static void setDeviceCharacteristics(unixFile *pFile){ if( pFile->sectorSize == 0 ){ struct statvfs fsInfo; @@ -3952,9 +3987,24 @@ static int unixSectorSize(sqlite3_file *id){ pFile->deviceCharacteristics = 0; pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE; } - return pFile->sectorSize; } -#endif /* __QNXNTO__ */ +#endif + +/* +** Return the sector size in bytes of the underlying block device for +** the specified file. This is almost always 512 bytes, but may be +** larger for some devices. +** +** SQLite code assumes this function cannot fail. It also assumes that +** if two files are created in the same file-system directory (i.e. +** a database and its journal file) that the sector size will be the +** same for both. +*/ +static int unixSectorSize(sqlite3_file *id){ + unixFile *pFd = (unixFile*)id; + setDeviceCharacteristics(pFd); + return pFd->sectorSize; +} /* ** Return the device characteristics for the file. @@ -3970,16 +4020,9 @@ static int unixSectorSize(sqlite3_file *id){ ** available to turn it off and URI query parameter available to turn it off. */ static int unixDeviceCharacteristics(sqlite3_file *id){ - unixFile *p = (unixFile*)id; - int rc = 0; -#ifdef __QNXNTO__ - if( p->sectorSize==0 ) unixSectorSize(id); - rc = p->deviceCharacteristics; -#endif - if( p->ctrlFlags & UNIXFILE_PSOW ){ - rc |= SQLITE_IOCAP_POWERSAFE_OVERWRITE; - } - return rc; + unixFile *pFd = (unixFile*)id; + setDeviceCharacteristics(pFd); + return pFd->deviceCharacteristics; } #if !defined(SQLITE_OMIT_WAL) || SQLITE_MAX_MMAP_SIZE>0 @@ -7598,7 +7641,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==28 ); + assert( ArraySize(aSyscall)==29 ); /* Register all VFSes defined in the aVfs[] array */ for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ diff --git a/src/pager.c b/src/pager.c index aee50e5318..7efab478f1 100644 --- a/src/pager.c +++ b/src/pager.c @@ -958,6 +958,7 @@ static int assert_pager_state(Pager *p){ assert( isOpen(p->jfd) || p->journalMode==PAGER_JOURNALMODE_OFF || p->journalMode==PAGER_JOURNALMODE_WAL + || (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC) ); break; @@ -1194,6 +1195,11 @@ static int jrnlBufferSize(Pager *pPager){ assert( isOpen(pPager->fd) ); dc = sqlite3OsDeviceCharacteristics(pPager->fd); + /* use in-memory journal */ + if( dc&SQLITE_IOCAP_BATCH_ATOMIC ){ + return -1; + } + nSector = pPager->sectorSize; szPage = pPager->pageSize; @@ -2012,7 +2018,9 @@ static int pager_end_transaction(Pager *pPager, int hasMaster, int bCommit){ } releaseAllSavepoints(pPager); - assert( isOpen(pPager->jfd) || pPager->pInJournal==0 ); + assert( isOpen(pPager->jfd) || pPager->pInJournal==0 + || (sqlite3OsDeviceCharacteristics(pPager->fd)&SQLITE_IOCAP_BATCH_ATOMIC) + ); if( isOpen(pPager->jfd) ){ assert( !pagerUseWal(pPager) ); @@ -4567,6 +4575,13 @@ static int pagerStress(void *p, PgHdr *pPg){ rc = pagerWalFrames(pPager, pPg, 0, 0); } }else{ + +#ifdef SQLITE_ENABLE_ATOMIC_WRITE + if( pPager->tempFile==0 ){ + rc = sqlite3JournalCreate(pPager->jfd); + if( rc!=SQLITE_OK ) return pager_error(pPager, rc); + } +#endif /* Sync the journal file if required. */ if( pPg->flags&PGHDR_NEED_SYNC @@ -6371,32 +6386,39 @@ int sqlite3PagerCommitPhaseOne( ** created for this transaction. */ #ifdef SQLITE_ENABLE_ATOMIC_WRITE - PgHdr *pPg; - assert( isOpen(pPager->jfd) - || pPager->journalMode==PAGER_JOURNALMODE_OFF - || pPager->journalMode==PAGER_JOURNALMODE_WAL - ); - if( !zMaster && isOpen(pPager->jfd) - && pPager->journalOff==jrnlBufferSize(pPager) - && pPager->dbSize>=pPager->dbOrigSize - && (0==(pPg = sqlite3PcacheDirtyList(pPager->pPCache)) || 0==pPg->pDirty) - ){ - /* Update the db file change counter via the direct-write method. The - ** following call will modify the in-memory representation of page 1 - ** to include the updated change counter and then write page 1 - ** directly to the database file. Because of the atomic-write - ** property of the host file-system, this is safe. - */ - rc = pager_incr_changecounter(pPager, 1); - }else{ - rc = sqlite3JournalCreate(pPager->jfd); - if( rc==SQLITE_OK ){ - rc = pager_incr_changecounter(pPager, 0); + sqlite3_file *fd = pPager->fd; + int bBatch = zMaster==0 /* An SQLITE_IOCAP_BATCH_ATOMIC commit */ + && (sqlite3OsDeviceCharacteristics(fd) & SQLITE_IOCAP_BATCH_ATOMIC) + && pPager->journalMode!=PAGER_JOURNALMODE_MEMORY + && sqlite3JournalIsInMemory(pPager->jfd); + + if( bBatch==0 ){ + PgHdr *pPg; + assert( isOpen(pPager->jfd) + || pPager->journalMode==PAGER_JOURNALMODE_OFF + || pPager->journalMode==PAGER_JOURNALMODE_WAL + ); + if( !zMaster && isOpen(pPager->jfd) + && pPager->journalOff==jrnlBufferSize(pPager) + && pPager->dbSize>=pPager->dbOrigSize + && (!(pPg = sqlite3PcacheDirtyList(pPager->pPCache)) || 0==pPg->pDirty) + ){ + /* Update the db file change counter via the direct-write method. The + ** following call will modify the in-memory representation of page 1 + ** to include the updated change counter and then write page 1 + ** directly to the database file. Because of the atomic-write + ** property of the host file-system, this is safe. + */ + rc = pager_incr_changecounter(pPager, 1); + }else{ + rc = sqlite3JournalCreate(pPager->jfd); + if( rc==SQLITE_OK ){ + rc = pager_incr_changecounter(pPager, 0); + } } - } - #else - rc = pager_incr_changecounter(pPager, 0); + }else #endif + rc = pager_incr_changecounter(pPager, 0); if( rc!=SQLITE_OK ) goto commit_phase_one_exit; /* Write the master journal name into the journal file. If a master @@ -6419,8 +6441,24 @@ int sqlite3PagerCommitPhaseOne( */ rc = syncJournal(pPager, 0); if( rc!=SQLITE_OK ) goto commit_phase_one_exit; - + + if( bBatch ){ + /* The pager is now in DBMOD state. But regardless of what happens + ** next, attempting to play the journal back into the database would + ** be unsafe. Close it now to make sure that does not happen. */ + sqlite3OsClose(pPager->jfd); + rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_BEGIN_ATOMIC_WRITE, 0); + if( rc!=SQLITE_OK ) goto commit_phase_one_exit; + } rc = pager_write_pagelist(pPager,sqlite3PcacheDirtyList(pPager->pPCache)); + if( bBatch ){ + if( rc==SQLITE_OK ){ + rc = sqlite3OsFileControl(fd, SQLITE_FCNTL_COMMIT_ATOMIC_WRITE, 0); + }else{ + sqlite3OsFileControl(fd, SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE, 0); + } + } + if( rc!=SQLITE_OK ){ assert( rc!=SQLITE_IOERR_BLOCKED ); goto commit_phase_one_exit; diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 427b6f747e..6d0aa3e2bb 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -595,6 +595,7 @@ int sqlite3_exec( #define SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN 0x00000800 #define SQLITE_IOCAP_POWERSAFE_OVERWRITE 0x00001000 #define SQLITE_IOCAP_IMMUTABLE 0x00002000 +#define SQLITE_IOCAP_BATCH_ATOMIC 0x00004000 /* ** CAPI3REF: File Locking Levels @@ -729,6 +730,7 @@ struct sqlite3_file { **
  • [SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN] **
  • [SQLITE_IOCAP_POWERSAFE_OVERWRITE] **
  • [SQLITE_IOCAP_IMMUTABLE] +**
  • [SQLITE_IOCAP_BATCH_ATOMIC] ** ** ** The SQLITE_IOCAP_ATOMIC property means that all writes of @@ -1044,6 +1046,10 @@ struct sqlite3_io_methods { #define SQLITE_FCNTL_WIN32_GET_HANDLE 29 #define SQLITE_FCNTL_PDB 30 +#define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE 31 +#define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE 32 +#define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE 33 + /* deprecated names */ #define SQLITE_GET_LOCKPROXYFILE SQLITE_FCNTL_GET_LOCKPROXYFILE #define SQLITE_SET_LOCKPROXYFILE SQLITE_FCNTL_SET_LOCKPROXYFILE diff --git a/test/syscall.test b/test/syscall.test index 2532187b47..19313a5e67 100644 --- a/test/syscall.test +++ b/test/syscall.test @@ -61,7 +61,7 @@ foreach s { fcntl read pread write pwrite fchmod fallocate pread64 pwrite64 unlink openDirectory mkdir rmdir statvfs fchown geteuid umask mmap munmap mremap - getpagesize readlink lstat + getpagesize readlink lstat ioctl } { if {[test_syscall exists $s]} {lappend syscall_list $s} } From d67a97705caa0951a32b6720cc0cbabf14f8c2bf Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 20 Jul 2017 21:00:03 +0000 Subject: [PATCH 03/17] Split SQLITE_ENABLE_ATOMIC_WRITE into two options - the original and SQLITE_ENABLE_BATCH_ATOMIC_WRITE. FossilOrigin-Name: 7eb9bf2c5b42c39901fd571553c1f70aa5a9dac71fdc8e318b3063b928ad58f7 --- manifest | 19 +++++------- manifest.uuid | 2 +- src/memjournal.c | 17 +++++++---- src/pager.c | 76 ++++++++++++++++++++++++++++++------------------ src/sqliteInt.h | 3 +- 5 files changed, 69 insertions(+), 48 deletions(-) diff --git a/manifest b/manifest index 008f47a0b9..7bf3e67604 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\ssupport\sfor\sF2FS\satomic\swrites.\sUntested\sat\sthis\spoint. -D 2017-07-20T19:49:14.731 +C Split\sSQLITE_ENABLE_ATOMIC_WRITE\sinto\stwo\soptions\s-\sthe\soriginal\sand\nSQLITE_ENABLE_BATCH_ATOMIC_WRITE. +D 2017-07-20T21:00:03.793 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -424,7 +424,7 @@ F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944 -F src/memjournal.c 3f1d95947cd39b35a6375b2ca384bac904f16353bd54995e9bff78161463ac1c +F src/memjournal.c 8669a499261d2c51ab2eb6c10b3b2e5085e559457ea630140de7f3521077daaa F src/msvc.h 4942752b6a253116baaa8de75256c51a459a5e81 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85 @@ -439,7 +439,7 @@ F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 F src/os_unix.c eca7004f2cde959ed233951256e22aa4169c72f69b831e14276d0bdded4372f5 F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c 7ab906445447d5374971986de3525350d18c0e256723cd5a2456a429cd372f6c +F src/pager.c a42704980ed4ce38ed75981acf12a4d34bea2419306c7ffe26940869c458df48 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 51541eacdbbd26afcb5933ea4fadf9952fa9b3e4d7277c2b7983bf2b4a09a0bf F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 967154985ed2ae62f90d9029bb5b5071793d847f1696a2ebe9e8cc0b042ae60b -F src/sqliteInt.h 96197a18f041b9ab99e6cee0db39dbf771ac7762d9f0f63d9e719285f0478664 +F src/sqliteInt.h 437217b5d22e9c8f3c53f90324915a535f649262b1281eaabed4e31653576b51 F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6a76b F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 @@ -1637,10 +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 a90c062d46c63a1e6f83064b1c5afb26a16e93b6ee8620ca46d169fdb325c488 -R 83821cb44cbf5af73c5132cb66d20c9f -T *branch * f2fs-support -T *sym-f2fs-support * -T -sym-trunk * +P 416973ede3bde8567d1f2699728f72352979e054ef988d1c1e1cfe4290f6f8b8 +R 1638e645768cee73f97e29d4fc63d373 U dan -Z 66fb297e5afae668d4c6aa465d37e6d1 +Z d68435e6ed708ea00daef410ca52596e diff --git a/manifest.uuid b/manifest.uuid index 8e1f9a8e9c..b2b1149ce4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -416973ede3bde8567d1f2699728f72352979e054ef988d1c1e1cfe4290f6f8b8 \ No newline at end of file +7eb9bf2c5b42c39901fd571553c1f70aa5a9dac71fdc8e318b3063b928ad58f7 \ No newline at end of file diff --git a/src/memjournal.c b/src/memjournal.c index cc5f73e227..493eb9a3b6 100644 --- a/src/memjournal.c +++ b/src/memjournal.c @@ -96,7 +96,8 @@ static int memjrnlRead( int iChunkOffset; FileChunk *pChunk; -#ifdef SQLITE_ENABLE_ATOMIC_WRITE +#ifdef SQLITE_ENABLE_ATOMIC_WRITE \ + || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) if( (iAmt+iOfst)>p->endpoint.iOffset ){ return SQLITE_IOERR_SHORT_READ; } @@ -215,7 +216,8 @@ static int memjrnlWrite( ** atomic-write optimization. In this case the first 28 bytes of the ** journal file may be written as part of committing the transaction. */ assert( iOfst==p->endpoint.iOffset || iOfst==0 ); -#ifdef SQLITE_ENABLE_ATOMIC_WRITE +#ifdef SQLITE_ENABLE_ATOMIC_WRITE \ + || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) if( iOfst==0 && p->pFirst ){ assert( p->nChunkSize>iAmt ); memcpy((u8*)p->pFirst->zChunk, zBuf, iAmt); @@ -384,7 +386,8 @@ void sqlite3MemJournalOpen(sqlite3_file *pJfd){ sqlite3JournalOpen(0, 0, pJfd, 0, -1); } -#ifdef SQLITE_ENABLE_ATOMIC_WRITE +#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \ + || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) /* ** If the argument p points to a MemJournal structure that is not an ** in-memory-only journal file (i.e. is one that was opened with a +ve @@ -394,9 +397,11 @@ void sqlite3MemJournalOpen(sqlite3_file *pJfd){ int sqlite3JournalCreate(sqlite3_file *pJfd){ int rc = SQLITE_OK; MemJournal *p = (MemJournal*)pJfd; - if( p->pMethod==&MemJournalMethods - && (p->nSpill>0 || (p->flags & SQLITE_OPEN_MAIN_JOURNAL)) - ){ + if( p->pMethod==&MemJournalMethods && (p->nSpill>0 +#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE + || (p->flags & SQLITE_OPEN_MAIN_JOURNAL) +#endif + )){ rc = memjrnlCreateFile(p); } return rc; diff --git a/src/pager.c b/src/pager.c index 7efab478f1..23be69ab2e 100644 --- a/src/pager.c +++ b/src/pager.c @@ -947,6 +947,7 @@ static int assert_pager_state(Pager *p){ assert( isOpen(p->jfd) || p->journalMode==PAGER_JOURNALMODE_OFF || p->journalMode==PAGER_JOURNALMODE_WAL + || (sqlite3OsDeviceCharacteristics(p->fd)&SQLITE_IOCAP_BATCH_ATOMIC) ); assert( pPager->dbOrigSize<=pPager->dbHintSize ); break; @@ -1169,39 +1170,45 @@ static int pagerLockDb(Pager *pPager, int eLock){ } /* -** This function determines whether or not the atomic-write optimization -** can be used with this pager. The optimization can be used if: +** This function determines whether or not the atomic-write or +** atomic-batch-write optimizations can be used with this pager. The +** atomic-write optimization can be used if: ** ** (a) the value returned by OsDeviceCharacteristics() indicates that ** a database page may be written atomically, and ** (b) the value returned by OsSectorSize() is less than or equal ** to the page size. ** -** The optimization is also always enabled for temporary files. It is -** an error to call this function if pPager is opened on an in-memory -** database. +** If it can be used, then the value returned is the size of the journal +** file when it contains rollback data for exactly one page. ** -** If the optimization cannot be used, 0 is returned. If it can be used, -** then the value returned is the size of the journal file when it -** contains rollback data for exactly one page. +** The atomic-batch-write optimization can be used if OsDeviceCharacteristics() +** returns a value with the SQLITE_IOCAP_BATCH_ATOMIC bit set. -1 is +** returned in this case. +** +** If neither optimization can be used, 0 is returned. */ -#ifdef SQLITE_ENABLE_ATOMIC_WRITE static int jrnlBufferSize(Pager *pPager){ assert( !MEMDB ); - if( !pPager->tempFile ){ - int dc; /* Device characteristics */ - int nSector; /* Sector size */ - int szPage; /* Page size */ - assert( isOpen(pPager->fd) ); - dc = sqlite3OsDeviceCharacteristics(pPager->fd); - /* use in-memory journal */ - if( dc&SQLITE_IOCAP_BATCH_ATOMIC ){ - return -1; - } +#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \ + || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) + int dc; /* Device characteristics */ - nSector = pPager->sectorSize; - szPage = pPager->pageSize; + assert( isOpen(pPager->fd) ); + dc = sqlite3OsDeviceCharacteristics(pPager->fd); +#endif + +#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE + if( dc&SQLITE_IOCAP_BATCH_ATOMIC ){ + return -1; + } +#endif + +#ifdef SQLITE_ENABLE_ATOMIC_WRITE + { + int nSector = pPager->sectorSize; + int szPage = pPager->pageSize; assert(SQLITE_IOCAP_ATOMIC512==(512>>8)); assert(SQLITE_IOCAP_ATOMIC64K==(65536>>8)); @@ -1211,11 +1218,11 @@ static int jrnlBufferSize(Pager *pPager){ } return JOURNAL_HDR_SZ(pPager) + JOURNAL_PG_SZ(pPager); -} -#else -# define jrnlBufferSize(x) 0 #endif + return 0; +} + /* ** If SQLITE_CHECK_PAGES is defined then we do some sanity checking ** on the cache using a hash function. This is used for testing @@ -4576,7 +4583,7 @@ static int pagerStress(void *p, PgHdr *pPg){ } }else{ -#ifdef SQLITE_ENABLE_ATOMIC_WRITE +#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE if( pPager->tempFile==0 ){ rc = sqlite3JournalCreate(pPager->jfd); if( rc!=SQLITE_OK ) return pager_error(pPager, rc); @@ -6385,13 +6392,17 @@ int sqlite3PagerCommitPhaseOne( ** in 'direct' mode. In this case the journal file will never be ** created for this transaction. */ - #ifdef SQLITE_ENABLE_ATOMIC_WRITE sqlite3_file *fd = pPager->fd; - int bBatch = zMaster==0 /* An SQLITE_IOCAP_BATCH_ATOMIC commit */ +#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 + const int bBatch = 0; +#endif +#ifdef SQLITE_ENABLE_ATOMIC_WRITE if( bBatch==0 ){ PgHdr *pPg; assert( isOpen(pPager->jfd) @@ -6416,9 +6427,16 @@ int sqlite3PagerCommitPhaseOne( rc = pager_incr_changecounter(pPager, 0); } } - }else - #endif + } +#else +#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE + if( zMaster ){ + rc = sqlite3JournalCreate(pPager->jfd); + if( rc!=SQLITE_OK ) goto commit_phase_one_exit; + } +#endif rc = pager_incr_changecounter(pPager, 0); +#endif if( rc!=SQLITE_OK ) goto commit_phase_one_exit; /* Write the master journal name into the journal file. If a master diff --git a/src/sqliteInt.h b/src/sqliteInt.h index e44c733b17..6e232e890f 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -4285,7 +4285,8 @@ int sqlite3FindInIndex(Parse *, Expr *, u32, int*, int*); int sqlite3JournalOpen(sqlite3_vfs *, const char *, sqlite3_file *, int, int); int sqlite3JournalSize(sqlite3_vfs *); -#ifdef SQLITE_ENABLE_ATOMIC_WRITE +#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \ + || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) int sqlite3JournalCreate(sqlite3_file *); #endif From 94e32acb5684d086e8168fa99368aa7af61e8307 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 20 Jul 2017 21:01:53 +0000 Subject: [PATCH 04/17] Transform two #ifdef statements into #if statements. FossilOrigin-Name: f2c6b5845028ef25dcd17e23e11b93c9f7296c26c7a21718fdae8f4b48c4e1da --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/memjournal.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 7bf3e67604..d3ceb012e2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Split\sSQLITE_ENABLE_ATOMIC_WRITE\sinto\stwo\soptions\s-\sthe\soriginal\sand\nSQLITE_ENABLE_BATCH_ATOMIC_WRITE. -D 2017-07-20T21:00:03.793 +C Transform\stwo\s#ifdef\sstatements\sinto\s#if\sstatements. +D 2017-07-20T21:01:53.887 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -424,7 +424,7 @@ F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944 -F src/memjournal.c 8669a499261d2c51ab2eb6c10b3b2e5085e559457ea630140de7f3521077daaa +F src/memjournal.c 9b9e579226341e891a4657dc76fe2cec69734abcd23be0e42aa8764d88131f12 F src/msvc.h 4942752b6a253116baaa8de75256c51a459a5e81 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85 @@ -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 416973ede3bde8567d1f2699728f72352979e054ef988d1c1e1cfe4290f6f8b8 -R 1638e645768cee73f97e29d4fc63d373 -U dan -Z d68435e6ed708ea00daef410ca52596e +P 7eb9bf2c5b42c39901fd571553c1f70aa5a9dac71fdc8e318b3063b928ad58f7 +R 07625fb6756b6e7b352836395541d6b0 +U drh +Z cd9d564ae288b39921ae68db54ad611b diff --git a/manifest.uuid b/manifest.uuid index b2b1149ce4..9016b58029 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7eb9bf2c5b42c39901fd571553c1f70aa5a9dac71fdc8e318b3063b928ad58f7 \ No newline at end of file +f2c6b5845028ef25dcd17e23e11b93c9f7296c26c7a21718fdae8f4b48c4e1da \ No newline at end of file diff --git a/src/memjournal.c b/src/memjournal.c index 493eb9a3b6..31ab5ef93f 100644 --- a/src/memjournal.c +++ b/src/memjournal.c @@ -96,7 +96,7 @@ static int memjrnlRead( int iChunkOffset; FileChunk *pChunk; -#ifdef SQLITE_ENABLE_ATOMIC_WRITE \ +#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \ || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) if( (iAmt+iOfst)>p->endpoint.iOffset ){ return SQLITE_IOERR_SHORT_READ; @@ -216,7 +216,7 @@ static int memjrnlWrite( ** atomic-write optimization. In this case the first 28 bytes of the ** journal file may be written as part of committing the transaction. */ assert( iOfst==p->endpoint.iOffset || iOfst==0 ); -#ifdef SQLITE_ENABLE_ATOMIC_WRITE \ +#if defined(SQLITE_ENABLE_ATOMIC_WRITE) \ || defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) if( iOfst==0 && p->pFirst ){ assert( p->nChunkSize>iAmt ); From d080e3d7acd3f5402c490b7becdeee2a05041ba6 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 21 Jul 2017 14:49:58 +0000 Subject: [PATCH 05/17] Additional documentation on the new VFS interface. No changes to code. FossilOrigin-Name: 83077ec8b5804e6c709fa4f0b50afec9eae6d5b603cc4c3e8a408ed6b2bfaf28 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 30 +++++++++++++++++++++++------- 3 files changed, 30 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 894b3ba0e9..2d98b37e4a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sdocumentation\stext\sfor\sthe\snew\sVFS\sinterfaces\sused\sby\sbatch-atomic\nwrites. -D 2017-07-20T21:18:49.851 +C Additional\sdocumentation\son\sthe\snew\sVFS\sinterface.\s\sNo\schanges\sto\scode. +D 2017-07-21T14:49:58.073 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -455,7 +455,7 @@ F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c c6bf96a7f9d7d68f929de84738c599a30d0a725ab0b54420e70545743cd5ee7b F src/shell.c bd6a37cbe8bf64ef6a6a74fdc50f067d3148149b4ce2b4d03154663e66ded55f F src/shell.c.in b5725acacba95ccefa57b6d068f710e29ba8239c3aa704628a1902a1f729c175 -F src/sqlite.h.in 6178cd914ca32535015ff57df78438f87a0f16609e9e47b1bc5f373ffe892686 +F src/sqlite.h.in c75b4de3d60133036ccfbbcf6afbb5d8ce492a902ff3e7cc5c3ef3ab28db0ee9 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 967154985ed2ae62f90d9029bb5b5071793d847f1696a2ebe9e8cc0b042ae60b F src/sqliteInt.h 437217b5d22e9c8f3c53f90324915a535f649262b1281eaabed4e31653576b51 @@ -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 f2c6b5845028ef25dcd17e23e11b93c9f7296c26c7a21718fdae8f4b48c4e1da 929bc46b8be0111a7b6e3d6fe129f0cad869c6a551bd47569c122742597b9f1c -R fd0dcdf56ec4d6602162b3b1d1594e27 +P 5e944eea5a32cb4d27a2d5ae283b9ce6fe08c1bc584256e8e8c78583c415eb2a +R f393cb3c25ccb9e4336ceb20b0531651 U drh -Z 9b7e24481f0b473c93f9af036e52968c +Z be7280aa4eb1e26b2cd69105d776b2e5 diff --git a/manifest.uuid b/manifest.uuid index 2096e2df55..190e2660c8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5e944eea5a32cb4d27a2d5ae283b9ce6fe08c1bc584256e8e8c78583c415eb2a \ No newline at end of file +83077ec8b5804e6c709fa4f0b50afec9eae6d5b603cc4c3e8a408ed6b2bfaf28 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index a248630809..92f5414c1d 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -582,9 +582,9 @@ int sqlite3_exec( ** elevated privileges. ** ** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying -** filesystem can multiple write operations atomically when those -** write operations are bracketed by [SQLITE_IOCAP_BEGIN_ATOMIC_WRITE] and -** [SQLITE_IOCAP_ATOMIC_WRITE_COMMIT]. +** filesystem supports doing multiple write operations atomically when those +** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and +** [SQLITE_FCNTL_ATOMIC_WRITE_COMMIT]. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 @@ -1021,22 +1021,38 @@ struct sqlite3_io_methods { ** this opcode. ** **
  • [[SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]] -** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, that +** If the [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] opcode returns SQLITE_OK, then +** the file descriptor is placed in "batch write mode", which ** means all subsequent write operations will be deferred and done ** atomically at the next [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. Systems ** that do not support batch atomic writes will return SQLITE_NOTFOUND. +** ^Following a successful SQLITE_FCNTL_BEGIN_ATOMIC_WRITE and prior to +** the closing [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] or +** [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE], SQLite will make +** no VFS interface calls on the same [sqlite3_file] file descriptor +** except for calls to the xWrite method and the xFileControl method +** with [SQLITE_FCNTL_SIZE_HINT]. ** **
  • [[SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]] -** If the [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write +** The [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE] opcode causes all write ** operations since the previous successful call to ** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be performed atomically. ** This file control returns [SQLITE_OK] if and only if the writes were ** all performed successfully and have been committed to persistent storage. +** ^Regardless of whether or not it is successful, this file control takes +** the file descriptor out of batch write mode so that all subsequent +** write operations are independent. +** ^SQLite will never invoke SQLITE_FCNTL_COMMIT_ATOMIC_WRITE without +** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. ** **
  • [[SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE]] -** If the [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write +** The [SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE] opcode causes all write ** operations since the previous successful call to -** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rollback. +** [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] to be rolled back. +** ^This file control takes the file descriptor out of batch write mode +** so that all subsequent write operations are independent. +** ^SQLite will never invoke SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE without +** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE]. ** */ #define SQLITE_FCNTL_LOCKSTATE 1 From 172861be763dc2fa472de5e814ff16c5e52d22c3 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 21 Jul 2017 20:29:06 +0000 Subject: [PATCH 06/17] Fix typo in comment. No changes to code. FossilOrigin-Name: 65ec077ba63ab84ab8da91033adcf4a57bb9269ebcdd10f9e6c97c265512a80c --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqlite.h.in | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 2d98b37e4a..e651e78919 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\sdocumentation\son\sthe\snew\sVFS\sinterface.\s\sNo\schanges\sto\scode. -D 2017-07-21T14:49:58.073 +C Fix\stypo\sin\scomment.\s\sNo\schanges\sto\scode. +D 2017-07-21T20:29:06.248 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -455,7 +455,7 @@ F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c c6bf96a7f9d7d68f929de84738c599a30d0a725ab0b54420e70545743cd5ee7b F src/shell.c bd6a37cbe8bf64ef6a6a74fdc50f067d3148149b4ce2b4d03154663e66ded55f F src/shell.c.in b5725acacba95ccefa57b6d068f710e29ba8239c3aa704628a1902a1f729c175 -F src/sqlite.h.in c75b4de3d60133036ccfbbcf6afbb5d8ce492a902ff3e7cc5c3ef3ab28db0ee9 +F src/sqlite.h.in eacc9cd3fa971f6056c0a312a61430df7c8d0b1fc01774e9209becf2c184b251 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 967154985ed2ae62f90d9029bb5b5071793d847f1696a2ebe9e8cc0b042ae60b F src/sqliteInt.h 437217b5d22e9c8f3c53f90324915a535f649262b1281eaabed4e31653576b51 @@ -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 5e944eea5a32cb4d27a2d5ae283b9ce6fe08c1bc584256e8e8c78583c415eb2a -R f393cb3c25ccb9e4336ceb20b0531651 -U drh -Z be7280aa4eb1e26b2cd69105d776b2e5 +P 83077ec8b5804e6c709fa4f0b50afec9eae6d5b603cc4c3e8a408ed6b2bfaf28 +R b334012c21dfa06dd301dc7ad606c856 +U mistachkin +Z fe62579b0ed14603dc9bb2d3159486da diff --git a/manifest.uuid b/manifest.uuid index 190e2660c8..00d2c0502d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -83077ec8b5804e6c709fa4f0b50afec9eae6d5b603cc4c3e8a408ed6b2bfaf28 \ No newline at end of file +65ec077ba63ab84ab8da91033adcf4a57bb9269ebcdd10f9e6c97c265512a80c \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 92f5414c1d..e0d8dacb1c 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -584,7 +584,7 @@ int sqlite3_exec( ** The SQLITE_IOCAP_BATCH_ATOMIC property means that the underlying ** filesystem supports doing multiple write operations atomically when those ** write operations are bracketed by [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE] and -** [SQLITE_FCNTL_ATOMIC_WRITE_COMMIT]. +** [SQLITE_FCNTL_COMMIT_ATOMIC_WRITE]. */ #define SQLITE_IOCAP_ATOMIC 0x00000001 #define SQLITE_IOCAP_ATOMIC512 0x00000002 From 9d70954094ca1fc0c6da29fa92a8d1bd5e87c150 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 21 Jul 2017 21:06:24 +0000 Subject: [PATCH 07/17] Use ioctl(F2FS_IOC_GET_FEATURES) to determine whether or not atomic batch writes are available. FossilOrigin-Name: 532bbf1f2b1028db4e581c756533aa660e482d833caaed4eafb299ef9b584f3a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_unix.c | 11 +++++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index e651e78919..1433d6978f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypo\sin\scomment.\s\sNo\schanges\sto\scode. -D 2017-07-21T20:29:06.248 +C Use\sioctl(F2FS_IOC_GET_FEATURES)\sto\sdetermine\swhether\sor\snot\satomic\sbatch\nwrites\sare\savailable. +D 2017-07-21T21:06:24.650 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -436,7 +436,7 @@ F src/os.c add02933b1dce7a39a005b00a2f5364b763e9a24 F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c eca7004f2cde959ed233951256e22aa4169c72f69b831e14276d0bdded4372f5 +F src/os_unix.c 7feae9cad46b5e43a87bf15133dd463b72ed7b8ad913833981582d8cd3f3802f F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c a42704980ed4ce38ed75981acf12a4d34bea2419306c7ffe26940869c458df48 @@ -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 83077ec8b5804e6c709fa4f0b50afec9eae6d5b603cc4c3e8a408ed6b2bfaf28 -R b334012c21dfa06dd301dc7ad606c856 -U mistachkin -Z fe62579b0ed14603dc9bb2d3159486da +P 65ec077ba63ab84ab8da91033adcf4a57bb9269ebcdd10f9e6c97c265512a80c +R 327ce51aa62d96bf2e9523d47812fe94 +U dan +Z 311d111b16e6fbf70dad068ea69fda6d diff --git a/manifest.uuid b/manifest.uuid index 00d2c0502d..e23616fc14 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -65ec077ba63ab84ab8da91033adcf4a57bb9269ebcdd10f9e6c97c265512a80c \ No newline at end of file +532bbf1f2b1028db4e581c756533aa660e482d833caaed4eafb299ef9b584f3a \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 3397b3a213..460b0a9bdc 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -332,6 +332,9 @@ static pid_t randomnessPid = 0; #define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2) #define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3) #define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5) +#define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, u32) + +#define F2FS_FEATURE_ATOMIC_WRITE 0x0004 /* @@ -507,7 +510,7 @@ static struct unix_syscall { #define osLstat ((int(*)(const char*,struct stat*))aSyscall[27].pCurrent) { "ioctl", (sqlite3_syscall_ptr)ioctl, 0 }, -#define osIoctl ((int(*)(int,int))aSyscall[28].pCurrent) +#define osIoctl ((int(*)(int,int,...))aSyscall[28].pCurrent) }; /* End of the overrideable system calls */ @@ -3894,12 +3897,12 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ static void setDeviceCharacteristics(unixFile *pFd){ if( pFd->sectorSize==0 ){ int res; + u32 f = 0; assert( pFd->deviceCharacteristics==0 ); /* Check for support for F2FS atomic batch writes. */ - res = osIoctl(pFd->h, F2FS_IOC_START_VOLATILE_WRITE); - if( res==SQLITE_OK ){ - osIoctl(pFd->h, F2FS_IOC_ABORT_VOLATILE_WRITE); + res = osIoctl(pFd->h, F2FS_IOC_GET_FEATURES, &f); + if( res==0 && (f & F2FS_FEATURE_ATOMIC_WRITE) ){ pFd->deviceCharacteristics = SQLITE_IOCAP_BATCH_ATOMIC | SQLITE_IOCAP_ATOMIC | From d76dba7eb5fec298ae8d5a50bc6091c9f9047d94 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 22 Jul 2017 16:00:34 +0000 Subject: [PATCH 08/17] Omit unused batch-atomic-write code if SQLITE_ENABLE_BATCH_ATOMIC_WRITE is not defined. FossilOrigin-Name: a89b62c4966cd297326e8712da40e0962d2328d7ba1f201d5abcec911eeef347 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/os_unix.c | 12 ++++++++++-- src/pager.c | 2 +- 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 1433d6978f..5dff1f3bd3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Use\sioctl(F2FS_IOC_GET_FEATURES)\sto\sdetermine\swhether\sor\snot\satomic\sbatch\nwrites\sare\savailable. -D 2017-07-21T21:06:24.650 +C Omit\sunused\sbatch-atomic-write\scode\sif\sSQLITE_ENABLE_BATCH_ATOMIC_WRITE\sis\nnot\sdefined. +D 2017-07-22T16:00:34.947 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -436,10 +436,10 @@ F src/os.c add02933b1dce7a39a005b00a2f5364b763e9a24 F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c 7feae9cad46b5e43a87bf15133dd463b72ed7b8ad913833981582d8cd3f3802f +F src/os_unix.c 9e7300ba4564bf1b95ef6f4ea5635a55d5b609fb8ec621183e7aadd48930ae45 F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a -F src/pager.c a42704980ed4ce38ed75981acf12a4d34bea2419306c7ffe26940869c458df48 +F src/pager.c 5e5e39f192e714ff1c07ea5b892da91db0cd824b58c4d1c389d141c3d82a8671 F src/pager.h f2a99646c5533ffe11afa43e9e0bea74054e4efa F src/parse.y e384cb73f99e1b074085c974b37f4d830e885359e4b60837e30f7d67c16ba65b F src/pcache.c 62835bed959e2914edd26afadfecce29ece0e870 @@ -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 65ec077ba63ab84ab8da91033adcf4a57bb9269ebcdd10f9e6c97c265512a80c -R 327ce51aa62d96bf2e9523d47812fe94 -U dan -Z 311d111b16e6fbf70dad068ea69fda6d +P 532bbf1f2b1028db4e581c756533aa660e482d833caaed4eafb299ef9b584f3a +R f8cc85762105a69ca21fc4aefd58063e +U drh +Z 90f565a84bb7c55ed3503f958b4951cd diff --git a/manifest.uuid b/manifest.uuid index e23616fc14..ffe8f301e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -532bbf1f2b1028db4e581c756533aa660e482d833caaed4eafb299ef9b584f3a \ No newline at end of file +a89b62c4966cd297326e8712da40e0962d2328d7ba1f201d5abcec911eeef347 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 460b0a9bdc..f45c86cb65 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -327,14 +327,18 @@ static pid_t randomnessPid = 0; # define lseek lseek64 #endif +#ifdef __linux__ +/* +** Linux-specific IOCTL magic numbers used for controlling F2FS +*/ #define F2FS_IOCTL_MAGIC 0xf5 #define F2FS_IOC_START_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 1) #define F2FS_IOC_COMMIT_ATOMIC_WRITE _IO(F2FS_IOCTL_MAGIC, 2) #define F2FS_IOC_START_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 3) #define F2FS_IOC_ABORT_VOLATILE_WRITE _IO(F2FS_IOCTL_MAGIC, 5) #define F2FS_IOC_GET_FEATURES _IOR(F2FS_IOCTL_MAGIC, 12, u32) - #define F2FS_FEATURE_ATOMIC_WRITE 0x0004 +#endif /* __linux__ */ /* @@ -3789,6 +3793,7 @@ static int unixGetTempname(int nBuf, char *zBuf); static int unixFileControl(sqlite3_file *id, int op, void *pArg){ unixFile *pFile = (unixFile*)id; switch( op ){ +#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) case SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: { int rc = osIoctl(pFile->h, F2FS_IOC_START_ATOMIC_WRITE); return rc ? SQLITE_ERROR : SQLITE_OK; @@ -3801,6 +3806,7 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ int rc = osIoctl(pFile->h, F2FS_IOC_ABORT_VOLATILE_WRITE); return rc ? SQLITE_ERROR : SQLITE_OK; } +#endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */ case SQLITE_FCNTL_LOCKSTATE: { *(int*)pArg = pFile->eFileLock; @@ -3895,10 +3901,11 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ */ #ifndef __QNXNTO__ static void setDeviceCharacteristics(unixFile *pFd){ + assert( pFd->deviceCharacteristics==0 || pFd->sectorSize!=0 ); if( pFd->sectorSize==0 ){ +#if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) int res; u32 f = 0; - assert( pFd->deviceCharacteristics==0 ); /* Check for support for F2FS atomic batch writes. */ res = osIoctl(pFd->h, F2FS_IOC_GET_FEATURES, &f); @@ -3909,6 +3916,7 @@ static void setDeviceCharacteristics(unixFile *pFd){ SQLITE_IOCAP_SEQUENTIAL | SQLITE_IOCAP_SAFE_APPEND; } +#endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */ /* Set the POWERSAFE_OVERWRITE flag if requested. */ if( pFd->ctrlFlags & UNIXFILE_PSOW ){ diff --git a/src/pager.c b/src/pager.c index 23be69ab2e..ca2479f791 100644 --- a/src/pager.c +++ b/src/pager.c @@ -6399,7 +6399,7 @@ int sqlite3PagerCommitPhaseOne( && pPager->journalMode!=PAGER_JOURNALMODE_MEMORY && sqlite3JournalIsInMemory(pPager->jfd); #else - const int bBatch = 0; +# define bBatch 0 #endif #ifdef SQLITE_ENABLE_ATOMIC_WRITE From 2df9478f5ff2702331500362e9854159ab38936b Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 22 Jul 2017 16:32:33 +0000 Subject: [PATCH 09/17] 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 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/pager.c | 26 +++++++++++++++----------- src/sqliteInt.h | 9 +++++++++ 4 files changed, 32 insertions(+), 19 deletions(-) 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. From 4da30f888834e48248bee6dcb90fc2e692603228 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 22 Jul 2017 16:58:47 +0000 Subject: [PATCH 10/17] Add the "atomic-batch-write" permutation to permutations.test. This permutation fails if not run on a file-system that supports atomic-batch-writes. FossilOrigin-Name: 9f1b83fae9c973eee80eefefe7bd3a1eb7bba8af4cd919d7a2ce911900dd9087 --- manifest | 22 +++++++++++----------- manifest.uuid | 2 +- src/test1.c | 41 +++++++++++++++++++++++++++++++++++++++++ test/fallocate.test | 4 +++- test/misc1.test | 42 ++++++++++++++++++++++-------------------- test/permutations.test | 24 ++++++++++++++++++++++++ test/rollback.test | 1 + 7 files changed, 103 insertions(+), 33 deletions(-) diff --git a/manifest b/manifest index 918df0b47f..e915c71f60 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -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 +C Add\sthe\s"atomic-batch-write"\spermutation\sto\spermutations.test.\sThis\npermutation\sfails\sif\snot\srun\son\sa\sfile-system\sthat\ssupports\natomic-batch-writes. +D 2017-07-22T16:58:47.336 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -463,7 +463,7 @@ F src/sqliteLimit.h 1513bfb7b20378aa0041e7022d04acb73525de35b80b252f1b83fedb4de6 F src/status.c a9e66593dfb28a9e746cba7153f84d49c1ddc4b1 F src/table.c b46ad567748f24a326d9de40e5b9659f96ffff34 F src/tclsqlite.c 2c29b0b76e91edfd1b43bf135c32c8674710089197327682b6b7e6af88062c3d -F src/test1.c cfb78b728b37ae3a2b14fe1b3a6c766e0da41370eda112594e698c94011b622e +F src/test1.c 8513b17ca4a7a9ba28748535d178b6e472ec7394ae0eea53907f2d3bcdbab2df F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6 @@ -754,7 +754,7 @@ F test/exists.test 79a75323c78f02bbe9c251ea502a092f9ef63dac F test/expr.test 66a2c9ac34f74f036faa4092f5402c7d3162fc93 F test/extension01.test 00d13cec817f331a687a243e0e5a2d87b0e358c9 F test/extraquick.test cb254400bd42bfb777ff675356aabf3287978f79 -F test/fallocate.test 3e979af17dfa7e5e9dda5eba1a696c04fa9d47f7 +F test/fallocate.test 87b5e43c872b7e69cd80b7b8813eb102b571a75d45dda24e38b65537bcc85733 F test/filectrl.test 6e871c2d35dead1d9a88e176e8d2ca094fec6bb3 F test/filefmt.test f393e80c4b8d493b7a7f8f3809a8425bbf4292af1f5140f01cb1427798a2bbd4 F test/fkey1.test ba64806ff9a04eecab2679caad377ae99a5e94e4 @@ -1029,7 +1029,7 @@ F test/minmax.test 6751e87b409fe11b02e70a306d846fa544e25a41 F test/minmax2.test b44bae787fc7b227597b01b0ca5575c7cb54d3bc F test/minmax3.test cc1e8b010136db0d01a6f2a29ba5a9f321034354 F test/minmax4.test 936941484ebdceb8adec7c86b6cd9b6e5e897c1f -F test/misc1.test 6430dabfb4b4fa480633590118964201f94d3ccc +F test/misc1.test 51ec3f56a2a7965de226964cff856695e743186826561536647f1e8b7d1d0eb3 F test/misc2.test 00d7de54eda90e237fc9a38b9e5ccc769ebf6d4d F test/misc3.test cf3dda47d5dda3e53fc5804a100d3c82be736c9d F test/misc4.test 0d8be3466adf123a7791a66ba2bc8e8d229e87f3 @@ -1087,7 +1087,7 @@ F test/parser1.test 391b9bf9a229547a129c61ac345ed1a6f5eb1854 F test/pcache.test c8acbedd3b6fd0f9a7ca887a83b11d24a007972b F test/pcache2.test af7f3deb1a819f77a6d0d81534e97d1cf62cd442 F test/percentile.test 4243af26b8f3f4555abe166f723715a1f74c77ff -F test/permutations.test 5e2e5439642898e0947ced066ad09b82bd817ddfb83dc71291b4c957efc84b62 +F test/permutations.test 3b94f8fd431d39fac4952eb5dc38e1bb2b4518e1ac967d66f5abc815c104aeb6 F test/pragma.test f274259d6393b6681eb433beb8dd39a26ec06a4431052a4880b43b84912a3f58 F test/pragma2.test e5d5c176360c321344249354c0c16aec46214c9f F test/pragma3.test 14c12bc5352b1e100e0b6b44f371053a81ccf8ed @@ -1113,7 +1113,7 @@ F test/regexp2.test 40e894223b3d6672655481493f1be12012f2b33c F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 F test/releasetest.tcl 7bb585433ce7fb2a2c255ae4b5e24f1bc27fe177ec1120f886cc4852f48f5ee9 x F test/resolver01.test f4022acafda7f4d40eca94dbf16bc5fc4ac30ceb -F test/rollback.test 458fe73eb3ffdfdf9f6ba3e9b7350a6220414dea +F test/rollback.test f580934279800d480a19176c6b44909df31ce7ad45267ea475a541daa522f3d3 F test/rollback2.test 8435d6ff0f13f51d2a4181c232e706005fa90fc5 F test/rollbackfault.test 0e646aeab8840c399cfbfa43daab46fd609cf04a F test/rowallock.test 3f88ec6819489d0b2341c7a7528ae17c053ab7cc @@ -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 a89b62c4966cd297326e8712da40e0962d2328d7ba1f201d5abcec911eeef347 -R 88801a01fa2ca8fc5930da1c8e878132 -U drh -Z dd2162169e6c906aa4638965a08ee342 +P 2e80e19e4faac30947ed56aa3601c45c758cafb27f84780df255fdbcdc9a6999 +R f3cc9474e40dfdafd1378160ccb50876 +U dan +Z e9e3d5840c0aa48b88a9ce806cb1e69e diff --git a/manifest.uuid b/manifest.uuid index 2b11e3dfa2..0361e53d3b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2e80e19e4faac30947ed56aa3601c45c758cafb27f84780df255fdbcdc9a6999 \ No newline at end of file +9f1b83fae9c973eee80eefefe7bd3a1eb7bba8af4cd919d7a2ce911900dd9087 \ No newline at end of file diff --git a/src/test1.c b/src/test1.c index df7685f244..7a6ff2163f 100644 --- a/src/test1.c +++ b/src/test1.c @@ -2553,6 +2553,46 @@ static int SQLITE_TCLAPI test_delete_database( return TCL_OK; } +/* +** Usage: atomic_batch_write PATH +*/ +static int SQLITE_TCLAPI test_atomic_batch_write( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + char *zFile = 0; /* Path to file to test */ + sqlite3 *db = 0; /* Database handle */ + sqlite3_file *pFd = 0; /* SQLite fd open on zFile */ + int bRes = 0; /* Integer result of this command */ + int dc = 0; /* Device-characteristics mask */ + int rc; /* sqlite3_open() return code */ + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "PATH"); + return TCL_ERROR; + } + zFile = Tcl_GetString(objv[1]); + + rc = sqlite3_open(zFile, &db); + if( rc!=SQLITE_OK ){ + Tcl_AppendResult(interp, sqlite3_errmsg(db), 0); + sqlite3_close(db); + return TCL_ERROR; + } + + rc = sqlite3_file_control(db, "main", SQLITE_FCNTL_FILE_POINTER, (void*)&pFd); + dc = pFd->pMethods->xDeviceCharacteristics(pFd); + if( dc & SQLITE_IOCAP_BATCH_ATOMIC ){ + bRes = 1; + } + + Tcl_SetObjResult(interp, Tcl_NewIntObj(bRes)); + sqlite3_close(db); + return TCL_OK; +} + /* ** Usage: sqlite3_next_stmt DB STMT ** @@ -7645,6 +7685,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){ { "sqlite3_snapshot_cmp_blob", test_snapshot_cmp_blob, 0 }, #endif { "sqlite3_delete_database", test_delete_database, 0 }, + { "atomic_batch_write", test_atomic_batch_write, 0 }, }; static int bitmask_size = sizeof(Bitmask)*8; static int longdouble_size = sizeof(LONGDOUBLE_TYPE); diff --git a/test/fallocate.test b/test/fallocate.test index f523c2cc4a..63d88ea885 100644 --- a/test/fallocate.test +++ b/test/fallocate.test @@ -59,7 +59,9 @@ do_test fallocate-1.6 { # do_test fallocate-1.7 { execsql { BEGIN; INSERT INTO t1 VALUES(1, 2); } - if {[permutation] != "inmemory_journal"} { + if {[permutation] != "inmemory_journal" + && [permutation] != "atomic-batch-write" + } { hexio_get_int [hexio_read test.db-journal 16 4] } else { set {} 1024 diff --git a/test/misc1.test b/test/misc1.test index e646bfd098..be64a8f7a9 100644 --- a/test/misc1.test +++ b/test/misc1.test @@ -479,26 +479,28 @@ ifcapable curdir { # Make sure a database connection still works after changing the # working directory. # -do_test misc1-14.1 { - file mkdir tempdir - cd tempdir - execsql {BEGIN} - file exists ./test.db-journal -} {0} -do_test misc1-14.2a { - execsql {UPDATE t1 SET a=a||'x' WHERE 0} - file exists ../test.db-journal -} {0} -do_test misc1-14.2b { - execsql {UPDATE t1 SET a=a||'y' WHERE 1} - file exists ../test.db-journal -} {1} -do_test misc1-14.3 { - cd .. - forcedelete tempdir - execsql {COMMIT} - file exists ./test.db-journal -} {0} +if {[atomic_batch_write test.db]==0} { + do_test misc1-14.1 { + file mkdir tempdir + cd tempdir + execsql {BEGIN} + file exists ./test.db-journal + } {0} + do_test misc1-14.2a { + execsql {UPDATE t1 SET a=a||'x' WHERE 0} + file exists ../test.db-journal + } {0} + do_test misc1-14.2b { + execsql {UPDATE t1 SET a=a||'y' WHERE 1} + file exists ../test.db-journal + } {1} + do_test misc1-14.3 { + cd .. + forcedelete tempdir + execsql {COMMIT} + file exists ./test.db-journal + } {0} +} } # A failed create table should not leave the table in the internal diff --git a/test/permutations.test b/test/permutations.test index 59e30b5198..bcd06c14b7 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -389,6 +389,30 @@ test_suite "vfslog" -prefix "" -description { wal* mmap* ] +test_suite "atomic-batch-write" -prefix "" -description { + Like veryquick.test, but must be run on a file-system that supports + atomic-batch-writes. Tests that depend on the journal file being present + are omitted. +} -files [ + test_set $allquicktests -exclude *malloc* *ioerr* *fault* *bigfile* *_err* \ + *fts5corrupt* *fts5big* *fts5aj* \ + crash8.test delete_db.test \ + exclusive.test journal3.test \ + journal1.test \ + jrnlmode.test jrnlmode2.test \ + lock4.test pager1.test \ + pager3.test sharedA.test \ + symlink.test stmt.test \ + sync.test sync2.test \ + tempdb.test tkt3457.test \ + vacuum5.test wal2.test \ + walmode.test zerodamage.test +] -initialize { + if {[atomic_batch_write test.db]==0} { + error "File system does NOT support atomic-batch-write" + } +} + lappend ::testsuitelist xxx #------------------------------------------------------------------------- # Define the coverage related test suites: diff --git a/test/rollback.test b/test/rollback.test index 7abafece61..60a6190317 100644 --- a/test/rollback.test +++ b/test/rollback.test @@ -82,6 +82,7 @@ do_test rollback-1.9 { if {$tcl_platform(platform) == "unix" && [permutation] ne "onefile" && [permutation] ne "inmemory_journal" + && [permutation] ne "atomic-batch-write" } { do_test rollback-2.1 { execsql { From 33447e7793436a6b93451c5ab6467f5fea25ed1a Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 22 Jul 2017 20:12:31 +0000 Subject: [PATCH 11/17] Add a test for the outcome of a process crash within an xWrite VFS method call. FossilOrigin-Name: eb8718006cb23ba9304da5c30d19863d688495f0eaae3794c5ad870e481866f8 --- manifest | 17 ++-- manifest.uuid | 2 +- src/test6.c | 25 +++++ src/test_devsym.c | 218 +++++++++++++++++++++++++++++++++---------- test/tester.tcl | 48 ++++++++++ test/writecrash.test | 62 ++++++++++++ 6 files changed, 313 insertions(+), 59 deletions(-) create mode 100644 test/writecrash.test diff --git a/manifest b/manifest index e915c71f60..03946f8c1a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\s"atomic-batch-write"\spermutation\sto\spermutations.test.\sThis\npermutation\sfails\sif\snot\srun\son\sa\sfile-system\sthat\ssupports\natomic-batch-writes. -D 2017-07-22T16:58:47.336 +C Add\sa\stest\sfor\sthe\soutcome\sof\sa\sprocess\scrash\swithin\san\sxWrite\sVFS\smethod\ncall. +D 2017-07-22T20:12:31.931 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -468,7 +468,7 @@ F src/test2.c 3efb99ab7f1fc8d154933e02ae1378bac9637da5 F src/test3.c b8434949dfb8aff8dfa082c8b592109e77844c2135ed3c492113839b6956255b F src/test4.c 18ec393bb4d0ad1de729f0b94da7267270f3d8e6 F src/test5.c 328aae2c010c57a9829d255dc099d6899311672d -F src/test6.c 004ad42f121f693b8cbe060d1a330678abc61620 +F src/test6.c e8d839fbc552ce044bec8234561a2d5b8819b48e29548ad0ba400471697946a8 F src/test7.c 5612e9aecf934d6df7bba6ce861fdf5ba5456010 F src/test8.c 4f4904721167b32f7a4fa8c7b32a07a673d6cc86 F src/test9.c 12e5ba554d2d1cbe0158f6ab3f7ffcd7a86ee4e5 @@ -481,7 +481,7 @@ F src/test_btree.c 8b2dc8b8848cf3a4db93f11578f075e82252a274 F src/test_config.c abf6fc1fe9d041b699578c42e3db81f8831c4f5b804f1927958102ee8f2b773e F src/test_delete.c e2fe07646dff6300b48d49b2fee2fe192ed389e834dd635e3b3bac0ce0bf9f8f F src/test_demovfs.c a0c3bdd45ed044115c2c9f7779e56eafff18741e -F src/test_devsym.c 4e58dec2602d8e139ca08659f62a62450587cb58 +F src/test_devsym.c 1960abbb234b97e9b920f07e99503fc04b443f62bbc3c6ff2c2cea2133e3b8a2 F src/test_fs.c 35a2f7dd8a915900873386331386d9ba1ae1b5026d74fd20c2807bc76221f291 F src/test_func.c a4fdab3363b436c1b12660e9362ce3f3782b7b5e F src/test_hexio.c 1d4469ca61ab202a1fcec6543f584d2407205e8d @@ -1246,7 +1246,7 @@ F test/temptable.test d2c9b87a54147161bcd1822e30c1d1cd891e5b30 F test/temptable2.test cd396beb41117a5302fff61767c35fa4270a0d5e F test/temptable3.test d11a0974e52b347e45ee54ef1923c91ed91e4637 F test/temptrigger.test 38f0ca479b1822d3117069e014daabcaacefffcc -F test/tester.tcl 581f0185434daf7026ccede4c07e8d1479186ec5 +F test/tester.tcl eb7ec55fe074a909423c1de701f7c545417b8aa96787b8c3e7a79203f2cebec8 F test/thread001.test 9f22fd3525a307ff42a326b6bc7b0465be1745a5 F test/thread002.test e630504f8a06c00bf8bbe68528774dd96aeb2e58 F test/thread003.test ee4c9efc3b86a6a2767516a37bd64251272560a7 @@ -1542,6 +1542,7 @@ F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a F test/without_rowid5.test 89b1c587bd92a0590e440da33e7666bf4891572a F test/without_rowid6.test 1f99644e6508447fb050f73697350c7ceca3392e F test/wordcount.c 06efb84b7c48a4973c2c24ea06c93d00bce24389 +F test/writecrash.test e6dc9d470d43710c3f780a50d29cce1c3884ca34ff50e737bc9ab8724c7c2398 F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 @@ -1637,7 +1638,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 2e80e19e4faac30947ed56aa3601c45c758cafb27f84780df255fdbcdc9a6999 -R f3cc9474e40dfdafd1378160ccb50876 +P 9f1b83fae9c973eee80eefefe7bd3a1eb7bba8af4cd919d7a2ce911900dd9087 +R f23da5f714bc905d7cb0056ef392fdf9 U dan -Z e9e3d5840c0aa48b88a9ce806cb1e69e +Z 063d069885d7a39f9c6cf058832bceb7 diff --git a/manifest.uuid b/manifest.uuid index 0361e53d3b..f6a017d89b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9f1b83fae9c973eee80eefefe7bd3a1eb7bba8af4cd919d7a2ce911900dd9087 \ No newline at end of file +eb8718006cb23ba9304da5c30d19863d688495f0eaae3794c5ad870e481866f8 \ No newline at end of file diff --git a/src/test6.c b/src/test6.c index 849cdeb3b9..9a3aa093f0 100644 --- a/src/test6.c +++ b/src/test6.c @@ -736,6 +736,7 @@ static int processDevSymArgs( { "sequential", SQLITE_IOCAP_SEQUENTIAL }, { "safe_append", SQLITE_IOCAP_SAFE_APPEND }, { "powersafe_overwrite", SQLITE_IOCAP_POWERSAFE_OVERWRITE }, + { "batch-atomic", SQLITE_IOCAP_BATCH_ATOMIC }, { 0, 0 } }; @@ -976,7 +977,30 @@ static int SQLITE_TCLAPI devSymObjCmd( devsym_register(iDc, iSectorSize); return TCL_OK; +} +/* +** tclcmd: sqlite3_crash_on_write N +*/ +static int SQLITE_TCLAPI writeCrashObjCmd( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + void devsym_crash_on_write(int); + int nWrite = 0; + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "NWRITE"); + return TCL_ERROR; + } + if( Tcl_GetIntFromObj(interp, objv[1], &nWrite) ){ + return TCL_ERROR; + } + + devsym_crash_on_write(nWrite); + return TCL_OK; } /* @@ -1068,6 +1092,7 @@ int Sqlitetest6_Init(Tcl_Interp *interp){ Tcl_CreateObjCommand(interp, "sqlite3_crashparams", crashParamsObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_crash_now", crashNowCmd, 0, 0); Tcl_CreateObjCommand(interp, "sqlite3_simulate_device", devSymObjCmd, 0, 0); + Tcl_CreateObjCommand(interp, "sqlite3_crash_on_write", writeCrashObjCmd,0,0); Tcl_CreateObjCommand(interp, "unregister_devsim", dsUnregisterObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "register_jt_vfs", jtObjCmd, 0, 0); Tcl_CreateObjCommand(interp, "unregister_jt_vfs", jtUnregisterObjCmd, 0, 0); diff --git a/src/test_devsym.c b/src/test_devsym.c index 9a1ba09d69..0da6671cf4 100644 --- a/src/test_devsym.c +++ b/src/test_devsym.c @@ -28,6 +28,7 @@ ** Name used to identify this VFS. */ #define DEVSYM_VFS_NAME "devsym" +#define WRITECRASH_NAME "writecrash" typedef struct devsym_file devsym_file; struct devsym_file { @@ -72,61 +73,13 @@ static int devsymRandomness(sqlite3_vfs*, int nByte, char *zOut); static int devsymSleep(sqlite3_vfs*, int microseconds); static int devsymCurrentTime(sqlite3_vfs*, double*); -static sqlite3_vfs devsym_vfs = { - 2, /* iVersion */ - sizeof(devsym_file), /* szOsFile */ - DEVSYM_MAX_PATHNAME, /* mxPathname */ - 0, /* pNext */ - DEVSYM_VFS_NAME, /* zName */ - 0, /* pAppData */ - devsymOpen, /* xOpen */ - devsymDelete, /* xDelete */ - devsymAccess, /* xAccess */ - devsymFullPathname, /* xFullPathname */ -#ifndef SQLITE_OMIT_LOAD_EXTENSION - devsymDlOpen, /* xDlOpen */ - devsymDlError, /* xDlError */ - devsymDlSym, /* xDlSym */ - devsymDlClose, /* xDlClose */ -#else - 0, /* xDlOpen */ - 0, /* xDlError */ - 0, /* xDlSym */ - 0, /* xDlClose */ -#endif /* SQLITE_OMIT_LOAD_EXTENSION */ - devsymRandomness, /* xRandomness */ - devsymSleep, /* xSleep */ - devsymCurrentTime, /* xCurrentTime */ - 0, /* xGetLastError */ - 0 /* xCurrentTimeInt64 */ -}; - -static sqlite3_io_methods devsym_io_methods = { - 2, /* iVersion */ - devsymClose, /* xClose */ - devsymRead, /* xRead */ - devsymWrite, /* xWrite */ - devsymTruncate, /* xTruncate */ - devsymSync, /* xSync */ - devsymFileSize, /* xFileSize */ - devsymLock, /* xLock */ - devsymUnlock, /* xUnlock */ - devsymCheckReservedLock, /* xCheckReservedLock */ - devsymFileControl, /* xFileControl */ - devsymSectorSize, /* xSectorSize */ - devsymDeviceCharacteristics, /* xDeviceCharacteristics */ - devsymShmMap, /* xShmMap */ - devsymShmLock, /* xShmLock */ - devsymShmBarrier, /* xShmBarrier */ - devsymShmUnmap /* xShmUnmap */ -}; - struct DevsymGlobal { sqlite3_vfs *pVfs; int iDeviceChar; int iSectorSize; + int nWriteCrash; }; -struct DevsymGlobal g = {0, 0, 512}; +struct DevsymGlobal g = {0, 0, 512, 0}; /* ** Close an devsym-file. @@ -271,6 +224,26 @@ static int devsymOpen( int flags, int *pOutFlags ){ +static sqlite3_io_methods devsym_io_methods = { + 2, /* iVersion */ + devsymClose, /* xClose */ + devsymRead, /* xRead */ + devsymWrite, /* xWrite */ + devsymTruncate, /* xTruncate */ + devsymSync, /* xSync */ + devsymFileSize, /* xFileSize */ + devsymLock, /* xLock */ + devsymUnlock, /* xUnlock */ + devsymCheckReservedLock, /* xCheckReservedLock */ + devsymFileControl, /* xFileControl */ + devsymSectorSize, /* xSectorSize */ + devsymDeviceCharacteristics, /* xDeviceCharacteristics */ + devsymShmMap, /* xShmMap */ + devsymShmLock, /* xShmLock */ + devsymShmBarrier, /* xShmBarrier */ + devsymShmUnmap /* xShmUnmap */ +}; + int rc; devsym_file *p = (devsym_file *)pFile; p->pReal = (sqlite3_file *)&p[1]; @@ -372,6 +345,137 @@ static int devsymCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ return g.pVfs->xCurrentTime(g.pVfs, pTimeOut); } +/* +** Return the sector-size in bytes for an writecrash-file. +*/ +static int writecrashSectorSize(sqlite3_file *pFile){ + devsym_file *p = (devsym_file *)pFile; + return sqlite3OsSectorSize(p->pReal); +} + +/* +** Return the device characteristic flags supported by an writecrash-file. +*/ +static int writecrashDeviceCharacteristics(sqlite3_file *pFile){ + devsym_file *p = (devsym_file *)pFile; + return sqlite3OsDeviceCharacteristics(p->pReal); +} + +/* +** Write data to an writecrash-file. +*/ +static int writecrashWrite( + sqlite3_file *pFile, + const void *zBuf, + int iAmt, + sqlite_int64 iOfst +){ + devsym_file *p = (devsym_file *)pFile; + if( g.nWriteCrash>0 ){ + g.nWriteCrash--; + if( g.nWriteCrash==0 ) abort(); + } + return sqlite3OsWrite(p->pReal, zBuf, iAmt, iOfst); +} + +/* +** Open an writecrash file handle. +*/ +static int writecrashOpen( + sqlite3_vfs *pVfs, + const char *zName, + sqlite3_file *pFile, + int flags, + int *pOutFlags +){ +static sqlite3_io_methods writecrash_io_methods = { + 2, /* iVersion */ + devsymClose, /* xClose */ + devsymRead, /* xRead */ + writecrashWrite, /* xWrite */ + devsymTruncate, /* xTruncate */ + devsymSync, /* xSync */ + devsymFileSize, /* xFileSize */ + devsymLock, /* xLock */ + devsymUnlock, /* xUnlock */ + devsymCheckReservedLock, /* xCheckReservedLock */ + devsymFileControl, /* xFileControl */ + writecrashSectorSize, /* xSectorSize */ + writecrashDeviceCharacteristics, /* xDeviceCharacteristics */ + devsymShmMap, /* xShmMap */ + devsymShmLock, /* xShmLock */ + devsymShmBarrier, /* xShmBarrier */ + devsymShmUnmap /* xShmUnmap */ +}; + + int rc; + devsym_file *p = (devsym_file *)pFile; + p->pReal = (sqlite3_file *)&p[1]; + rc = sqlite3OsOpen(g.pVfs, zName, p->pReal, flags, pOutFlags); + if( p->pReal->pMethods ){ + pFile->pMethods = &writecrash_io_methods; + } + return rc; +} + +static sqlite3_vfs devsym_vfs = { + 2, /* iVersion */ + sizeof(devsym_file), /* szOsFile */ + DEVSYM_MAX_PATHNAME, /* mxPathname */ + 0, /* pNext */ + DEVSYM_VFS_NAME, /* zName */ + 0, /* pAppData */ + devsymOpen, /* xOpen */ + devsymDelete, /* xDelete */ + devsymAccess, /* xAccess */ + devsymFullPathname, /* xFullPathname */ +#ifndef SQLITE_OMIT_LOAD_EXTENSION + devsymDlOpen, /* xDlOpen */ + devsymDlError, /* xDlError */ + devsymDlSym, /* xDlSym */ + devsymDlClose, /* xDlClose */ +#else + 0, /* xDlOpen */ + 0, /* xDlError */ + 0, /* xDlSym */ + 0, /* xDlClose */ +#endif /* SQLITE_OMIT_LOAD_EXTENSION */ + devsymRandomness, /* xRandomness */ + devsymSleep, /* xSleep */ + devsymCurrentTime, /* xCurrentTime */ + 0, /* xGetLastError */ + 0 /* xCurrentTimeInt64 */ +}; + +static sqlite3_vfs writecrash_vfs = { + 2, /* iVersion */ + sizeof(devsym_file), /* szOsFile */ + DEVSYM_MAX_PATHNAME, /* mxPathname */ + 0, /* pNext */ + WRITECRASH_NAME, /* zName */ + 0, /* pAppData */ + writecrashOpen, /* xOpen */ + devsymDelete, /* xDelete */ + devsymAccess, /* xAccess */ + devsymFullPathname, /* xFullPathname */ +#ifndef SQLITE_OMIT_LOAD_EXTENSION + devsymDlOpen, /* xDlOpen */ + devsymDlError, /* xDlError */ + devsymDlSym, /* xDlSym */ + devsymDlClose, /* xDlClose */ +#else + 0, /* xDlOpen */ + 0, /* xDlError */ + 0, /* xDlSym */ + 0, /* xDlClose */ +#endif /* SQLITE_OMIT_LOAD_EXTENSION */ + devsymRandomness, /* xRandomness */ + devsymSleep, /* xSleep */ + devsymCurrentTime, /* xCurrentTime */ + 0, /* xGetLastError */ + 0 /* xCurrentTimeInt64 */ +}; + /* ** This procedure registers the devsym vfs with SQLite. If the argument is @@ -379,10 +483,13 @@ static int devsymCurrentTime(sqlite3_vfs *pVfs, double *pTimeOut){ ** available function in this file. */ void devsym_register(int iDeviceChar, int iSectorSize){ + if( g.pVfs==0 ){ g.pVfs = sqlite3_vfs_find(0); devsym_vfs.szOsFile += g.pVfs->szOsFile; + writecrash_vfs.szOsFile += g.pVfs->szOsFile; sqlite3_vfs_register(&devsym_vfs, 0); + sqlite3_vfs_register(&writecrash_vfs, 0); } if( iDeviceChar>=0 ){ g.iDeviceChar = iDeviceChar; @@ -403,4 +510,15 @@ void devsym_unregister(){ g.iSectorSize = 0; } +void devsym_crash_on_write(int nWrite){ + if( g.pVfs==0 ){ + g.pVfs = sqlite3_vfs_find(0); + devsym_vfs.szOsFile += g.pVfs->szOsFile; + writecrash_vfs.szOsFile += g.pVfs->szOsFile; + sqlite3_vfs_register(&devsym_vfs, 0); + sqlite3_vfs_register(&writecrash_vfs, 0); + } + g.nWriteCrash = nWrite; +} + #endif diff --git a/test/tester.tcl b/test/tester.tcl index dc6547d033..38c19701c6 100644 --- a/test/tester.tcl +++ b/test/tester.tcl @@ -1608,6 +1608,54 @@ proc crashsql {args} { lappend r $msg } +# crash_on_write ?-devchar DEVCHAR? CRASHDELAY SQL +# +proc crash_on_write {args} { + + set nArg [llength $args] + if {$nArg<2 || $nArg%2} { + error "bad args: $args" + } + set zSql [lindex $args end] + set nDelay [lindex $args end-1] + + set devchar {} + for {set ii 0} {$ii < $nArg-2} {incr ii 2} { + set opt [lindex $args $ii] + switch -- [lindex $args $ii] { + -devchar { + set devchar [lindex $args [expr $ii+1]] + } + + default { error "unrecognized option: $opt" } + } + } + + set f [open crash.tcl w] + puts $f "sqlite3_crash_on_write $nDelay" + puts $f "sqlite3_test_control_pending_byte $::sqlite_pending_byte" + puts $f "sqlite3 db test.db -vfs writecrash" + puts $f "db eval {$zSql}" + puts $f "set {} {}" + + close $f + set r [catch { + exec [info nameofexec] crash.tcl >@stdout + } msg] + + # Windows/ActiveState TCL returns a slightly different + # error message. We map that to the expected message + # so that we don't have to change all of the test + # cases. + if {$::tcl_platform(platform)=="windows"} { + if {$msg=="child killed: unknown signal"} { + set msg "child process exited abnormally" + } + } + + lappend r $msg +} + proc run_ioerr_prep {} { set ::sqlite_io_error_pending 0 catch {db close} diff --git a/test/writecrash.test b/test/writecrash.test new file mode 100644 index 0000000000..25fe6b423f --- /dev/null +++ b/test/writecrash.test @@ -0,0 +1,62 @@ +# 2009 January 8 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Test the outcome of a writer crashing within a call to the VFS +# xWrite function. +# + + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix writecrash + +do_not_use_codec + +do_execsql_test 1.0 { + CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB UNIQUE); + WITH s(i) AS ( + VALUES(1) UNION ALL SELECT i+1 FROM s WHERE i<100 + ) + INSERT INTO t1 SELECT NULL, randomblob(900) FROM s; +} {} + +set bGo 1 +for {set tn 1} {$bGo} {incr tn} { + +db close +sqlite3 db test.db + + do_test 1.$tn.1 { + set res [crash_on_write $tn { + UPDATE t1 SET b = randomblob(899) WHERE (a%3)==0 + }] + set bGo 0 + if {[string match {1 {child killed:*}} $res]} { + set res {0 {}} + set bGo 1 + } + set res + } {0 {}} + +#db close +#sqlite3 db test.db + + do_execsql_test 1.$tn.2 { PRAGMA integrity_check } {ok} + +db close +sqlite3 db test.db + + do_execsql_test 1.$tn.3 { PRAGMA integrity_check } {ok} +} + + + +finish_test From 77b4f528fab48e28b179a351f2b478667063266b Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 27 Jul 2017 18:34:00 +0000 Subject: [PATCH 12/17] Do not set device-capabilities flags SEQUENTIAL or SAFE_APPEND for f2fs file-systems. FossilOrigin-Name: 4477e60cd801dab7a8aec12c5bc5e81e774bedbfed38abbc8eb8b37336141a44 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_unix.c | 6 +----- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 03946f8c1a..0c6d27f1f4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\sfor\sthe\soutcome\sof\sa\sprocess\scrash\swithin\san\sxWrite\sVFS\smethod\ncall. -D 2017-07-22T20:12:31.931 +C Do\snot\sset\sdevice-capabilities\sflags\sSEQUENTIAL\sor\sSAFE_APPEND\sfor\sf2fs\nfile-systems. +D 2017-07-27T18:34:00.448 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -436,7 +436,7 @@ F src/os.c add02933b1dce7a39a005b00a2f5364b763e9a24 F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c 9e7300ba4564bf1b95ef6f4ea5635a55d5b609fb8ec621183e7aadd48930ae45 +F src/os_unix.c 9aa19db965d574cbaf74405cd51c58b87fdbfe045b8bbfc01b18bdeeda3c4305 F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 1e63b0299cf123cf38c48413ec03190f56c1e7d0ccc6573c467d8ac240b898e9 @@ -1638,7 +1638,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 9f1b83fae9c973eee80eefefe7bd3a1eb7bba8af4cd919d7a2ce911900dd9087 -R f23da5f714bc905d7cb0056ef392fdf9 +P eb8718006cb23ba9304da5c30d19863d688495f0eaae3794c5ad870e481866f8 +R ce693a7ca9a259977de390176cf62cb0 U dan -Z 063d069885d7a39f9c6cf058832bceb7 +Z f84e1d974aa4edf0cc8f431eef8b011b diff --git a/manifest.uuid b/manifest.uuid index f6a017d89b..e6f6c99525 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eb8718006cb23ba9304da5c30d19863d688495f0eaae3794c5ad870e481866f8 \ No newline at end of file +4477e60cd801dab7a8aec12c5bc5e81e774bedbfed38abbc8eb8b37336141a44 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index f45c86cb65..430c5386ea 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3910,11 +3910,7 @@ static void setDeviceCharacteristics(unixFile *pFd){ /* Check for support for F2FS atomic batch writes. */ res = osIoctl(pFd->h, F2FS_IOC_GET_FEATURES, &f); if( res==0 && (f & F2FS_FEATURE_ATOMIC_WRITE) ){ - pFd->deviceCharacteristics = - SQLITE_IOCAP_BATCH_ATOMIC | - SQLITE_IOCAP_ATOMIC | - SQLITE_IOCAP_SEQUENTIAL | - SQLITE_IOCAP_SAFE_APPEND; + pFd->deviceCharacteristics = SQLITE_IOCAP_BATCH_ATOMIC; } #endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */ From a66632d83a13a73ff406a8efd46e0092864b252c Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 28 Jul 2017 01:53:32 +0000 Subject: [PATCH 13/17] Add the SQLITE_ENABLE_BATCH_ATOMIC_WRITE macro to ctime.c FossilOrigin-Name: 67bad7fb9b2fdb29b63308f22062444084dc28191a542e08076dc2e39caf6f62 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/ctime.c | 3 +++ 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 0c6d27f1f4..d19c66231b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\sset\sdevice-capabilities\sflags\sSEQUENTIAL\sor\sSAFE_APPEND\sfor\sf2fs\nfile-systems. -D 2017-07-27T18:34:00.448 +C Add\sthe\sSQLITE_ENABLE_BATCH_ATOMIC_WRITE\smacro\sto\sctime.c +D 2017-07-28T01:53:32.480 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -401,7 +401,7 @@ F src/btreeInt.h 97700795edf8a43245720414798b7b29d8e465aef46bf301ffacd431910c0da F src/build.c 74108007d286232fb4290464ee5452fa860c26215f8caa0e6c7cbf69a6fafe8f F src/callback.c 8e14b60d1ed1c87c02cb5f121ecda99224f2aea6524a77ee6f72c9b5c7110f84 F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e -F src/ctime.c 928954802b1397d9fb1378c7eb702c94b4735bbab1d5793e21b6a77734f56a1b +F src/ctime.c ff1be3eed7bdd75aaca61ca8dc848f7c9f850ef2fb9cb56f2734e922a098f9c0 F src/date.c 48f743d88bbe88f848532d333cca84f26e52a4f217e86f86be7fc1b919c33d74 F src/dbstat.c 7a4ba8518b6369ef3600c49cf9c918ad979acba610b2aebef1b656d649b96720 F src/delete.c 939bd15e6b54b82b951e1c0ffc2ff2b4ab579196780a1f6d394e47bd6f799b6c @@ -1638,7 +1638,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 eb8718006cb23ba9304da5c30d19863d688495f0eaae3794c5ad870e481866f8 -R ce693a7ca9a259977de390176cf62cb0 -U dan -Z f84e1d974aa4edf0cc8f431eef8b011b +P 4477e60cd801dab7a8aec12c5bc5e81e774bedbfed38abbc8eb8b37336141a44 +R 7b37fdaf5e84d7527bf9bb356bdba2dd +U drh +Z 27d0a818d20124b850051ada33dcfbb8 diff --git a/manifest.uuid b/manifest.uuid index e6f6c99525..508bf735c2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4477e60cd801dab7a8aec12c5bc5e81e774bedbfed38abbc8eb8b37336141a44 \ No newline at end of file +67bad7fb9b2fdb29b63308f22062444084dc28191a542e08076dc2e39caf6f62 \ No newline at end of file diff --git a/src/ctime.c b/src/ctime.c index ef2523a9b2..e8f4e7f90b 100644 --- a/src/ctime.c +++ b/src/ctime.c @@ -184,6 +184,9 @@ static const char * const sqlite3azCompileOpt[] = { #if SQLITE_ENABLE_ATOMIC_WRITE "ENABLE_ATOMIC_WRITE", #endif +#if SQLITE_ENABLE_BATCH_ATOMIC_WRITE + "ENABLE_BATCH_ATOMIC_WRITE", +#endif #if SQLITE_ENABLE_CEROD "ENABLE_CEROD", #endif From 2912da0283394ffdf0da78051130204f8003c459 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 28 Jul 2017 11:05:33 +0000 Subject: [PATCH 14/17] Add new test file test/atomic.test. FossilOrigin-Name: f9213e4864d0542be5489e03cf40c47d9127a86bbbbbabd963aa08525d5dc97b --- manifest | 13 +++++++------ manifest.uuid | 2 +- test/atomic.test | 41 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 test/atomic.test diff --git a/manifest b/manifest index d19c66231b..b03dc42eec 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\sSQLITE_ENABLE_BATCH_ATOMIC_WRITE\smacro\sto\sctime.c -D 2017-07-28T01:53:32.480 +C Add\snew\stest\sfile\stest/atomic.test. +D 2017-07-28T11:05:33.638 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -572,6 +572,7 @@ F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test 383ab533fdb9f7ad228cc99ee66e1acb34cc0dc0 F test/atof1.test ff0b0156fd705b67c506e1f2bfe9e26102bea9bd +F test/atomic.test 065a453dde33c77ff586d91ccaa6ed419829d492dbb1a5694b8a09f3f9d7d061 F test/attach.test f4b8918ba2f3e88e6883b8452340545f10a1388af808343c37fc5c577be8281c F test/attach2.test 0ec5defa340363de6cd50fd595046465e9aaba2d F test/attach3.test c59d92791070c59272e00183b7353eeb94915976 @@ -1638,7 +1639,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 4477e60cd801dab7a8aec12c5bc5e81e774bedbfed38abbc8eb8b37336141a44 -R 7b37fdaf5e84d7527bf9bb356bdba2dd -U drh -Z 27d0a818d20124b850051ada33dcfbb8 +P 67bad7fb9b2fdb29b63308f22062444084dc28191a542e08076dc2e39caf6f62 +R f9a806bade742314c2ca4f28e94ea3db +U dan +Z e2b2bd316b28a6b89ebee3e338f870e9 diff --git a/manifest.uuid b/manifest.uuid index 508bf735c2..bcacdd3199 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67bad7fb9b2fdb29b63308f22062444084dc28191a542e08076dc2e39caf6f62 \ No newline at end of file +f9213e4864d0542be5489e03cf40c47d9127a86bbbbbabd963aa08525d5dc97b \ No newline at end of file diff --git a/test/atomic.test b/test/atomic.test new file mode 100644 index 0000000000..6ce6debb73 --- /dev/null +++ b/test/atomic.test @@ -0,0 +1,41 @@ +# 2015-11-07 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing the WITH clause. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix atomic + +db close +if {[atomic_batch_write test.db]==0} { + puts "No f2fs atomic-batch-write support. Skipping tests..." + finish_test + return +} + +reset_db + +do_execsql_test 1.0 { + CREATE TABLE t1(x, y); + BEGIN; + INSERT INTO t1 VALUES(1, 2); +} + +do_test 1.1 { file exists test.db-journal } {0} + +do_execsql_test 1.2 { + COMMIT; +} + + +finish_test From 344f763f7253ef0ca23a2268ea81f9d62bfd8e37 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 28 Jul 2017 13:18:35 +0000 Subject: [PATCH 15/17] Add new extended error codes for the atomic write file-controls. FossilOrigin-Name: 94a2004756ffe027b3495be91366750135c294a9c460edc9a1b4b9422dcc33bd --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/os_unix.c | 6 +++--- src/sqlite.h.in | 3 +++ 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index b03dc42eec..600d9d81fe 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\stest\sfile\stest/atomic.test. -D 2017-07-28T11:05:33.638 +C Add\snew\sextended\serror\scodes\sfor\sthe\satomic\swrite\sfile-controls. +D 2017-07-28T13:18:35.469 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -436,7 +436,7 @@ F src/os.c add02933b1dce7a39a005b00a2f5364b763e9a24 F src/os.h 8e976e59eb4ca1c0fca6d35ee803e38951cb0343 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586 -F src/os_unix.c 9aa19db965d574cbaf74405cd51c58b87fdbfe045b8bbfc01b18bdeeda3c4305 +F src/os_unix.c 0681c6ef336fcb6a111f45b60a5faea38992ed6c4ae9fbd57a6f8e247724fa68 F src/os_win.c 2a6c73eef01c51a048cc4ddccd57f981afbec18a F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a F src/pager.c 1e63b0299cf123cf38c48413ec03190f56c1e7d0ccc6573c467d8ac240b898e9 @@ -455,7 +455,7 @@ F src/rowset.c 7b7e7e479212e65b723bf40128c7b36dc5afdfac F src/select.c c6bf96a7f9d7d68f929de84738c599a30d0a725ab0b54420e70545743cd5ee7b F src/shell.c bd6a37cbe8bf64ef6a6a74fdc50f067d3148149b4ce2b4d03154663e66ded55f F src/shell.c.in b5725acacba95ccefa57b6d068f710e29ba8239c3aa704628a1902a1f729c175 -F src/sqlite.h.in eacc9cd3fa971f6056c0a312a61430df7c8d0b1fc01774e9209becf2c184b251 +F src/sqlite.h.in 91ebe5f8b4e6595325110fb23efe6cc70dfe53d394d2dd31c8b6cdf6a98325e0 F src/sqlite3.rc 5121c9e10c3964d5755191c80dd1180c122fc3a8 F src/sqlite3ext.h 967154985ed2ae62f90d9029bb5b5071793d847f1696a2ebe9e8cc0b042ae60b F src/sqliteInt.h 3cbbcb67ba66ffe44a6768c95df22137335e9ef167d5da93bf0c1ed20a91b992 @@ -1639,7 +1639,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 67bad7fb9b2fdb29b63308f22062444084dc28191a542e08076dc2e39caf6f62 -R f9a806bade742314c2ca4f28e94ea3db -U dan -Z e2b2bd316b28a6b89ebee3e338f870e9 +P f9213e4864d0542be5489e03cf40c47d9127a86bbbbbabd963aa08525d5dc97b +R df00eb2b7872527f1e0cbc6920cf1993 +U drh +Z ff0fbf0bcfb6efb6cc06622fd28cdbe1 diff --git a/manifest.uuid b/manifest.uuid index bcacdd3199..bc9a0c0efb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f9213e4864d0542be5489e03cf40c47d9127a86bbbbbabd963aa08525d5dc97b \ No newline at end of file +94a2004756ffe027b3495be91366750135c294a9c460edc9a1b4b9422dcc33bd \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 430c5386ea..157be3c3ac 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3796,15 +3796,15 @@ static int unixFileControl(sqlite3_file *id, int op, void *pArg){ #if defined(__linux__) && defined(SQLITE_ENABLE_BATCH_ATOMIC_WRITE) case SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: { int rc = osIoctl(pFile->h, F2FS_IOC_START_ATOMIC_WRITE); - return rc ? SQLITE_ERROR : SQLITE_OK; + return rc ? SQLITE_IOERR_BEGIN_ATOMIC : SQLITE_OK; } case SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: { int rc = osIoctl(pFile->h, F2FS_IOC_COMMIT_ATOMIC_WRITE); - return rc ? SQLITE_ERROR : SQLITE_OK; + return rc ? SQLITE_IOERR_COMMIT_ATOMIC : SQLITE_OK; } case SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: { int rc = osIoctl(pFile->h, F2FS_IOC_ABORT_VOLATILE_WRITE); - return rc ? SQLITE_ERROR : SQLITE_OK; + return rc ? SQLITE_IOERR_ROLLBACK_ATOMIC : SQLITE_OK; } #endif /* __linux__ && SQLITE_ENABLE_BATCH_ATOMIC_WRITE */ diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e0d8dacb1c..fec6573e7b 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -494,6 +494,9 @@ int sqlite3_exec( #define SQLITE_IOERR_CONVPATH (SQLITE_IOERR | (26<<8)) #define SQLITE_IOERR_VNODE (SQLITE_IOERR | (27<<8)) #define SQLITE_IOERR_AUTH (SQLITE_IOERR | (28<<8)) +#define SQLITE_IOERR_BEGIN_ATOMIC (SQLITE_IOERR | (29<<8)) +#define SQLITE_IOERR_COMMIT_ATOMIC (SQLITE_IOERR | (30<<8)) +#define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8)) #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8)) #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8)) #define SQLITE_BUSY_SNAPSHOT (SQLITE_BUSY | (2<<8)) From 9e61104c6890fef76d1eebcd80e7c296dcd2f383 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 28 Jul 2017 18:16:14 +0000 Subject: [PATCH 16/17] More precise determination of when an in-memory journal needs to be spilled to disk. FossilOrigin-Name: 6a505bdd9347783d3d8105cb8185aa787801bad0c855b623cfd780fb406f0e7b --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/memjournal.c | 10 +++++++++- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 600d9d81fe..175be09fce 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\snew\sextended\serror\scodes\sfor\sthe\satomic\swrite\sfile-controls. -D 2017-07-28T13:18:35.469 +C More\sprecise\sdetermination\sof\swhen\san\sin-memory\sjournal\sneeds\sto\sbe\nspilled\sto\sdisk. +D 2017-07-28T18:16:14.317 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -424,7 +424,7 @@ F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de F src/mem2.c f1940d9e91948dd6a908fbb9ce3835c36b5d83c3 F src/mem3.c 8768ac94694f31ffaf8b4d0ea5dc08af7010a35a F src/mem5.c 9bf955937b07f8c32541c8a9991f33ce3173d944 -F src/memjournal.c 9b9e579226341e891a4657dc76fe2cec69734abcd23be0e42aa8764d88131f12 +F src/memjournal.c 6f3d36a0a8f72f48f6c3c722f04301ac64f2515435fa42924293e46fc7994661 F src/msvc.h 4942752b6a253116baaa8de75256c51a459a5e81 F src/mutex.c 8e45800ee78e0cd1f1f3fe8e398853307f4a085c F src/mutex.h 779d588e3b7756ec3ecf7d78cde1d84aba414f85 @@ -1639,7 +1639,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 f9213e4864d0542be5489e03cf40c47d9127a86bbbbbabd963aa08525d5dc97b -R df00eb2b7872527f1e0cbc6920cf1993 +P 94a2004756ffe027b3495be91366750135c294a9c460edc9a1b4b9422dcc33bd +R 86ba3bf27ee71fb4aea5fe3f1aba5d47 U drh -Z ff0fbf0bcfb6efb6cc06622fd28cdbe1 +Z 81ac04bf34607e329fe9d94777807b23 diff --git a/manifest.uuid b/manifest.uuid index bc9a0c0efb..f196242728 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -94a2004756ffe027b3495be91366750135c294a9c460edc9a1b4b9422dcc33bd \ No newline at end of file +6a505bdd9347783d3d8105cb8185aa787801bad0c855b623cfd780fb406f0e7b \ No newline at end of file diff --git a/src/memjournal.c b/src/memjournal.c index 31ab5ef93f..3b0e7a6728 100644 --- a/src/memjournal.c +++ b/src/memjournal.c @@ -397,7 +397,15 @@ void sqlite3MemJournalOpen(sqlite3_file *pJfd){ int sqlite3JournalCreate(sqlite3_file *pJfd){ int rc = SQLITE_OK; MemJournal *p = (MemJournal*)pJfd; - if( p->pMethod==&MemJournalMethods && (p->nSpill>0 + if( p->pMethod==&MemJournalMethods && ( +#ifdef SQLITE_ENABLE_ATOMIC_WRITE + p->nSpill>0 +#else + /* While this appears to not be possible without ATOMIC_WRITE, the + ** paths are complex, so it seems prudent to leave the test in as + ** a NEVER(), in case our analysis is subtly flawed. */ + NEVER(p->nSpill>0) +#endif #ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE || (p->flags & SQLITE_OPEN_MAIN_JOURNAL) #endif From 2fc2f92ed6cad3822f5bacf57040e2d4c61cd859 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 28 Jul 2017 20:49:02 +0000 Subject: [PATCH 17/17] Disable the writecrash.test module on Windows. FossilOrigin-Name: 4c0520d4df7473eb4cc764774df7d99bb96cf067ac224755e09f0df47fb2a810 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/writecrash.test | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 175be09fce..351fec8523 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C More\sprecise\sdetermination\sof\swhen\san\sin-memory\sjournal\sneeds\sto\sbe\nspilled\sto\sdisk. -D 2017-07-28T18:16:14.317 +C Disable\sthe\swritecrash.test\smodule\son\sWindows. +D 2017-07-28T20:49:02.901 F Makefile.in d9873c9925917cca9990ee24be17eb9613a668012c85a343aef7e5536ae266e8 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434 F Makefile.msc 02b469e9dcd5b7ee63fc1fb05babc174260ee4cfa4e0ef2e48c3c6801567a016 @@ -1543,7 +1543,7 @@ F test/without_rowid4.test 4e08bcbaee0399f35d58b5581881e7a6243d458a F test/without_rowid5.test 89b1c587bd92a0590e440da33e7666bf4891572a F test/without_rowid6.test 1f99644e6508447fb050f73697350c7ceca3392e F test/wordcount.c 06efb84b7c48a4973c2c24ea06c93d00bce24389 -F test/writecrash.test e6dc9d470d43710c3f780a50d29cce1c3884ca34ff50e737bc9ab8724c7c2398 +F test/writecrash.test f1da7f7adfe8d7f09ea79b42e5ca6dcc41102f27f8e334ad71539501ddd910cc F test/zeroblob.test 3857870fe681b8185654414a9bccfde80b62a0fa F test/zerodamage.test e59a56443d6298ecf7435f618f0b27654f0c849e F tool/GetFile.cs a15e08acb5dd7539b75ba23501581d7c2b462cb5 @@ -1639,7 +1639,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 94a2004756ffe027b3495be91366750135c294a9c460edc9a1b4b9422dcc33bd -R 86ba3bf27ee71fb4aea5fe3f1aba5d47 +P 6a505bdd9347783d3d8105cb8185aa787801bad0c855b623cfd780fb406f0e7b +R a1d9f1b06fb7a9cab059484be0d2ec0b U drh -Z 81ac04bf34607e329fe9d94777807b23 +Z f25cf82f472085f11871c2d253c31dfe diff --git a/manifest.uuid b/manifest.uuid index f196242728..ba62037fe0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6a505bdd9347783d3d8105cb8185aa787801bad0c855b623cfd780fb406f0e7b \ No newline at end of file +4c0520d4df7473eb4cc764774df7d99bb96cf067ac224755e09f0df47fb2a810 \ No newline at end of file diff --git a/test/writecrash.test b/test/writecrash.test index 25fe6b423f..01bc4dbb56 100644 --- a/test/writecrash.test +++ b/test/writecrash.test @@ -20,6 +20,12 @@ set testprefix writecrash do_not_use_codec + +if {$tcl_platform(platform)=="windows"} { + finish_test + return +} + do_execsql_test 1.0 { CREATE TABLE t1(a INTEGER PRIMARY KEY, b BLOB UNIQUE); WITH s(i) AS (