From 0ec8c565672ab8526a4f6125d96bc41e2ac24f90 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 24 Nov 2025 11:22:56 +0000 Subject: [PATCH] Remove the the SQLITE_SYNC_DATAONLY flag from the core on the grounds that it is not currently used by either built-in VFS and is therefore untested. FossilOrigin-Name: ff2065b533769cbf5278d13d09ffa93a7a0f841b1b59b6be0e5f27e3d1c341d0 --- manifest | 28 +++++++++++++++------------- manifest.tags | 4 ++-- manifest.uuid | 2 +- src/os_unix.c | 42 ++++++++++++++++-------------------------- src/pager.c | 6 ++---- src/sqlite.h.in | 4 +--- src/test_onefile.c | 2 +- src/test_vfs.c | 6 ------ test/vacuum-into.test | 2 +- 9 files changed, 39 insertions(+), 57 deletions(-) diff --git a/manifest b/manifest index 6b87377f98..fb20827ee9 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\slong-missing\ssqlite3_next_stmt()\sbinding\sto\sJS/WASM. -D 2025-11-23T22:18:26.469 +C Remove\sthe\sthe\sSQLITE_SYNC_DATAONLY\sflag\sfrom\sthe\score\son\sthe\sgrounds\sthat\sit\sis\snot\scurrently\sused\sby\seither\sbuilt-in\sVFS\sand\sis\stherefore\suntested. +D 2025-11-24T11:22:56.683 F .fossil-settings/binary-glob 61195414528fb3ea9693577e1980230d78a1f8b0a54c78cf1b9b24d0a409ed6a x F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea @@ -719,10 +719,10 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06 F src/os_kv.c fb7ba8d6204197357f1eb7e1c7450d09c10043bf7e99aba602f4aa46b8fb11a3 F src/os_setup.h 8efc64eda6a6c2f221387eefc2e7e45fd5a3d5c8337a7a83519ba4fbd2957ae2 -F src/os_unix.c 7945ede1e85b2d1b910e1b4af9ba342e964b1e30e79f4176480a60736445cb36 +F src/os_unix.c bf55d195730393a9faf31dcec65257710c61f61a728342151af06a8267ffb35d F src/os_win.c a89b501fc195085c7d6c9eec7f5bd782625e94bb2a96b000f4d009703df1083f F src/os_win.h 4c247cdb6d407c75186c94a1e84d5a22cbae4adcec93fcae8d2bc1f956fd1f19 -F src/pager.c a81461de271ac4886ad75b7ca2cca8157a48635820c4646cd2714acdc2c17e5f +F src/pager.c 52bae5ea11f25cbdc425be7b0a8c3310b3ec2a1381e73b5d5b6af20c26094108 F src/pager.h 6137149346e6c8a3ddc1eeb40aee46381e9bc8b0fcc6dda8a1efde993c2275b8 F src/parse.y 424d195ea70f4656a3f6440e0b79ca8f712ae4da9431033a19ec8c9816469287 F src/pcache.c 588cc3c5ccaaadde689ed35ce5c5c891a1f7b1f4d1f56f6cf0143b74d8ee6484 @@ -736,7 +736,7 @@ F src/resolve.c 5616fbcf3b833c7c705b24371828215ad0925d0c0073216c4f153348d5753f0a F src/rowset.c 8432130e6c344b3401a8874c3cb49fefe6873fec593294de077afea2dce5ec97 F src/select.c ba9cd07ffa3277883c1986085f6ddc4320f4d35d5f212ab58df79a7ecc1a576a F src/shell.c.in 7f4a56ac62b5030755e72c5a9598b45782a0deccba350605b13d6d7b48e58b2d -F src/sqlite.h.in f1363321ca55cc2feaa289e9fe6dfb08102a28c54edf005564711a2348b06eef +F src/sqlite.h.in b5b2450724c9aa2d7ae2861c881385bc21ba940c79122c893f5ae9bb36ad10dd F src/sqlite3.rc 015537e6ac1eec6c7050e17b616c2ffe6f70fca241835a84a4f0d5937383c479 F src/sqlite3ext.h 5d5330f5f8461f5ce74960436ddcfa53ecd09c2b8b23901e22ae38aec3243998 F src/sqliteInt.h a89c3a9296928dffcb4c287df176a739f9cf620c7c9d33aec59e8efb9b39cbbd @@ -775,7 +775,7 @@ F src/test_md5.c 811a45330c9391933360f998156a8907ee29909c828ab83ac05d329942cbea8 F src/test_multiplex.c 82f0aa8eee629b6949782cfab8782ed35a9b56dc80d12877af52147f304d22b8 F src/test_multiplex.h f0ff5b6f4462bfd46dac165d6375b9530d08089b7bcbe75e88e0926110db5363 F src/test_mutex.c dacae6790956c0d4e705aaed2090227792e291b0496cccd688e9994c1e21f740 -F src/test_onefile.c f31e52e891c5fef6709b9fcef54ce660648a34172423a9cbdf4cbce3ba0049f4 +F src/test_onefile.c f52ae709489837863521e6e0e1a8965b6716d45f784445b98641b6ce0fc2137b F src/test_osinst.c 269039d9c0820a02ee928014c30860d57ee757ecda54df42e463d0ca1377b835 F src/test_pcache.c 496da3f7e2ca66aefbc36bbf22138b1eff43ba0dff175c228b760fa020a37bd0 F src/test_quota.c 180e87437250bed7e17e4e61c106730939e39fec9be73d28961f27f579a92078 @@ -789,7 +789,7 @@ F src/test_tclsh.c c01706ac60bd3176754d3ccd37da74c6ad97c2e14489f8ed71b497c1c0ac0 F src/test_tclvar.c ae873248a0188459b1c16ca7cc431265dacce524399e8b46725c2b3b7e048424 F src/test_thread.c 3edb4a5b5aeb1a6e9a275dccc848ac95acab7f496b3e9230f6d2d04953a2b862 F src/test_vdbecov.c 5c426d9cd2b351f5f9ceb30cabf8c64a63bfcad644c507e0bd9ce2f6ae1a3bf3 -F src/test_vfs.c b4135c1308516adf0dfd494e6d6c33114e03732be899eace0502919b674586b5 +F src/test_vfs.c 7b06f2f82584a9e723e62cb6894d60d21dc4cd9bcd02d6de976e5434e5d60a30 F src/test_window.c 6d80e11fba89a1796525e6f0048ff0c7789aa2c6b0b11c80827dc1437bd8ea72 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 F src/threads.c 4ae07fa022a3dc7c5beb373cf744a85d3c5c6c3c @@ -1925,7 +1925,7 @@ F test/upsertfault.test f21ca47740841fdb4d61acfa7b17646d773e67724fe8c185b71c018d F test/uri.test 1250724af9beeed2d6c3716f5b990c483200c54f408d3c0ec9543a3c7961f8fc F test/uri2.test 9d3ba7a53ee167572d53a298ee4a5d38ec4a8fb7 F test/utf16align.test 9fde0bb5d3a821594aa68c6829ab9c5453a084384137ebb9f6153e2d678039da -F test/vacuum-into.test 5a489714feecfdabfc7b293be4111564a173dee92c0d6818dd0207f3ade65783 +F test/vacuum-into.test ebd223213fde4c985818b9d6dc33fe29a7cdd4272738d82e3e14aa2e686d228b F test/vacuum.test f3b2257a4fcd659513c866a5d9e5f70999cc58fd5d74e979290385fa350b79ee F test/vacuum2.test 9fd45ce6ce29f5614c249e03938d3567c06a9e772d4f155949f8eafe2d8af520 F test/vacuum3.test d9d9a04ee58c485b94694fd4f68cffaba49c32234fdefe1ac1a622c5e17d4ce3 @@ -2179,9 +2179,11 @@ F tool/version-info.c 33d0390ef484b3b1cb685d59362be891ea162123cea181cb8e6d2cf6dd F tool/warnings-clang.sh bbf6a1e685e534c92ec2bfba5b1745f34fb6f0bc2a362850723a9ee87c1b31a7 F tool/warnings.sh d924598cf2f55a4ecbc2aeb055c10bd5f48114793e7ba25f9585435da29e7e98 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f -P 6d01f9f49eef5f7d4bddadc458691b6ca36e277bae1d4b43b60a128a44e3faca -Q +53a99ff4ed5ef5f8620bf324a4f7a1d0812f5c80311228eb820039430ca04bd5 -R 515a3a81ebc9373c74089cfbe119fc8c -U stephan -Z 7b4c76955b7cff921337deda4dac0ebb +P de27d2d3f2353309227b4d5f77eff76c108c094b61ac59f5a769229a084f2567 +R b3a6bdd7591660f0d3db476c840596b8 +T *branch * remove-sync-dataonly +T *sym-remove-sync-dataonly * +T -sym-trunk * +U dan +Z 1d7edb159c9d5f32f5cc7510cd06382b # Remove this line to create a well-formed Fossil manifest. diff --git a/manifest.tags b/manifest.tags index bec971799f..d0ddf3ce0a 100644 --- a/manifest.tags +++ b/manifest.tags @@ -1,2 +1,2 @@ -branch trunk -tag trunk +branch remove-sync-dataonly +tag remove-sync-dataonly diff --git a/manifest.uuid b/manifest.uuid index bee0d28dd5..08a2b8ad65 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -de27d2d3f2353309227b4d5f77eff76c108c094b61ac59f5a769229a084f2567 +ff2065b533769cbf5278d13d09ffa93a7a0f841b1b59b6be0e5f27e3d1c341d0 diff --git a/src/os_unix.c b/src/os_unix.c index 6b679c4dcd..8edecbea54 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -3756,20 +3756,18 @@ int sqlite3_fullsync_count = 0; ** enabled, however, since with SQLITE_NO_SYNC enabled, an OS crash ** or power failure will likely corrupt the database file. ** -** SQLite sets the dataOnly flag if the size of the file is unchanged. -** The idea behind dataOnly is that it should only write the file content -** to disk, not the inode. We only set dataOnly if the file size is -** unchanged since the file size is part of the inode. However, -** Ted Ts'o tells us that fdatasync() will also write the inode if the -** file size has changed. The only real difference between fdatasync() -** and fsync(), Ted tells us, is that fdatasync() will not flush the -** inode if the mtime or owner or other inode attributes have changed. -** We only care about the file size, not the other file attributes, so -** as far as SQLite is concerned, an fdatasync() is always adequate. -** So, we always use fdatasync() if it is available, regardless of -** the value of the dataOnly flag. -*/ -static int full_fsync(int fd, int fullSync, int dataOnly){ +** At one point we attempted to pass a flag to this function if the +** file-size had not changed to tell it to use fdatasync() instead of +** fsync() in this case. However, Ted Ts'o tells us that fdatasync() will +** also write the inode if the file size has changed. The only real +** difference between fdatasync() and fsync(), Ted tells us, is that +** fdatasync() will not flush the inode if the mtime or owner or other +** inode attributes have changed. We only care about the file size, not +** the other file attributes, so as far as SQLite is concerned, an +** fdatasync() is always adequate. So, we always use fdatasync() if it is +** available. +*/ +static int full_fsync(int fd, int fullSync){ int rc; /* The following "ifdef/elif/else/" block has the same structure as @@ -3779,12 +3777,9 @@ static int full_fsync(int fd, int fullSync, int dataOnly){ #ifdef SQLITE_NO_SYNC UNUSED_PARAMETER(fd); UNUSED_PARAMETER(fullSync); - UNUSED_PARAMETER(dataOnly); #elif HAVE_FULLFSYNC - UNUSED_PARAMETER(dataOnly); #else UNUSED_PARAMETER(fullSync); - UNUSED_PARAMETER(dataOnly); #endif /* Record the number of times that we do a normal fsync() and @@ -3890,10 +3885,6 @@ static int openDirectory(const char *zFilename, int *pFd){ /* ** Make sure all writes to a particular file are committed to disk. ** -** If dataOnly==0 then both the file itself and its metadata (file -** size, access time, etc) are synced. If dataOnly!=0 then only the -** file data is synced. -** ** Under Unix, also make sure that the directory entry for the file ** has been created by fsync-ing the directory that contains the file. ** If we do not do this and we encounter a power failure, the directory @@ -3906,7 +3897,6 @@ static int unixSync(sqlite3_file *id, int flags){ int rc; unixFile *pFile = (unixFile*)id; - int isDataOnly = (flags&SQLITE_SYNC_DATAONLY); int isFullsync = (flags&0x0F)==SQLITE_SYNC_FULL; /* Check that one of SQLITE_SYNC_NORMAL or FULL was passed */ @@ -3921,7 +3911,7 @@ static int unixSync(sqlite3_file *id, int flags){ assert( pFile ); OSTRACE(("SYNC %-3d\n", pFile->h)); - rc = full_fsync(pFile->h, isFullsync, isDataOnly); + rc = full_fsync(pFile->h, isFullsync); SimulateIOError( rc=1 ); if( rc ){ storeLastErrno(pFile, errno); @@ -3938,7 +3928,7 @@ static int unixSync(sqlite3_file *id, int flags){ HAVE_FULLFSYNC, isFullsync)); rc = osOpenDirectory(pFile->zPath, &dirfd); if( rc==SQLITE_OK ){ - full_fsync(dirfd, 0, 0); + full_fsync(dirfd, 0); robust_close(pFile, dirfd, __LINE__); }else{ assert( rc==SQLITE_CANTOPEN ); @@ -6854,7 +6844,7 @@ static int unixDelete( int fd; rc = osOpenDirectory(zPath, &fd); if( rc==SQLITE_OK ){ - if( full_fsync(fd,0,0) ){ + if( full_fsync(fd, 0) ){ rc = unixLogError(SQLITE_IOERR_DIR_FSYNC, "fsync", zPath); } robust_close(0, fd, __LINE__); @@ -7910,7 +7900,7 @@ static int proxyTakeConch(unixFile *pFile){ writeSize = PROXY_PATHINDEX + strlen(&writeBuffer[PROXY_PATHINDEX]); robust_ftruncate(conchFile->h, writeSize); rc = unixWrite((sqlite3_file *)conchFile, writeBuffer, writeSize, 0); - full_fsync(conchFile->h,0,0); + full_fsync(conchFile->h, 0); /* If we created a new conch file (not just updated the contents of a ** valid conch file), try to match the permissions of the database */ diff --git a/src/pager.c b/src/pager.c index 1e03b87ec0..b2087a275c 100644 --- a/src/pager.c +++ b/src/pager.c @@ -1400,7 +1400,7 @@ static int zeroJournalHdr(Pager *pPager, int doTruncate){ rc = sqlite3OsWrite(pPager->jfd, zeroHdr, sizeof(zeroHdr), 0); } if( rc==SQLITE_OK && !pPager->noSync ){ - rc = sqlite3OsSync(pPager->jfd, SQLITE_SYNC_DATAONLY|pPager->syncFlags); + rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags); } /* At this point the transaction is committed but the write lock @@ -4367,9 +4367,7 @@ static int syncJournal(Pager *pPager, int newHdr){ if( 0==(iDc&SQLITE_IOCAP_SEQUENTIAL) ){ PAGERTRACE(("SYNC journal of %d\n", PAGERID(pPager))); IOTRACE(("JSYNC %p\n", pPager)) - rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags| - (pPager->syncFlags==SQLITE_SYNC_FULL?SQLITE_SYNC_DATAONLY:0) - ); + rc = sqlite3OsSync(pPager->jfd, pPager->syncFlags); if( rc!=SQLITE_OK ) return rc; } diff --git a/src/sqlite.h.in b/src/sqlite.h.in index b10cbdd4e5..f1ae79834b 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -766,9 +766,7 @@ struct sqlite3_file { ** ** The flags argument to xSync may be one of [SQLITE_SYNC_NORMAL] or ** [SQLITE_SYNC_FULL]. The first choice is the normal fsync(). -** The second choice is a Mac OS X style fullsync. The [SQLITE_SYNC_DATAONLY] -** flag may be ORed in to indicate that only the data of the file -** and not its inode needs to be synced. +** The second choice is a Mac OS X style fullsync. ** ** The integer values to xLock() and xUnlock() are one of **