mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
In shared-cache mode, do not allow one connection to checkpoint a database while a second connection is reading or writing the same shared-cache.
FossilOrigin-Name: e75b52d156905ce16bedb94f65c01a4640bdfa75
This commit is contained in:
23
src/btree.c
23
src/btree.c
@@ -7848,6 +7848,29 @@ int sqlite3BtreeIsInTrans(Btree *p){
|
||||
return (p && (p->inTrans==TRANS_WRITE));
|
||||
}
|
||||
|
||||
#ifndef SQLITE_OMIT_WAL
|
||||
/*
|
||||
** Run a checkpoint on the Btree passed as the first argument.
|
||||
**
|
||||
** Return SQLITE_LOCKED if this or any other connection has an open
|
||||
** transaction on the shared-cache the argument Btree is connected to.
|
||||
*/
|
||||
int sqlite3BtreeCheckpoint(Btree *p){
|
||||
int rc = SQLITE_OK;
|
||||
if( p ){
|
||||
BtShared *pBt = p->pBt;
|
||||
sqlite3BtreeEnter(p);
|
||||
if( pBt->inTransaction!=TRANS_NONE ){
|
||||
rc = SQLITE_LOCKED;
|
||||
}else{
|
||||
rc = sqlite3PagerCheckpoint(pBt->pPager);
|
||||
}
|
||||
sqlite3BtreeLeave(p);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
** Return non-zero if a read (or write) transaction is active.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user