Lines Matching defs:lock

770 #define SQLITE_PROTOCOL    15   /* Database lock protocol error */
1071 ** xLock() upgrades the database file lock. In other words, xLock() moves the
1072 ** database file lock in the direction NONE toward EXCLUSIVE. The argument to
1074 ** SQLITE_LOCK_NONE. If the database file lock is already at or above the
1075 ** requested lock, then the call to xLock() is a no-op.
1076 ** xUnlock() downgrades the database file lock to either SHARED or NONE.
1077 * If the lock is already at or below the requested lock state, then the call
1081 ** PENDING, or EXCLUSIVE lock on the file. It returns true
1082 ** if such a lock exists and false otherwise.
1092 ** about the status of a lock, or to break stale locks. The SQLite
1181 ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
1402 ** be advantageous to block on the next WAL lock if the lock is not immediately
1453 ** obtain a file lock using the xLock or xShmLock methods of the VFS.
1853 ** was given on the corresponding lock.
1870 ** lock outside of this range
3043 ** is returned immediately upon encountering the lock. ^If the busy callback
3057 ** when there is lock contention. ^If SQLite determines that invoking the busy
3061 ** Consider a scenario where one process is holding a read lock that
3062 ** it is trying to promote to a reserved lock and
3063 ** a second process is holding a reserved lock that it is trying
3064 ** to promote to an exclusive lock. The first process cannot proceed
3069 ** will induce the first process to release its read lock and allow
9308 ** ^If sqlite3_backup_step() cannot obtain a required file-system lock, then
9311 ** busy-handler returns non-zero before the lock is available, then
9325 ** ^The first call to sqlite3_backup_step() obtains an exclusive lock
9326 ** on the destination file. ^The exclusive lock is not released until either
9329 ** sqlite3_backup_step() obtains a [shared lock] on the source database that
9430 ** when the connection currently holding the required lock relinquishes it.
9440 ** shared-cache lock and SQLITE_LOCKED is returned to the caller, the
9456 ** ^If the blocked connection is attempting to obtain a write-lock on a
9458 ** a read-lock on the same table, then SQLite arbitrarily selects one of
9625 ** the associated write-lock on the database released)^, so the implementation
9762 ** ^All calls obtain an exclusive "checkpoint" lock on the database file. ^If
9764 ** lock cannot be obtained and SQLITE_BUSY is returned. ^Even if there is a
9768 ** exclusive "writer" lock on the database file. ^If the writer lock cannot be
9770 ** the writer lock retried until either the busy-handler returns 0 or the lock
9773 ** the writer lock is obtained or while waiting for database readers, the
10379 ** in the usual manner. ^If the required lock still cannot be obtained, then
15022 ** SHARED: Any number of processes may hold a SHARED lock simultaneously.
15023 ** RESERVED: A single process may hold a RESERVED lock on a file at
15025 ** PENDING: A single process may hold a PENDING lock on a file at
15028 ** EXCLUSIVE: An EXCLUSIVE lock precludes all other locks.
15031 ** process that requests an EXCLUSIVE lock may actually obtain a PENDING
15032 ** lock. This can be upgraded to an EXCLUSIVE lock by a subsequent call to
15050 ** byte out of a specific range of bytes. The lock byte is obtained at
15052 ** same time, unless they are unlucky and choose the same lock byte.
15055 ** a single byte of the file that is designated as the reserved lock byte.
15061 ** are used, the lock is placed on the same range of bytes that is used
15064 ** But a single Win95 reader will lock out all WinNT readers and a single
15065 ** WinNT reader will lock out all other Win95 readers.
15069 ** a random byte is selected for a shared lock. The pool of bytes for
19190 int nVtabLock; /* Number of virtual tables to lock */
22879 yDbMask lockMask; /* Subset of btreeMask that requires a lock */
28192 pthread_mutex_t mutex; /* Mutex controlling the lock */
28677 CRITICAL_SECTION mutex; /* Mutex controlling the lock */
29267 ** lock is already held.
36555 ** Check if another file-handle holds a RESERVED lock on an kvvfs-file.
36994 unsigned char eFileLock; /* The type of lock held on this fd */
37575 ** integer lock-type.
37849 ** sets or clears a lock, that operation overrides any prior locks set
37859 ** an exclusive lock on fd1, then try to get an exclusive lock
37860 ** on fd2, it works. I would have expected the second lock to
37861 ** fail since there was already a lock on the file due to fd1.
37877 ** locks to see if another thread has previously set a lock on that same
37891 ** field that tells us its internal lock status. cnt==0 means the
37892 ** file is unlocked. cnt==-1 means the file has an exclusive lock.
37895 ** Any attempt to lock or unlock a file first checks the locking
37897 ** POSIX lock if the internal lock structure transitions between
37910 ** be closed and that list is walked (and cleared) when the last lock
37916 ** not posix compliant. Under LinuxThreads, a lock created by thread
37918 ** Only thread A can modify the lock. Locking behavior is correct
37920 ** on linux - with NPTL a lock created by thread A can override locks
37985 unsigned char bProcessLock; /* An exclusive process lock is held */
37992 unsigned long long sharedByte; /* for AFP simulated shared lock */
38329 ** This routine checks if there is a RESERVED lock held on the specified
38330 ** file by this or any other process. If such a lock is held, set *pResOut
38332 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
38345 /* Check if a thread in this process holds such a lock */
38354 struct flock lock;
38355 lock.l_whence = SEEK_SET;
38356 lock.l_start = RESERVED_BYTE;
38357 lock.l_len = 1;
38358 lock.l_type = F_WRLCK;
38359 if( osFcntl(pFile->h, F_GETLK, &lock) ){
38362 } else if( lock.l_type!=F_UNLCK ){
38379 ** Set a posix-advisory-lock.
38385 ** failing the lock. The iBusyTimeout value is always reset back to
38389 ** attempt to set the lock.
38395 int h, /* The file descriptor on which to take the lock */
38396 struct flock *pLock, /* The description of the lock */
38402 /* On systems that support some kind of blocking file lock with a timeout,
38403 ** make appropriate changes here to invoke that blocking file lock. On
38405 ** lock once every millisecond until either the timeout expires, or until
38406 ** the lock is obtained. */
38417 ** Attempt to set a system-lock on the file pFile. The lock is
38420 ** If the pFile was opened read/write from unix-excl, then the only lock
38421 ** ever obtained is an exclusive lock, and it is obtained exactly once
38422 ** the first time any lock is attempted. All subsequent system locking
38442 struct flock lock;
38444 lock.l_whence = SEEK_SET;
38445 lock.l_start = SHARED_FIRST;
38446 lock.l_len = SHARED_SIZE;
38447 lock.l_type = F_WRLCK;
38448 rc = osSetPosixAdvisoryLock(pFile->h, &lock, pFile);
38462 ** Lock the file with the lock specified by parameter eFileLock - one
38470 ** Sometimes when requesting one lock state, additional lock states
38472 ** transitions leaving the lock state different from what it started but
38482 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
38487 ** lock transitions in terms of the POSIX advisory shared and exclusive
38488 ** lock primitives (called read-locks and write-locks below, to avoid
38489 ** confusion with SQLite lock names). The algorithms are complicated
38497 ** To obtain a SHARED lock, a read-lock is obtained on the 'pending
38499 ** and the lock on the 'pending byte' released. (Legacy note: When
38501 ** and Widnows95 lacks a shared-lock capability. So on Windows95, a
38507 ** A process may only obtain a RESERVED lock after it has a SHARED lock.
38508 ** A RESERVED lock is implemented by grabbing a write-lock on the
38511 ** A process may only obtain a PENDING lock after it has obtained a
38512 ** SHARED lock. A PENDING lock is implemented by obtaining a write-lock
38515 ** does not have to obtain a RESERVED lock on the way to a PENDING lock.
38519 ** An EXCLUSIVE lock, obtained after a PENDING lock is held, is
38520 ** implemented by obtaining a write-lock on the entire 'shared byte
38521 ** range'. Since all other locks require a read-lock on one of the bytes
38528 struct flock lock;
38537 /* If there is already a lock of this type or more restrictive on the
38548 ** (1) We never move from unlocked to anything higher than shared lock.
38549 ** (2) SQLite never explicitly requests a pendig lock.
38550 ** (3) A shared lock is always held when a reserve lock is requested.
38561 /* If some thread using this PID has a lock via a different unixFile*
38562 ** handle that precludes the requested lock, return BUSY.
38571 /* If a SHARED lock is requested, and some thread using this PID already
38572 ** has a SHARED or RESERVED lock, then increment reference counts and
38587 /* A PENDING lock is needed before acquiring a SHARED lock and before
38588 ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will
38591 lock.l_len = 1L;
38592 lock.l_whence = SEEK_SET;
38596 lock.l_type = (eFileLock==SHARED_LOCK?F_RDLCK:F_WRLCK);
38597 lock.l_start = PENDING_BYTE;
38598 if( unixFileLock(pFile, &lock) ){
38610 ** operating system calls for the specified lock.
38617 /* Now get the read-lock */
38618 lock.l_start = SHARED_FIRST;
38619 lock.l_len = SHARED_SIZE;
38620 if( unixFileLock(pFile, &lock) ){
38625 /* Drop the temporary PENDING lock */
38626 lock.l_start = PENDING_BYTE;
38627 lock.l_len = 1L;
38628 lock.l_type = F_UNLCK;
38629 if( unixFileLock(pFile, &lock) && rc==SQLITE_OK ){
38646 /* We are trying for an exclusive lock but another thread in this
38647 ** same process is still holding a shared lock. */
38650 /* The request was for a RESERVED or EXCLUSIVE lock. It is
38651 ** assumed that there is a SHARED or greater lock on the file
38655 lock.l_type = F_WRLCK;
38659 lock.l_start = RESERVED_BYTE;
38660 lock.l_len = 1L;
38662 lock.l_start = SHARED_FIRST;
38663 lock.l_len = SHARED_SIZE;
38666 if( unixFileLock(pFile, &lock) ){
38678 ** transitioning from a SHARED to a RESERVED lock. The change
38731 ** set to a read lock, then the other part is simply unlocked. This works
38733 ** remove the write lock on a region when a read lock is set.
38738 struct flock lock;
38757 /* When reducing a lock such that other processes can start
38768 /* downgrading to a shared lock on NFS involves clearing the write lock
38770 ** the lock in 2 blocks, so that part of the range will be covered by a
38771 ** write lock until the rest is covered by a read lock:
38787 lock.l_type = F_UNLCK;
38788 lock.l_whence = SEEK_SET;
38789 lock.l_start = SHARED_FIRST;
38790 lock.l_len = divSize;
38791 if( unixFileLock(pFile, &lock)==(-1) ){
38797 lock.l_type = F_RDLCK;
38798 lock.l_whence = SEEK_SET;
38799 lock.l_start = SHARED_FIRST;
38800 lock.l_len = divSize;
38801 if( unixFileLock(pFile, &lock)==(-1) ){
38809 lock.l_type = F_UNLCK;
38810 lock.l_whence = SEEK_SET;
38811 lock.l_start = SHARED_FIRST+divSize;
38812 lock.l_len = SHARED_SIZE-divSize;
38813 if( unixFileLock(pFile, &lock)==(-1) ){
38822 lock.l_type = F_RDLCK;
38823 lock.l_whence = SEEK_SET;
38824 lock.l_start = SHARED_FIRST;
38825 lock.l_len = SHARED_SIZE;
38826 if( unixFileLock(pFile, &lock) ){
38828 ** process is holding an incompatible lock. If it does, this
38839 lock.l_type = F_UNLCK;
38840 lock.l_whence = SEEK_SET;
38841 lock.l_start = PENDING_BYTE;
38842 lock.l_len = 2L; assert( PENDING_BYTE+1==RESERVED_BYTE );
38843 if( unixFileLock(pFile, &lock)==0 ){
38852 /* Decrement the shared lock counter. Release the lock using an
38854 ** the lock.
38858 lock.l_type = F_UNLCK;
38859 lock.l_whence = SEEK_SET;
38860 lock.l_start = lock.l_len = 0L;
38861 if( unixFileLock(pFile, &lock)==0 ){
38972 ** when the last lock is cleared.
38984 /************** End of the posix advisory lock implementation *****************
38991 ** simplest: locking is ignored. No attempt is made to lock the database
39025 /******************* End of the no-op lock implementation *********************
39031 ** The dotfile locking implementation uses the existence of separate lock
39038 ** (2) An application crash or power loss can leave stale lock files
39045 ** the database and with the same name but with a ".lock" extension added.
39046 ** The existence of a lock directory implies an EXCLUSIVE lock. All other
39047 ** lock types (SHARED, RESERVED, PENDING) are mapped into EXCLUSIVE.
39052 ** lock directory.
39054 #define DOTLOCK_SUFFIX ".lock"
39057 ** This routine checks if there is a RESERVED lock held on the specified
39058 ** file by this or any other process. If such a lock is held, set *pResOut
39060 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
39062 ** In dotfile locking, either a lock exists or it does not. So in this
39063 ** variation of CheckReservedLock(), *pResOut is set to true if any lock
39081 ** Lock the file with the lock specified by parameter eFileLock - one
39089 ** Sometimes when requesting one lock state, additional lock states
39091 ** transitions leaving the lock state different from what it started but
39101 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
39113 /* If we have any lock, then the lock file already exists. All we have
39114 ** to do is adjust our internal record of the lock level.
39127 /* grab an exclusive lock */
39130 /* failed to open/create the lock directory */
39155 ** When the locking level reaches NO_LOCK, delete the lock file.
39173 ** lock state. No need to mess with the file on disk.
39180 /* To fully unlock the database, delete the lock file */
39198 ** Close a file. Make sure the lock has been released before closing.
39207 /****************** End of the dot-file lock implementation *******************
39217 ** a single exclusive lock. In other words, SHARED, RESERVED, and
39218 ** PENDING locks are the same thing as an EXCLUSIVE lock. SQLite
39241 ** This routine checks if there is a RESERVED lock held on the specified
39242 ** file by this or any other process. If such a lock is held, set *pResOut
39244 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
39255 /* Check if a thread in this process holds such a lock */
39262 /* attempt to get the lock */
39265 /* got the lock, unlock it */
39298 ** Lock the file with the lock specified by parameter eFileLock - one
39306 ** Sometimes when requesting one lock state, additional lock states
39308 ** transitions leaving the lock state different from what it started but
39319 ** lock states in the sqlite3_file structure, but all locks SHARED or
39323 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
39332 /* if we already have a lock, it is exclusive.
39339 /* grab an exclusive lock */
39415 /******************* End of the flock lock implementation *********************
39423 ** Semaphore locking is like dot-lock and flock in that it really only
39426 ** makes the lock implementation much easier.
39431 ** This routine checks if there is a RESERVED lock held on the specified
39432 ** file by this or any other process. If such a lock is held, set *pResOut
39434 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
39445 /* Check if a thread in this process holds such a lock */
39460 /* someone else has the lock when we are in NO_LOCK */
39475 ** Lock the file with the lock specified by parameter eFileLock - one
39483 ** Sometimes when requesting one lock state, additional lock states
39485 ** transitions leaving the lock state different from what it started but
39496 ** lock states in the sqlite3_file structure, but all locks SHARED or
39500 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
39508 /* if we already have a lock, it is exclusive.
39516 /* lock semaphore now but bail out when already locked. */
39591 *************** End of the named semaphore lock implementation ****************
39607 ** The afpLockingContext structure contains all afp lock specific state
39617 unsigned long long offset; /* offset to first byte to lock */
39618 unsigned long long length; /* nbr of bytes to lock */
39620 unsigned char unLockFlag; /* 1 = unlock, 0 = lock */
39622 int fd; /* file desc to assoc this lock with */
39628 ** This is a utility for setting or clearing a bit-range lock on an
39637 unsigned long long length, /* Number of bytes to lock */
39638 int setLockFlag /* True to set lock. False to clear lock */
39674 ** This routine checks if there is a RESERVED lock held on the specified
39675 ** file by this or any other process. If such a lock is held, set *pResOut
39677 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
39694 /* Check if a thread in this process holds such a lock */
39702 /* lock the RESERVED byte */
39705 /* if we succeeded in taking the reserved lock, unlock it to restore
39709 /* if we failed to get the lock then someone else must have it */
39725 ** Lock the file with the lock specified by parameter eFileLock - one
39733 ** Sometimes when requesting one lock state, additional lock states
39735 ** transitions leaving the lock state different from what it started but
39745 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
39759 /* If there is already a lock of this type or more restrictive on the
39770 ** (1) We never move from unlocked to anything higher than shared lock.
39771 ** (2) SQLite never explicitly requests a pendig lock.
39772 ** (3) A shared lock is always held when a reserve lock is requested.
39783 /* If some thread using this PID has a lock via a different unixFile*
39784 ** handle that precludes the requested lock, return BUSY.
39793 /* If a SHARED lock is requested, and some thread using this PID already
39794 ** has a SHARED or RESERVED lock, then increment reference counts and
39808 /* A PENDING lock is needed before acquiring a SHARED lock and before
39809 ** acquiring an EXCLUSIVE lock. For the SHARED lock, the PENDING will
39824 ** operating system calls for the specified lock.
39834 /* Now get the read-lock SHARED_LOCK */
39843 /* Drop the temporary PENDING lock */
39861 /* We are trying for an exclusive lock but another thread in this
39862 ** same process is still holding a shared lock. */
39865 /* The request was for a RESERVED or EXCLUSIVE lock. It is
39866 ** assumed that there is a SHARED or greater lock on the file
39872 /* Acquire a RESERVED lock */
39879 /* Acquire an EXCLUSIVE lock */
39881 /* Remove the shared lock before trying the range. we'll need to
39882 ** reestablish the shared lock if we can't get the afpUnlock
39887 /* now attemmpt to get the exclusive lock range */
39892 /* Can't reestablish the shared lock. Sqlite can't deal, this is
39959 /* When reducing a lock such that other processes can start
39976 /* only re-establish the shared lock if necessary */
39998 /* Decrement the shared lock counter. Release the lock using an
40000 ** the lock.
40047 ** the last lock is cleared.
40062 ** The code above is the AFP lock implementation. The code is specific
40067 ********************* End of the AFP lock implementation **********************
40087 ** The code above is the NFS lock implementation. The code is specific
40091 ********************* End of the NFS lock implementation **********************
41177 u8 isUnlocked; /* True if no DMS lock held */
41181 int aLock[SQLITE_SHM_NLOCK]; /* # shared locks on slot, -1==excl lock */
41214 #define UNIX_SHM_BASE ((22+SQLITE_SHM_NLOCK)*4) /* first lock byte */
41261 int n /* Number of bytes to lock */
41295 /* Update the global lock state and do debug tracing */
41306 OSTRACE(("read-lock %d ok", ofst));
41311 OSTRACE(("write-lock %d ok", ofst));
41319 OSTRACE(("read-lock failed"));
41322 OSTRACE(("write-lock %d failed", ofst));
41382 ** The DMS lock has not yet been taken on shm file pShmNode. Attempt to
41387 ** connection and no other process already holds a lock, return
41391 struct flock lock;
41396 ** a SHARED lock, then this process may also take a SHARED lock
41399 ** Or, if no other process is holding any lock, then this process
41400 ** is the first to open it. In this case take an EXCLUSIVE lock on the
41402 ** downgrade to a SHARED lock on the DMS byte.
41404 ** If another process is holding an EXCLUSIVE lock on the DMS byte,
41406 ** version of this code attempted the SHARED lock at this point. But
41412 lock.l_whence = SEEK_SET;
41413 lock.l_start = UNIX_SHM_DMS;
41414 lock.l_len = 1;
41415 lock.l_type = F_WRLCK;
41416 if( osFcntl(pShmNode->hShm, F_GETLK, &lock)!=0 ) {
41418 }else if( lock.l_type==F_UNLCK ){
41433 }else if( lock.l_type==F_WRLCK ){
41438 assert( lock.l_type==F_UNLCK || lock.l_type==F_RDLCK );
41474 ** that means that an exclusive lock is held on the database file and
41789 ** Change the lock state for a shared-memory segment.
41798 int ofst, /* First lock to acquire or release */
41800 int flags /* What to do with the lock */
41837 /* Check that, if this to be a blocking lock, no locks that occur later
41838 ** in the following list than the lock being obtained are already held:
41840 ** 1. Checkpointer lock (ofst==1).
41841 ** 2. Write lock (ofst==0).
41844 ** In other words, if this is a blocking lock, none of the locks that
41845 ** occur later in the above list than the lock being obtained may be
41848 ** It is not permitted to block on the RECOVER lock.
41908 ** lock. If any do, return SQLITE_BUSY right away. */
42379 ** opens secondary file descriptors for the conch and lock files and
42403 /* nfs lockd on OSX 10.3+ doesn't clear write locks when a read lock is set */
42461 ** Test byte-range lock using fcntl(). If the call succeeds,
42611 ** such bad shape that dropping a lock or two doesn't matter much.
42792 ** Implementation in the proxy-lock division, but used by unixOpen()
42806 ** other file descriptor open on the same file is holding a file-lock.
43733 ** other locking methods on secondary lock files. Proxy locking is a
43750 ** address in the shared range is taken for a SHARED lock, the entire
43751 ** shared range is taken for an EXCLUSIVE lock):
43798 ** The lock path will be "<tmpdir>/sqliteplocks/_Users_me_foo.db:auto:")
43800 ** Once a lock proxy is configured for a database connection, it can not
43818 ** by taking an sqlite-style shared lock on the conch file, reading the
43819 ** contents and comparing the host's unique host ID (see below) and lock
43824 ** host ID and/or proxy path, then the lock is escalated to an exclusive
43825 ** lock and the conch file contents is updated with the host ID and proxy
43826 ** path and the lock is downgraded to a shared lock again. If the conch
43827 ** is held by another process (with a shared lock), the exclusive lock
43833 ** host (the conch ensures that they all use the same local lock file).
43835 ** Requesting the lock proxy does not immediately take the conch, it is
43836 ** only taken when the first request to lock database file is made.
43838 ** opening a connection to a database file does not take a lock on it.
43839 ** The shared lock and an open file descriptor are maintained until
43842 ** The proxy file and the lock file are never deleted so they only need
43851 ** automatically configured for proxy locking, lock files are
43862 ** Overrides the default directory used for lock proxy files that
43868 ** lock proxy files, only used when LOCKPROXYDIR is not set.
43892 unixFile *lockProxy; /* Open proxy lock file */
43893 char *lockProxyPath; /* Name of the proxy lock file */
43902 ** The proxy lock file path for the database at dbPath is written into lPath,
43943 OSTRACE(("GETLOCKPATH proxy lock path=%s pid=%d\n", lPath, osGetpid(0)));
43948 ** Creates the lock file and any missing directories in lockPath
43969 "'%s' proxy lock path=%s pid=%d\n",
43979 OSTRACE(("CREATELOCKPATH proxy lock path=%s pid=%d\n",lockPath,osGetpid(0)));
44004 ** 2. if that fails, and this is a lock file (not-conch), try creating
44007 ** otherwise return BUSY (if lock file) or CANTOPEN for the conch file
44115 /* The conch file contains the header, host id and lock file path
44169 fprintf(stderr, "broke stale lock on %s\n", cPath);
44180 fprintf(stderr, "failed to break stale lock on %s, %s\n", cPath, errmsg);
44185 /* Take the requested lock on the conch file and break a stale lock if the
44200 /* If the lock failed (busy):
44204 * 3rd try: break the lock unless the mod time has changed.
44217 unixSleep(0,500000); /* wait 0.5 sec and try the lock again*/
44238 /* don't break the lock if the host id doesn't match */
44243 /* don't break the lock on short read or a version mismatch */
44246 unixSleep(0,10000000); /* wait 10 sec and try the lock again */
44266 /* Takes the conch by taking a shared lock and read the contents conch, if
44267 ** lockPath is non-NULL, the host ID and lock file path must match. A NULL
44269 ** host IDs match, or a new lock path will be generated automatically
44321 /* if the host id matches and the lock path already exists in the conch
44325 do { /* in case we need to try again for an :auto: named lock file */
44332 /* for auto-named local lock file, just check the host ID and we'll
44333 ** use the local lock file path that's already in there
44345 /* create a copy of the lock path if the conch is taken */
44352 /* conch host and lock path match */
44367 /* create a copy of the lock path _only_ if the conch is taken */
44371 ** has a shared lock already), if the host id matches, use the big
44377 /* We are trying for an exclusive lock but another thread in this
44378 ** same process is still holding a shared lock. */
44456 /* we couldn't create the proxy lock file with the old lock file path
44489 } while (1); /* in case we need to retry the :auto: lock file -
44495 ** If pFile holds a lock on a conch file, then release that lock.
44499 proxyLockingContext *pCtx; /* The locking context for the proxy lock */
44562 ** the local lock file path
44611 /* dot lock style uses the locking context to store the dot lock
44625 ** will be performed on the local proxy lock file. The following fields
44780 ** above this point are all utilities. The lock-related methods of the
44786 ** This routine checks if there is a RESERVED lock held on the specified
44787 ** file by this or any other process. If such a lock is held, set *pResOut
44789 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
44807 ** Lock the file with the lock specified by parameter eFileLock - one
44815 ** Sometimes when requesting one lock state, additional lock states
44817 ** transitions leaving the lock state different from what it started but
44827 ** This routine will only increase a lock. Use the sqlite3OsUnlock()
44919 ******************* End of the proxy lock implementation **********************
45035 /* Validate lock assumptions */
45325 BOOL bPending; /* Indicates a pending lock has been obtained */
45326 BOOL bReserved; /* Indicates a reserved lock has been obtained */
45327 BOOL bExclusive; /* Indicates an exclusive lock has been obtained */
45340 u8 locktype; /* Type of lock currently held on this file */
45341 short sharedLockByte; /* Randomly chosen byte used as a shared lock */
45351 HANDLE hMutex; /* Mutex used to control access to shared lock */
45354 winceLock *shared; /* Global shared lock memory for the file */
47260 "delayed %dms for lock/sharing conflict at line %d",
47307 ** Acquire a lock on the handle h
47316 ** Release a lock acquired by winceMutexAcquire()
47468 /* Wanting an exclusive lock? */
47478 /* Want a read-only lock? */
47490 /* Want a pending lock? */
47493 /* If no pending lock has been acquired, then acquire it */
47501 /* Want a reserved lock? */
47534 /* Releasing a reader lock or an exclusive lock */
47536 /* Did we have an exclusive lock? */
47544 /* Did we just have a reader lock? */
47557 /* Releasing a pending lock */
47566 /* Releasing a reserved lock */
47811 "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
47889 "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
48012 OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
48100 OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\n",
48212 ** immediately if the lock could not be obtained. Also, it always expected to
48213 ** obtain an exclusive lock. These flags are used with the LockFileEx function
48223 ** call to fail immediately if the lock cannot be obtained.
48230 ** Acquire a reader lock.
48236 OSTRACE(("READ-LOCK file=%p, lock=%d\n", pFile->h, pFile->locktype));
48260 /* No need to log a failure to lock */
48272 OSTRACE(("READ-UNLOCK file=%p, lock=%d\n", pFile->h, pFile->locktype));
48291 ** Lock the file with the lock specified by parameter locktype - one
48299 ** Sometimes when requesting one lock state, additional lock states
48301 ** transitions leaving the lock state different from what it started but
48311 ** This routine will only increase a lock. The winUnlock() routine
48318 int res = 1; /* Result of a Windows lock call */
48320 int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */
48328 /* If there is already a lock of this type or more restrictive on the
48337 /* Do not allow any kind of write-lock on a read-only database
48349 /* Lock the PENDING_LOCK byte if we need to acquire a PENDING lock or
48350 ** a SHARED lock. If we are acquiring a SHARED lock, the acquisition of
48360 /* Try 3 times to get the pending lock. This is needed to work
48384 /* Acquire a shared lock
48396 /* Acquire a RESERVED lock
48408 /* Acquire a PENDING lock
48415 /* Acquire an EXCLUSIVE lock
48430 /* If we are holding a PENDING lock that ought to be released, then
48437 /* Update the state of the lock has held in the file descriptor then
48449 OSTRACE(("LOCK file=%p, lock=%d, rc=%s\n",
48455 ** This routine checks if there is a RESERVED lock held on the specified
48456 ** file by this or any other process. If such a lock is held, return
48508 ** reacquire the read lock */
48523 OSTRACE(("UNLOCK file=%p, lock=%d, rc=%s\n",
48532 ** simplest: locking is ignored. No attempt is made to lock the database
48563 /******************* End of the no-op lock implementation *********************
48807 u8 isUnlocked; /* True if no DMS lock held */
48857 #define WIN_SHM_BASE ((22+SQLITE_SHM_NLOCK)*4) /* first lock byte */
48870 int nByte /* Number of bytes to lock or unlock */
48877 OSTRACE(("SHM-LOCK file=%p, lock=%d, offset=%d, size=%d\n",
48880 /* Release/Acquire the system-level lock */
48957 ** The DMS lock has not yet been taken on shm file pShmNode. Attempt to
48962 ** connection and no other process already holds a lock, return
49142 ** Change the lock state for a shared-memory segment.
49146 int ofst, /* First lock to acquire or release */
49148 int flags /* What to do with the lock */
49175 /* See if any siblings hold this same lock */
49198 ** If any sibling already holds an exclusive lock, go ahead and return
49224 ** lock. If any do, return SQLITE_BUSY right away.
51359 int eLock; /* Most recent lock against this file */
55410 /* Used by readers to open (lock) and close (unlock) a snapshot. A
55412 ** at an instant in time. sqlite3WalOpenSnapshot gets a read lock and
55415 ** transaction and releases the lock.
55427 /* Obtain or release the WRITER lock. */
55466 /* Tell the wal layer that an EXCLUSIVE lock has been obtained (or released)
55576 ** the EXCLUSIVE lock, thus signaling other connections on the same
55585 ** (12) An EXCLUSIVE lock is held on the database file when writing to
55588 ** (13) A SHARED lock is held on the database file while reading any
55660 ** * Any lock, or no lock at all, may be held on the database file.
55679 ** * A SHARED or greater lock is held on the database file.
55695 ** BEGIN EXCLUSIVE) EXCLUSIVE lock is obtained on the database file when
55701 ** IN WAL mode, WalBeginWriteTransaction() is called to lock the log file.
55703 ** is made to obtain an EXCLUSIVE lock on the database file.
55707 ** lock is held on the database file.
55724 ** * A RESERVED or greater lock is held on the database file.
55737 ** * An EXCLUSIVE or greater lock is held on the database file.
55755 ** * An EXCLUSIVE or greater lock is held on the database file.
55842 ** following locking-states, according to the lock currently held on
55853 ** to a less exclusive (lower) value than the lock that is actually held
55857 ** be a few redundant xLock() calls or a lock may be held for longer than
55864 ** fails at this point and the pager is left holding an EXCLUSIVE lock, this
55869 ** lock held by this process or any others". So xCheckReservedLock may
55870 ** return true because the caller itself is holding an EXCLUSIVE lock (but
55881 ** lock. Instead, it assumes a hot-journal exists and obtains an EXCLUSIVE
55882 ** lock on the database file before attempting to roll it back. See function
55957 ** For a real on-disk database, the current lock held on the database file -
55977 ** can only happen if an exclusive lock is held on the database file.
55978 ** It is cleared (set to false) whenever an exclusive lock is
56125 u8 noLock; /* Do not lock (except in WAL mode) */
56140 u8 eLock; /* Current lock held on database file */
56146 u8 hasHeldSharedLock; /* True if a shared lock has ever been held */
56367 ** as if it has an exclusive lock on the database file. It never updates
56397 /* If changeCountDone is set, a RESERVED lock or greater must be held
56637 ** succeeds, set the Pager.eLock variable to match the (attempted) new lock.
56916 /* At this point the transaction is committed but the write lock
57348 ** close the journal file when dropping the database lock. Otherwise
57365 ** file fails, set the current lock to UNKNOWN_LOCK. See the comment
57474 ** in PAGER_NONE or PAGER_SHARED state and the lock held is less
57475 ** exclusive than a RESERVED lock, it is a no-op.
57507 ** If running in non-exclusive rollback mode, the lock on the file is
57524 ** or at least a RESERVED lock. This function may be called when there
57525 ** is no write-transaction active but a RESERVED or greater lock is
57532 ** lock switches back to locking_mode=normal and then executes a
57616 /* Drop the WAL write-lock, if any. Also, if the connection was in
57618 ** lock held on the database file.
57626 ** successfully committed, but the EXCLUSIVE lock is still held on the
57658 ** connection to obtain a shared lock on the pager (which may be this one)
57808 ** is in state OPEN and holds an EXCLUSIVE lock. Hot-journal rollback
57974 ** for page 1 which is held in use in order to keep the lock on the
58520 ** pPg->pData. A shared lock or greater must be held on the database
58843 ** The caller must hold a SHARED lock on the database file to call this
58844 ** function. Because an EXCLUSIVE lock on the db file is required to delete
59205 ** SQLITE_BUSY when trying to upgrade from no-lock to a SHARED lock,
59206 ** or when trying to upgrade from a RESERVED lock to an EXCLUSIVE
59207 ** lock. It does *not* invoke the busy handler when upgrading from
59218 ** If the busy-handler callback returns non-zero, the lock is
59432 ** Try to obtain a lock of type locktype on the database file. If
59433 ** a similar or greater lock is already held, this function is a no-op
59436 ** Otherwise, attempt to obtain the lock using sqlite3OsLock(). Invoke
59437 ** the busy callback if the lock is currently not available. Repeat
59439 ** obtain the lock succeeds.
59442 ** the lock. If the lock is obtained successfully, set the Pager.state
59448 /* Check that this is either a no-op (because the requested lock is
59905 ** The pager must hold at least a RESERVED lock when this function
59906 ** is called. Before writing anything to the database file, this lock
59907 ** is upgraded to an EXCLUSIVE lock. If the lock cannot be obtained,
59914 ** Once the lock has been upgraded and, if necessary, the file opened,
59927 ** occurs, an IO error code is returned. Or, if the EXCLUSIVE lock cannot
60521 pPager->eState = PAGER_READER; /* Pretend we already have a lock */
60633 ** * No process holds a RESERVED or greater lock on the database file, and
60675 int locked = 0; /* True if some process holds a RESERVED lock */
60678 ** the RESERVED lock and have a journal open at the sqlite3OsAccess()
60679 ** call above, but then delete the journal and drop the lock before
60709 ** or greater lock on the database file. Now check that there is
60735 ** with it under an EXCLUSIVE lock where we do not need to
60750 ** This function is called to obtain a shared lock on the database file.
60752 ** has been successfully called. If a shared-lock is already held when
60757 ** 1) If the pager is currently in PAGER_OPEN state (no lock held
60759 ** SHARED lock on the database file. Immediately after obtaining
60760 ** the SHARED lock, the file-system is checked for a hot-journal,
60800 /* If a journal file exists, and there is no RESERVED lock on the
60815 /* Get an EXCLUSIVE lock on the database file. At this point it is
60816 ** important that a RESERVED lock is not obtained on the way to the
60817 ** EXCLUSIVE lock. If it were, another process might open the
60818 ** database file, detect the RESERVED lock, and conclude that the
60822 ** Because the intermediate RESERVED lock is not requested, any
60824 ** this point in the code and fail to obtain its own EXCLUSIVE lock
60827 ** Unless the pager is in locking_mode=exclusive mode, the lock is
60844 ** this connection obtained the exclusive lock above. Or, it
60867 ** lock and reacquire the read lock. Purge the cache before
60887 ** or roll back a hot-journal while holding an EXCLUSIVE lock. The
60913 /* The shared-lock has just been acquired then check to
60945 ** to its original size while this process was not holding a lock.
61052 ** just returns 0. This routine acquires a read-lock the first time it
61289 ** pages reaches zero it drops the database lock.
61318 ** There must already be a RESERVED or EXCLUSIVE lock on the database
61417 ** lock on the database file. If exFlag is true, then acquire at least
61418 ** an EXCLUSIVE lock. If such a lock is already held, no locking
61441 ** exclusive lock on the database is not already held, obtain it now.
61451 /* Grab the write lock on the log file. If successful, upgrade to
61454 ** holds the write-lock. If possible, the upper layer will call it.
61458 /* Obtain a RESERVED lock on the database file. If the exFlag parameter
61459 ** is true, then immediately upgrade this to an EXCLUSIVE lock. The
61461 ** lock, but not when obtaining the RESERVED lock.
61922 ** Otherwise, if the connection does not already have an EXCLUSIVE lock on
61925 ** If the EXCLUSIVE lock is already held or the attempt to obtain it is
62949 ** Before deleting the journal file, obtain a RESERVED lock on the
63094 ** Attempt to take an exclusive lock on the database file. If a PENDING lock
63103 /* If the attempt to grab the exclusive lock failed, release the
63104 ** pending lock that may have been obtained instead. */
63114 ** lock on the database file and use heap-memory to store the wal-index
63125 ** implementation. Take the exclusive lock now, before opening the WAL
63148 ** The caller must be holding a SHARED lock on the database file to call
63197 ** EXCLUSIVE lock on the database file. If this cannot be obtained, an
63199 ** If successful, the EXCLUSIVE lock is not released before returning.
63223 /* Checkpoint and close the log. Because an EXCLUSIVE lock is held on
63313 ** this function takes a SHARED lock on the CHECKPOINTER slot and then
63318 ** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error
63320 ** lock is released before returning.
63333 ** Release a lock obtained by an earlier successful call to
63346 ** A read-lock must be held on the pager when this function is called. If
63705 ** holding the WAL_CKPT_LOCK lock (which includes a recovery thread).
63719 ** There is one entry in aReadMark[] for each reader lock. If a reader
63720 ** holds read-lock K, then the value in aReadMark[K] is no greater than
63729 ** is holding an exclusive lock on WAL_READ_LOCK(K). Thus, the value of
63731 ** since the reader will be holding a shared lock on WAL_READ_LOCK(K).
63820 ** +-------+-------+------+------+ ) 8 lock bytes
63877 i16 readLock; /* Which read lock is being held. -1 for none */
63881 u8 ckptLock; /* True if holding a checkpoint lock */
64288 ** A lock cannot be moved directly between shared and exclusive - it must go
64576 ** This routine first tries to establish an exclusive lock on the
64587 int iLock; /* Lock offset to lock for checkpoint */
64589 /* Obtain an exclusive lock on all byte in the locking range not already
64824 ** A SHARED lock should be held on the database file when this function
64825 ** is called. The purpose of this SHARED lock is to prevent any other
64883 ** For that matter, if the lock offset ever changes from its initial design
65132 ** only. The caller must hold the checkpoint lock.
65150 /* This routine only runs while holding the checkpoint lock. And
65247 ** the WRITER lock, and then disable blocking locks. If blocking locks
65248 ** cannot be enabled, no attempt to obtain the WRITER lock is made. Return
65252 ** If the bLock parameter is false and the WRITER lock is held, release it.
65281 ** Take an exclusive WRITE lock. Blocking if so configured.
65299 ** Attempt to obtain the exclusive WAL lock defined by parameters lockIdx and
65301 ** busy-handler function. Invoke it and retry the lock until either the
65302 ** lock is successfully obtained or the busy-handler returns 0.
65308 int lockIdx, /* Offset of first byte to lock */
65309 int n /* Number of bytes to lock */
65335 ** a) the WRITER lock is held,
65529 /* Release the reader lock held while backfilling */
65614 /* If an EXCLUSIVE lock can be obtained on the database file (using the
65620 ** The EXCLUSIVE lock is not released before returning.
65790 ** wal-index header immediately, without holding any lock. This usually
65797 ** with a writer. So get a WRITE lock and try again.
65813 ** a WRITE lock, it can only mean that the header is corrupted and
66054 ** On success, this routine obtains a read lock on
66057 ** that means the Wal does not hold any read lock. The reader must not
66066 ** lock on WAL_READ_LOCK(pWal->readLock) and set pWal->readLock to -1.
66072 ** so it takes care to hold an exclusive lock on the corresponding
66082 u32 mxFrame; /* Wal frame to lock to */
66094 ** if we are unlucky, another process that is holding a lock might get
66096 ** during the few nanoseconds that it is holding the lock. In that case,
66097 ** it might take longer than normal for the lock to free.
66198 ** but not exceeding pWal->hdr.mxFrame and lock that entry.
66241 /* Now that the read-lock has been obtained, check that neither the
66246 ** between the time it was read and when the shared-lock was obtained
66402 ** there is no checkpointer process by taking a shared CKPT lock
66426 /* At this point the client has a lock on an aReadMark[] slot holding
66474 /* Release the shared CKPT lock obtained above. */
66486 ** read-lock.
66653 /* If the write-lock is already held, then it was obtained before the
66671 /* Only one writer allowed at a time. Get the write lock. Return
66695 ** routine merely releases the lock.
66978 ** Write a set of frames to the log. The caller must hold the write-lock
67174 /* Append data to the wal-index. It is not necessary to lock the
67175 ** wal-index to do this as the SQLITE_SHM_WRITE lock held on the wal-index
67219 ** Obtain a CHECKPOINT lock and then backfill as much information as
67258 ** "checkpoint" lock on the database file.
67260 ** checkpoint operation at the same time, the lock cannot be obtained and
67272 ** TRUNCATE modes also obtain the exclusive "writer" lock on the database
67275 ** EVIDENCE-OF: R-60642-04082 If the writer lock cannot be obtained
67277 ** writer lock retried until either the busy-handler returns 0 or the
67278 ** lock is successfully obtained.
67370 ** into locking_mode=NORMAL. This means that we must acquire a lock
67372 ** or if the acquisition of the lock fails, then return 0. If the
67375 ** lock on the main database file.
67381 ** routine is a no-op. The pager must already hold the exclusive lock
67386 ** should acquire the database exclusive lock prior to invoking
67395 ** prior error while attempting to acquire are read-lock. This cannot
67490 ** This function takes a SHARED lock on the CHECKPOINTER slot and then
67495 ** the CHECKPOINTER lock cannot be obtained, SQLITE_BUSY. If any error
67497 ** lock is released before returning.
67515 ** Release a lock obtained by an earlier successful call to
67529 ** read-lock. This function returns the database page-size if it is known,
67880 Btree *pBtree; /* Btree handle holding this lock */
67927 BtLock lock; /* Object used to lock page 1 */
67975 ** If a BtShared client fails to obtain a write-lock on a database
67977 ** the shared-cache enters 'pending-lock' state and isPending is
67980 ** The shared-cache leaves the 'pending lock' state when either of
67986 ** while in the 'pending-lock' state, no connection may start a new
68038 #define BTS_EXCLUSIVE 0x0040 /* pWriter has an exclusive lock */
68348 ** which need to be locked after p. If we cannot get a lock on
68350 ** for the lock to become available on p, then relock all of the
68351 ** subsequent Btrees that desire a lock.
68368 /* We should already hold a lock on the database connection */
68390 /* In most cases, we should be able to acquire the lock we
68391 ** want without having to go through the ascending lock
68401 ** BtShared address. Then acquire our lock. Then reacquire
68465 ** two or more btrees in common both try to lock all their btrees
68699 ** So define the lock related functions as no-ops.
68787 ** caller should have first obtained a lock specifying the root page of
68793 ** Instead of a lock on the table/index rooted at page iRoot, the caller may
68794 ** hold a write-lock on the schema table (root page 1). This is also
68798 Btree *pBtree, /* Handle that must hold lock */
68801 int eLockType /* Required lock type (READ_LOCK or WRITE_LOCK) */
68808 ** and has the read-uncommitted flag set, then no lock is required.
68826 /* Figure out the root-page that the lock should be held on. For table
68850 /* Search for the required lock. Either a write-lock on root-page iTab, a
68851 ** write-lock on the schema table, or (if the client is reading) a
68852 ** read-lock on iTab will suffice. Return 1 if any of these are found. */
68862 /* Failed to find the required lock. */
68901 ** Query to see if Btree handle p may obtain a lock of type eLock
68903 ** SQLITE_OK if the lock may be obtained (by calling
68915 /* If requesting a write-lock, then the Btree must have an open write
68927 /* If some other connection is holding an exclusive lock, the
68928 ** requested lock may not be obtained.
68962 ** Add a lock on the table with root-page iTable to the shared-btree used
68971 ** (b) No other Btree objects hold a lock that conflicts
68972 ** with the requested lock (i.e. querySharedCacheTableLock() has
68975 ** SQLITE_OK is returned if the lock is added successfully. SQLITE_NOMEM
68988 ** obtain a read-lock using this function. The only read-lock obtained
68990 ** table, and that lock is obtained in BtreeBeginTrans(). */
68994 ** has been determined that no other b-tree holds a conflicting lock. */
68998 /* First search the list for an existing lock on this table. */
69020 /* Set the BtLock.eLock variable to the maximum of the current lock
69021 ** and the requested lock. This means if a write-lock was already held
69022 ** and a read-lock requested, we don't incorrectly downgrade the lock.
69056 assert( pLock->iTable!=1 || pLock==&p->lock );
71123 p->lock.pBtree = p;
71124 p->lock.iTable = 1;
72016 ** of a transaction but there is a read lock on the database, then
72018 ** has the effect of releasing the read lock.
72113 ** If an initial attempt to acquire the lock fails because of lock contention
72115 ** if there is one. But if there was previously a read-lock, do not
72117 ** returned when there is already a read-lock in order to avoid a deadlock.
72119 ** Suppose there are two processes A and B. A has a read lock and B has
72120 ** a reserved lock. B tries to promote to exclusive but is blocked because
72121 ** of A's read lock. A tries to promote to reserved but is blocked by B.
72124 ** when A already has a read lock, we encourage A to give up and let B
72184 /* Any read-only or read-write transaction implies a read-lock on
72185 ** page 1. So if some other shared-cache client already has a write-lock
72197 ** block for the WRITER lock first if possible. */
72246 assert( p->lock.pBtree==p && p->lock.iTable==1 );
72247 p->lock.eLock = READ_LOCK;
72248 p->lock.pNext = pBt->pLock;
72249 pBt->pLock = &p->lock;
72871 ** This will release the write lock on the database file. If there
72872 ** are no active cursors, it also releases the read lock.
72991 ** This will release the write lock on the database file. If there
72992 ** are no active cursors, it also releases the read lock.
73180 ** this lock. The iTable<1 term disables the check for corrupt schemas. */
73280 ** Close a cursor. The read lock on the database file is released
79555 ** btree as the argument handle holds an exclusive lock on the
79571 ** Obtain a lock on the table whose root page is iTab. The
79572 ** lock is a write lock if isWritelock is true or a read lock
79634 ** (c) the connection holds a write-lock on the table (if required),
80159 /* Now that there is a read-lock on the source database, query the
84402 ** p->btreeMask of databases that will require a lock.
85681 ** lock contention, return SQLITE_BUSY. If SQLITE_BUSY is returned, it
94368 ** There must be a read-lock on the database (either a transaction
98108 ** file. An EXCLUSIVE lock may still be held on the database file
98249 ** Obtain a lock on a particular table. This instruction is only used when
98253 ** on which the lock is acquired. A readlock is obtained if P3==0 or
98254 ** a write lock if P3==1.
98256 ** P2 contains the root-page of the table to lock.
98259 ** used to generate an error message if the lock cannot be obtained.
99524 {OP_TableLock, 0, 0, 0}, /* 0: Acquire a read or write lock */
115643 /* Establish a read-lock on the table at the shared-cache level.
117492 u8 isWriteLock; /* True for write lock. False for a read lock */
117497 ** Record the fact that we want to lock a table at run-time.
117500 ** A read or a write lock can be taken depending on isWritelock.
117502 ** This routine just records the fact that the lock is desired. The
117503 ** code to make the lock occur is generated by a later call to
117508 int iDb, /* Index of the database containing the table to lock */
117510 u8 isWriteLock, /* True for a write lock */
117544 int iDb, /* Index of the database containing the table to lock */
117546 u8 isWriteLock, /* True for a write lock */
120281 ** A shared-cache write-lock is not required to write to the new table,
120282 ** as a schema-lock must have already been obtained to create it. Since
120283 ** a schema-lock excludes all other database users, the write-lock would
121228 /* Require a write-lock on the table to perform this operation */
128111 /* Take a shared-cache advisory read-lock on the parent table. Allocate
128622 ** (1) acquire a lock for table pTab then
135324 sqlite3ErrorMsg(pParse, "failed to set lock proxy file");
137853 /* Check to verify that it is possible to get a read lock on all
137854 ** database schemas. The inability to get a read lock indicates that
137855 ** some other database connection is holding a write-lock, which in
137872 ** Note that setting READ_UNCOMMITTED overrides most lock detection,
137873 ** but it does *not* override schema lock detection, so this all still
149768 /* Begin a transaction and take an exclusive lock on the main database
150112 ** Locks nest. Every lock should have a corresponding unlock.
175084 ** Return non-zero to retry the lock. Return zero to stop trying
175134 ** lock on VFS file pFile.
175136 ** If this routine returns non-zero, the lock is retried. If it
178562 ** to the user because it requires a lock that will not be available
190401 ** shared-cache table-lock on the %_segdir table. This is required before
190402 ** writing data to the fts3 table. If this lock is not acquired first, then
190403 ** the caller may end up attempting to take this lock as part of committing
191079 ** before control is returned to the user (to prevent a lock being held
208213 ** module takes an EXCLUSIVE lock on the database file, ensuring
208216 ** Once the EXCLUSIVE lock is released, any other database readers
208521 ** While an RBU handle is open, a SHARED lock may be held on the target
208923 ** Name of the URI option that causes RBU to take an exclusive lock as
211829 ** * If the exclusive shm WRITER or READ0 lock cannot be obtained,
211955 ** Take an EXCLUSIVE lock on the database file. Return SQLITE_OK if
212007 ** The RBU handle is currently in RBU_STAGE_OAL state, with a SHARED lock
212031 ** holding a SHARED lock on the target database file (because it is
212035 ** lock is obtained here before the *-oal is moved to *-wal.
212920 ** exclusive lock on the db file. If this fails, so be it. */
213276 ** 3c. If an EXCLUSIVE lock is attempted on a target database file in any
213628 ** Check if another file-handle holds a RESERVED lock on an rbuVfs-file.
213708 ** Take or release a shared-memory lock.
213725 /* Prevent SQLite from taking a shm-lock on the target file when it
243522 sqlite3_stmt *pStmt; /* Statement holding lock on pIndex */
246239 const char *lock_name_list[DB_LOCK_NUM] = {"pending lock ", "reserved lock", "shared lock "};
246249 sqlite3_log(SQLITE_WARNING, "lock name: %s, pos: 0x%x, len: 0x%x, lock type: %s, owner: %d\n",
246261 char *lock_name_list_wal[WAL_LOCK_NUM] = {"wal_write lock ", "wal_ckpt lock ", "wal_recover lock"};
246263 lock_name_list_wal[i] = "wal_read lock ";
246274 sqlite3_log(SQLITE_WARNING, "lock name: %s, pos: 0x%x, len: 0x%x, lock type: %s, owner: %d\n",