1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

In btree.c, have setSharedCacheLock() assume that the b-tree is sharable instead of checking to see if it is. The caller has already performed this check. (CVS 6870)

FossilOrigin-Name: 3190eefd5f5285a5250d6f4729f109852fdb02ab
This commit is contained in:
danielk1977
2009-07-09 08:27:14 +00:00
parent 3054866c7c
commit 9d10486ae7
3 changed files with 22 additions and 15 deletions

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.669 2009/07/09 05:07:38 danielk1977 Exp $
** $Id: btree.c,v 1.670 2009/07/09 08:27:14 danielk1977 Exp $
**
** This file implements a external (disk-based) database using BTrees.
** See the header comment on "btreeInt.h" for additional information.
@@ -255,8 +255,17 @@ static int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){
** by Btree handle p. Parameter eLock must be either READ_LOCK or
** WRITE_LOCK.
**
** SQLITE_OK is returned if the lock is added successfully. SQLITE_BUSY and
** SQLITE_NOMEM may also be returned.
** This function assumes the following:
**
** (a) The specified b-tree connection handle is connected to a sharable
** b-tree database (one with the BtShared.sharable) flag set, and
**
** (b) No other b-tree connection handle holds a lock that conflicts
** with the requested lock (i.e. querySharedCacheTableLock() has
** already been called and returned SQLITE_OK).
**
** SQLITE_OK is returned if the lock is added successfully. SQLITE_NOMEM
** is returned if a malloc attempt fails.
*/
static int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){
BtShared *pBt = p->pBt;
@@ -273,11 +282,9 @@ static int setSharedCacheTableLock(Btree *p, Pgno iTable, u8 eLock){
** table, and that lock is obtained in BtreeBeginTrans(). */
assert( 0==(p->db->flags&SQLITE_ReadUncommitted) || eLock==WRITE_LOCK );
/* This is a no-op if the shared-cache is not enabled */
if( !p->sharable ){
return SQLITE_OK;
}
/* This function should only be called on a sharable b-tree after it
** has been determined that no other b-tree holds a conflicting lock. */
assert( p->sharable );
assert( SQLITE_OK==querySharedCacheTableLock(p, iTable, eLock) );
/* First search the list for an existing lock on this table. */