From 9d10486ae7a3c8f076451f49efdebcc1f202eb23 Mon Sep 17 00:00:00 2001 From: danielk1977 Date: Thu, 9 Jul 2009 08:27:14 +0000 Subject: [PATCH] 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 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 23 +++++++++++++++-------- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 2814670f1d..7987c59fa4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Restore\s(btree_set_cache_size)\sto\stest3.c.\sThis\sis\sused\son\sunix\sfor\sthe\stcl\s"crash\stests".\sMake\ssome\sfunctions\sno\slonger\sused\soutside\sof\sbtree.c\sstatic.\s(CVS\s6869) -D 2009-07-09T05:07:38 +C In\sbtree.c,\shave\ssetSharedCacheLock()\sassume\sthat\sthe\sb-tree\sis\ssharable\sinstead\sof\schecking\sto\ssee\sif\sit\sis.\sThe\scaller\shas\salready\sperformed\sthis\scheck.\s(CVS\s6870) +D 2009-07-09T08:27:14 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in df9359da7a726ccb67a45db905c5447d5c00c6ef F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -106,7 +106,7 @@ F src/auth.c 802a9439dfa0b8c208b10055cba400e82ef18025 F src/backup.c 6f1c2d9862c8a3feb7739dfcca02c1f5352e37f3 F src/bitvec.c 0ef0651714728055d43de7a4cdd95e703fac0119 F src/btmutex.c 9b899c0d8df3bd68f527b0afe03088321b696d3c -F src/btree.c 068c2d866c50c160935ff295e1e0352924d01c05 +F src/btree.c 45595e89ac2babfc6317ef27cc1a930e7db1bb19 F src/btree.h e53a10fd31d16c60a86f03c9467a6f470aa3683b F src/btreeInt.h a568bf057aa249eb06fd31358b4393a5ac88c118 F src/build.c 867028ee9f63f7bc8eb8d4a720bb98cf9b9a12b4 @@ -740,7 +740,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746 -P 579ba6c83f52d26860e5152f06355aa4f49e568d -R d5b9a0157f1211f7631b1172e2a7ef04 +P 1d96ce8c76e007ca29e7971a6c72b6387fe0fb93 +R b4d836437dbb61ffda54759b119298cf U danielk1977 -Z 053de8785ae8ff1ebe93c77d8f639f56 +Z 394ccb1806f19bc1b72ed270bf66ac3f diff --git a/manifest.uuid b/manifest.uuid index abd7554fff..7cc7488a74 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1d96ce8c76e007ca29e7971a6c72b6387fe0fb93 \ No newline at end of file +3190eefd5f5285a5250d6f4729f109852fdb02ab \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 8f4d786d77..fe638abda0 100644 --- a/src/btree.c +++ b/src/btree.c @@ -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. */