xref: /netbsd-src/external/public-domain/sqlite/man/sqlite3_update_hook.3 (revision 022f005200bc25af02826a05c8d86d0ef18232dc)
1.Dd March 11, 2017
2.Dt SQLITE3_UPDATE_HOOK 3
3.Os
4.Sh NAME
5.Nm sqlite3_update_hook
6.Nd Data Change Notification Callbacks
7.Sh SYNOPSIS
8.Ft void *
9.Fo sqlite3_update_hook
10.Fa "sqlite3*"
11.Fa "void(*)(void *,int ,char const *,char const *,sqlite3_int64)"
12.Fa "void* "
13.Fc
14.Sh DESCRIPTION
15The sqlite3_update_hook() interface registers a callback function with
16the database connection identified by the first
17argument to be invoked whenever a row is updated, inserted or deleted
18in a rowid table.
19Any callback set by a previous call to this function for the same database
20connection is overridden.
21.Pp
22The second argument is a pointer to the function to invoke when a row
23is updated, inserted or deleted in a rowid table.
24The first argument to the callback is a copy of the third argument
25to sqlite3_update_hook().
26The second callback argument is one of SQLITE_INSERT,
27SQLITE_DELETE, or SQLITE_UPDATE, depending
28on the operation that caused the callback to be invoked.
29The third and fourth arguments to the callback contain pointers to
30the database and table name containing the affected row.
31The final callback parameter is the rowid of the row.
32In the case of an update, this is the rowid after the update takes
33place.
34.Pp
35The update hook is not invoked when internal system tables are modified
36(i.e.
37sqlite_master and sqlite_sequence).
38The update hook is not invoked when WITHOUT ROWID tables
39are modified.
40.Pp
41In the current implementation, the update hook is not invoked when
42conflicting rows are deleted because of an  ON CONFLICT REPLACE
43clause.
44Nor is the update hook invoked when rows are deleted using the truncate optimization.
45The exceptions defined in this paragraph might change in a future release
46of SQLite.
47.Pp
48The update hook implementation must not do anything that will modify
49the database connection that invoked the update hook.
50Any actions to modify the database connection must be deferred until
51after the completion of the sqlite3_step() call that
52triggered the update hook.
53Note that sqlite3_prepare_v2() and sqlite3_step()
54both modify their database connections for the meaning of "modify"
55in this paragraph.
56.Pp
57The sqlite3_update_hook(D,C,P) function returns the P argument from
58the previous call on the same database connection
59D, or NULL for the first call on D.
60.Pp
61See also the sqlite3_commit_hook(), sqlite3_rollback_hook(),
62and sqlite3_preupdate_hook() interfaces.
63.Sh SEE ALSO
64.Xr sqlite3 3 ,
65.Xr sqlite3_commit_hook 3 ,
66.Xr sqlite3_prepare 3 ,
67.Xr sqlite3_preupdate_hook 3 ,
68.Xr sqlite3_commit_hook 3 ,
69.Xr sqlite3_step 3 ,
70.Xr SQLITE_CREATE_INDEX 3
71