mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-15 11:41:13 +03:00
Attempt to clarify the operation of the xLock and xUnlock VFS I/O methods.
Assert() statements added to prove that they behave as the documentation says. FossilOrigin-Name: 3efa811251d4510a074231a1e0b667783cc5f90777466b9dcae675cd9892b423
This commit is contained in:
2
src/os.c
2
src/os.c
@@ -106,9 +106,11 @@ int sqlite3OsFileSize(sqlite3_file *id, i64 *pSize){
|
||||
}
|
||||
int sqlite3OsLock(sqlite3_file *id, int lockType){
|
||||
DO_OS_MALLOC_TEST(id);
|
||||
assert( lockType>=SQLITE_LOCK_SHARED && lockType<=SQLITE_LOCK_EXCLUSIVE );
|
||||
return id->pMethods->xLock(id, lockType);
|
||||
}
|
||||
int sqlite3OsUnlock(sqlite3_file *id, int lockType){
|
||||
assert( lockType==SQLITE_LOCK_NONE || lockType==SQLITE_LOCK_SHARED );
|
||||
return id->pMethods->xUnlock(id, lockType);
|
||||
}
|
||||
int sqlite3OsCheckReservedLock(sqlite3_file *id, int *pResOut){
|
||||
|
||||
@@ -670,13 +670,17 @@ int sqlite3_exec(
|
||||
**
|
||||
** SQLite uses one of these integer values as the second
|
||||
** argument to calls it makes to the xLock() and xUnlock() methods
|
||||
** of an [sqlite3_io_methods] object.
|
||||
** of an [sqlite3_io_methods] object. These values are ordered from
|
||||
** lest restrictive to most restrictive.
|
||||
**
|
||||
** The argument to xLock() is always SHARED or higher. The argument to
|
||||
** xUnlock is either SHARED or NONE.
|
||||
*/
|
||||
#define SQLITE_LOCK_NONE 0
|
||||
#define SQLITE_LOCK_SHARED 1
|
||||
#define SQLITE_LOCK_RESERVED 2
|
||||
#define SQLITE_LOCK_PENDING 3
|
||||
#define SQLITE_LOCK_EXCLUSIVE 4
|
||||
#define SQLITE_LOCK_NONE 0 /* xUnlock() only */
|
||||
#define SQLITE_LOCK_SHARED 1 /* xLock() or xUnlock() */
|
||||
#define SQLITE_LOCK_RESERVED 2 /* xLock() only */
|
||||
#define SQLITE_LOCK_PENDING 3 /* xLock() only */
|
||||
#define SQLITE_LOCK_EXCLUSIVE 4 /* xLock() only */
|
||||
|
||||
/*
|
||||
** CAPI3REF: Synchronization Type Flags
|
||||
@@ -754,7 +758,14 @@ struct sqlite3_file {
|
||||
** <li> [SQLITE_LOCK_PENDING], or
|
||||
** <li> [SQLITE_LOCK_EXCLUSIVE].
|
||||
** </ul>
|
||||
** xLock() increases the lock. xUnlock() decreases the lock.
|
||||
** xLock() upgrades the database file lock. In other words, xLock() moves the
|
||||
** database file lock in the direction NONE toward EXCLUSIVE. The argument to
|
||||
** xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
|
||||
** SQLITE_LOCK_NONE. If the database file lock is already at or above the
|
||||
** requested lock, then the call to xLock() is a no-op.
|
||||
** xUnlock() downgrades the database file lock to either SHARED or NONE.
|
||||
* If the lock is already at or below the requested lock state, then the call
|
||||
** to xUnlock() is a no-op.
|
||||
** The xCheckReservedLock() method checks whether any database connection,
|
||||
** either in this process or in some other process, is holding a RESERVED,
|
||||
** PENDING, or EXCLUSIVE lock on the file. It returns true
|
||||
@@ -859,9 +870,8 @@ struct sqlite3_io_methods {
|
||||
** opcode causes the xFileControl method to write the current state of
|
||||
** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
|
||||
** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
|
||||
** into an integer that the pArg argument points to. This capability
|
||||
** is used during testing and is only available when the SQLITE_TEST
|
||||
** compile-time option is used.
|
||||
** into an integer that the pArg argument points to.
|
||||
** This capability is only available if SQLite is compiled with [SQLITE_DEBUG].
|
||||
**
|
||||
** <li>[[SQLITE_FCNTL_SIZE_HINT]]
|
||||
** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
|
||||
|
||||
Reference in New Issue
Block a user