mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-07 02:42:48 +03:00
Add experimental API sqlite3_db_cacheflush().
FossilOrigin-Name: 65b86dc1fa4a57cc3cde86a820d9f848aa288a15
This commit is contained in:
33
src/main.c
33
src/main.c
@@ -740,6 +740,39 @@ int sqlite3_db_release_memory(sqlite3 *db){
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
** Flush any dirty pages in the pager-cache for any attached database
|
||||
** to disk.
|
||||
*/
|
||||
int sqlite3_db_cacheflush(sqlite3 *db){
|
||||
int i;
|
||||
int rc = SQLITE_OK;
|
||||
int bSeenBusy = 0;
|
||||
|
||||
#ifdef SQLITE_ENABLE_API_ARMOR
|
||||
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
|
||||
#endif
|
||||
sqlite3_mutex_enter(db->mutex);
|
||||
sqlite3BtreeEnterAll(db);
|
||||
for(i=0; rc==SQLITE_OK && i<db->nDb; i++){
|
||||
Btree *pBt = db->aDb[i].pBt;
|
||||
if( pBt && sqlite3BtreeIsInTrans(pBt) ){
|
||||
Pager *pPager = sqlite3BtreePager(pBt);
|
||||
rc = sqlite3PagerFlush(pPager);
|
||||
if( rc==SQLITE_BUSY ){
|
||||
bSeenBusy = 1;
|
||||
rc = SQLITE_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( rc!=SQLITE_OK ){
|
||||
sqlite3RollbackAll(db, SQLITE_ABORT_ROLLBACK);
|
||||
}
|
||||
sqlite3BtreeLeaveAll(db);
|
||||
sqlite3_mutex_leave(db->mutex);
|
||||
return ((rc==SQLITE_OK && bSeenBusy) ? SQLITE_BUSY : rc);
|
||||
}
|
||||
|
||||
/*
|
||||
** Configuration settings for an individual database connection
|
||||
*/
|
||||
|
Reference in New Issue
Block a user