mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Add some assert() statements to querySharedCacheTableLock(). (CVS 6421)
FossilOrigin-Name: 3e3b5e861aeff2e4ef568c422236fdf7fa22bed3
This commit is contained in:
23
src/btree.c
23
src/btree.c
@@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.582 2009/03/30 18:50:05 danielk1977 Exp $
|
||||
** $Id: btree.c,v 1.583 2009/04/01 09:41:54 danielk1977 Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** See the header comment on "btreeInt.h" for additional information.
|
||||
@@ -103,6 +103,13 @@ static int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){
|
||||
assert( eLock==READ_LOCK || eLock==WRITE_LOCK );
|
||||
assert( p->db!=0 );
|
||||
|
||||
/* If requesting a write-lock, then the Btree must have an open write
|
||||
** transaction on this file. And, obviously, for this to be so there
|
||||
** must be an open write transaction on the file itself.
|
||||
*/
|
||||
assert( eLock==READ_LOCK || (p==pBt->pWriter && p->inTrans==TRANS_WRITE) );
|
||||
assert( eLock==READ_LOCK || pBt->inTransaction==TRANS_WRITE );
|
||||
|
||||
/* This is a no-op if the shared-cache is not enabled */
|
||||
if( !p->sharable ){
|
||||
return SQLITE_OK;
|
||||
@@ -138,8 +145,18 @@ static int querySharedCacheTableLock(Btree *p, Pgno iTab, u8 eLock){
|
||||
iTab==MASTER_ROOT
|
||||
){
|
||||
for(pIter=pBt->pLock; pIter; pIter=pIter->pNext){
|
||||
if( pIter->pBtree!=p && pIter->iTable==iTab &&
|
||||
(pIter->eLock!=eLock || eLock!=READ_LOCK) ){
|
||||
/* The condition (pIter->eLock!=eLock) in the following if(...)
|
||||
** statement is a simplification of:
|
||||
**
|
||||
** (eLock==WRITE_LOCK || pIter->eLock==WRITE_LOCK)
|
||||
**
|
||||
** since we know that if eLock==WRITE_LOCK, then no other connection
|
||||
** may hold a WRITE_LOCK on any table in this file (since there can
|
||||
** only be a single writer).
|
||||
*/
|
||||
assert( pIter->eLock==READ_LOCK || pIter->eLock==WRITE_LOCK );
|
||||
assert( eLock==READ_LOCK || pIter->pBtree==p || pIter->eLock==READ_LOCK);
|
||||
if( pIter->pBtree!=p && pIter->iTable==iTab && pIter->eLock!=eLock ){
|
||||
sqlite3ConnectionBlocked(p->db, pIter->pBtree->db);
|
||||
if( eLock==WRITE_LOCK ){
|
||||
assert( p==pBt->pWriter );
|
||||
|
Reference in New Issue
Block a user