]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Handle the case where unix-dotfile is used with URI parameter nolock=1.
authordan <Dan Kennedy>
Tue, 11 Jun 2024 20:28:56 +0000 (20:28 +0000)
committerdan <Dan Kennedy>
Tue, 11 Jun 2024 20:28:56 +0000 (20:28 +0000)
FossilOrigin-Name: 3925a5b904e159d54455cfc73fe837a9c6ea3a6d60da63afde3242b4d6f67c90

manifest
manifest.uuid
src/os_unix.c
test/lock5.test

index dbd86925eb5be254e93859796550afee5430c05f..cf3caa1cb2446380da0599c46cf5694136089f32 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\sproblem\swith\srolling\sback\shot\sjournals\susing\sthe\sunix-dotfile\sVFS.
-D 2024-06-11T20:03:32.695
+C Handle\sthe\scase\swhere\sunix-dotfile\sis\sused\swith\sURI\sparameter\snolock=1.
+D 2024-06-11T20:28:56.529
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -739,7 +739,7 @@ F src/os.h 1ff5ae51d339d0e30d8a9d814f4b8f8e448169304d83a7ed9db66a65732f3e63
 F src/os_common.h 6c0eb8dd40ef3e12fe585a13e709710267a258e2c8dd1c40b1948a1d14582e06
 F src/os_kv.c 4d39e1f1c180b11162c6dc4aa8ad34053873a639bac6baae23272fc03349986a
 F src/os_setup.h 6011ad7af5db4e05155f385eb3a9b4470688de6f65d6166b8956e58a3d872107
-F src/os_unix.c 582eb7e4aa4fee66dd9475cf7325a6753890266020ba1670c36ed8b9babd5a46
+F src/os_unix.c 2ea8d3ed496b8d1f9332a9505653424e5464fd797ea9d91f8e2e62f9dd0298d0
 F src/os_win.c 6ff43bac175bd9ed79e7c0f96840b139f2f51d01689a638fd05128becf94908a
 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
 F src/pager.c 9beb80f6e330dd63c5d8ba0f7a7f3a55fff22067a68d424949c389bfc6fa0c56
@@ -1388,7 +1388,7 @@ F test/lock.test be4fe08118fb988fed741f429b7dd5d65e1c90db
 F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff
 F test/lock3.test f271375930711ae044080f4fe6d6eda930870d00
 F test/lock4.test 27143363eda1622f03c133efc8db808fc331afd973486cb571ea71cd717d37b8
-F test/lock5.test 69d7991e39c3fade9b6e46403c1386bcd21a4808796c9c6f60f17d0fdcec266f
+F test/lock5.test e6d5a7dd3c3c2ad83b05dbd50d0bd8b2a98a13ce6b2f3297e0edfbebb3413de3
 F test/lock6.test ad5b387a3a8096afd3c68a55b9535056431b0cf5
 F test/lock7.test 49f1eaff1cdc491cc5dee3669f3c671d9f172431
 F test/lock_common.tcl 2f3f7f2e9637f93ccf609df48ef5b27a50278b6b1cd752b445d52262e5841413
@@ -2195,11 +2195,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 6935ac71bad3d36cc519f0325ae4447a674f257309d020cdc0741160fcce0580
-R a6be376671415b32f13dc00f1cf159ee
-T *branch * unix-dotfile-fix
-T *sym-unix-dotfile-fix *
-T -sym-trunk *
+P 4ae3300b79e03381fd7f1033bb7978bb6367369790f17c3bdacac51e205edaf9
+R f4ac66d6cce3f1556fd45b9db23cb700
 U dan
-Z 82729b2f1037b9035a8ecef1ba94fcd8
+Z 59b7d2f0f8fc06cadab577170f885282
 # Remove this line to create a well-formed Fossil manifest.
index 78f90430a4b2a22b629d27103f781a82a13ce902..48f2de2bc70fd0a519d00f0d14801dedd7339c42 100644 (file)
@@ -1 +1 @@
-4ae3300b79e03381fd7f1033bb7978bb6367369790f17c3bdacac51e205edaf9
\ No newline at end of file
+3925a5b904e159d54455cfc73fe837a9c6ea3a6d60da63afde3242b4d6f67c90
\ No newline at end of file
index 45ba0c001d0226c6e0524065f48ecc3466f588ff..c94c0c111f49b7f7d23c716235157196109fcba2 100644 (file)
@@ -2279,16 +2279,21 @@ static int nolockClose(sqlite3_file *id) {
 
 /*
 ** This routine checks if there is a RESERVED lock held on the specified
-** file by this or any other process. The caller always holds a SHARED
-** lock when it is called. This means that no other connection could
-** hold a RESERVED lock, as unix-dotfile uses just a single exclusive lock -
-** the presence of the dotfile - for all 4 VFS locks. So this function sets
-** (*pResOut) to 0 (no other connection holds RESERVED) and returns SQLITE_OK.
+** file by this or any other process. If the caller holds a SHARED
+** or greater lock when it is called, then it is assumed that no other
+** client may hold RESERVED. Or, if the caller holds no lock, then it
+** is assumed another client holds RESERVED if the lock-file exists.
 */
 static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {
+  unixFile *pFile = (unixFile*)id;
   SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
-  assert( ((unixFile*)id)->eFileLock>=SHARED_LOCK );
-  *pResOut = 0;
+
+  if( pFile->eFileLock>=SHARED_LOCK ){
+    *pResOut = 0;
+  }else{
+    *pResOut = osAccess((const char*)pFile->lockingContext, 0)==0;
+  }
+  OSTRACE(("TEST WR-LOCK %d %d %d (dotlock)\n", pFile->h, 0, *pResOut));
   return SQLITE_OK;
 }
 
index 6e26f9dd02c260b4580730cba67222a515704df1..0e1669f1b1e988cb3c8bd1834b4777d81c8aeb09 100644 (file)
@@ -252,6 +252,18 @@ do_test 2.dotfile.5 {
   } db2
 } {ok}
 
+db2 close
+
+do_test 2.dotfile.6 {
+  forcecopy test.db test.db2
+  forcecopy test.db-journal test.db2-journal
+
+  sqlite3 db2 file:test.db2?nolock=1 -vfs unix-dotfile -uri 1
+  catchsql {
+    SELECT count(*) FROM t1;
+  } db2
+} {0 1000}
+
 finish_test