xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3_wal_hook.3 (revision 82d56013d7b633d116a93943de88e08335357a7c)
1.Dd December 19, 2018
2.Dt SQLITE3_WAL_HOOK 3
3.Os
4.Sh NAME
5.Nm sqlite3_wal_hook
6.Nd Write-Ahead Log Commit Hook
7.Sh SYNOPSIS
8.Ft void *
9.Fo sqlite3_wal_hook
10.Fa "sqlite3*"
11.Fa "int(*)(void *,sqlite3*,const char*,int)"
12.Fa "void* "
13.Fc
14.Sh DESCRIPTION
15The sqlite3_wal_hook() function is used to register
16a callback that is invoked each time data is committed to a database
17in wal mode.
18.Pp
19The callback is invoked by SQLite after the commit has taken place
20and the associated write-lock on the database released  , so the implementation
21may read, write or checkpoint the database as required.
22.Pp
23The first parameter passed to the callback function when it is invoked
24is a copy of the third parameter passed to sqlite3_wal_hook() when
25registering the callback.
26The second is a copy of the database handle.
27The third parameter is the name of the database that was written to
28- either "main" or the name of an ATTACH-ed database.
29The fourth parameter is the number of pages currently in the write-ahead
30log file, including those that were just committed.
31.Pp
32The callback function should normally return SQLITE_OK.
33If an error code is returned, that error will propagate back up through
34the SQLite code base to cause the statement that provoked the callback
35to report an error, though the commit will have still occurred.
36If the callback returns SQLITE_ROW or SQLITE_DONE,
37or if it returns a value that does not correspond to any valid SQLite
38error code, the results are undefined.
39.Pp
40A single database handle may have at most a single write-ahead log
41callback registered at one time.
42Calling sqlite3_wal_hook() replaces any previously
43registered write-ahead log callback.
44Note that the sqlite3_wal_autocheckpoint()
45interface and the wal_autocheckpoint pragma
46both invoke sqlite3_wal_hook() and will overwrite
47any prior sqlite3_wal_hook() settings.
48.Sh SEE ALSO
49.Xr sqlite3_wal_autocheckpoint 3 ,
50.Xr sqlite3_wal_hook 3 ,
51.Xr SQLITE_OK 3
52