SQLite

Check-in [3925a5b9]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Handle the case where unix-dotfile is used with URI parameter nolock=1.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | unix-dotfile-fix
Files: files | file ages | folders
SHA3-256: 3925a5b904e159d54455cfc73fe837a9c6ea3a6d60da63afde3242b4d6f67c90
User & Date: dan 2024-06-11 20:28:56
Context
2024-06-12
11:41
Do not attempt to run hot journal rollback tests in lock5.test with the "inmemory_journal" permutation, which cannot generate hot journals. (check-in: 1e6fa95b user: dan tags: unix-dotfile-fix)
2024-06-11
20:28
Handle the case where unix-dotfile is used with URI parameter nolock=1. (check-in: 3925a5b9 user: dan tags: unix-dotfile-fix)
20:03
Fix a problem with rolling back hot journals using the unix-dotfile VFS. (check-in: 4ae3300b user: dan tags: unix-dotfile-fix)
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288

2289

2290
2291




2292
2293
2294
2295
2296
2297
2298
** The file suffix added to the data base filename in order to create the
** lock directory.
*/
#define DOTLOCK_SUFFIX ".lock"

/*
** 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.
*/
static int dotlockCheckReservedLock(sqlite3_file *id, int *pResOut) {

  SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );

  assert( ((unixFile*)id)->eFileLock>=SHARED_LOCK );
  *pResOut = 0;




  return SQLITE_OK;
}

/*
** Lock the file with the lock specified by parameter eFileLock - one
** of the following:
**







|
|
|
<
|


>

>
|
|
>
>
>
>







2275
2276
2277
2278
2279
2280
2281
2282
2283
2284

2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
** The file suffix added to the data base filename in order to create the
** lock directory.
*/
#define DOTLOCK_SUFFIX ".lock"

/*
** This routine checks if there is a RESERVED lock held on the specified
** 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; );

  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;
}

/*
** Lock the file with the lock specified by parameter eFileLock - one
** of the following:
**

Changes to test/lock5.test.

248
249
250
251
252
253
254












255
256
257
do_test 2.dotfile.5 {
  file delete test.db2.lock
  execsql {
    PRAGMA integrity_check
  } db2
} {ok}













finish_test









>
>
>
>
>
>
>
>
>
>
>
>



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
do_test 2.dotfile.5 {
  file delete test.db2.lock
  execsql {
    PRAGMA integrity_check
  } 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