1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-11-14 00:22:38 +03:00

Change the behavior of the sqlite3_wal_hook() callback. It should now return

SQLITE_OK or an error code and the error code is propagated back up the 
stack.  If a checkpoint is desired, the callback should invoke
sqlite3_wal_callback() itself.

FossilOrigin-Name: 1b14195e05fe5551992a39246ec3bcf6a33bbfac
This commit is contained in:
drh
2010-05-05 20:00:25 +00:00
parent ccd13d1f80
commit 5def0843f1
8 changed files with 44 additions and 43 deletions

View File

@@ -1189,19 +1189,20 @@ void *sqlite3_rollback_hook(
#ifndef SQLITE_OMIT_WAL
/*
** The sqlite3_wal_hook() callback registered by sqlite3_wal_autocheckpoint().
** Return non-zero, indicating to the caller that a checkpoint should be run,
** if the number of frames in the log file is greater than
** sqlite3.pWalArg cast to an integer (the value configured by
** Invoke sqlite3_wal_checkpoint if the number of frames in the log file
** is greater than sqlite3.pWalArg cast to an integer (the value configured by
** wal_autocheckpoint()).
*/
int sqlite3WalDefaultHook(
void *p, /* Argument */
void *pClientData, /* Argument */
sqlite3 *db, /* Connection */
const char *zNotUsed, /* Database */
const char *zDb, /* Database */
int nFrame /* Size of WAL */
){
UNUSED_PARAMETER(zNotUsed);
return ( nFrame>=SQLITE_PTR_TO_INT(p));
if( nFrame>=SQLITE_PTR_TO_INT(pClientData) ){
sqlite3_wal_checkpoint(db, zDb);
}
return SQLITE_OK;
}
#endif /* SQLITE_OMIT_WAL */
@@ -1218,13 +1219,11 @@ int sqlite3WalDefaultHook(
*/
int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
#ifndef SQLITE_OMIT_WAL
sqlite3_mutex_enter(db->mutex);
if( nFrame>0 ){
sqlite3_wal_hook(db, sqlite3WalDefaultHook, SQLITE_INT_TO_PTR(nFrame));
}else{
sqlite3_wal_hook(db, 0, 0);
}
sqlite3_mutex_leave(db->mutex);
#endif
return SQLITE_OK;
}