1.Dd January 24, 2024 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.In sqlite3.h 9.Ft void * 10.Fo sqlite3_update_hook 11.Fa "sqlite3*" 12.Fa "void(*)(void *,int ,char const *,char const *,sqlite3_int64)" 13.Fa "void*" 14.Fc 15.Sh DESCRIPTION 16The sqlite3_update_hook() interface registers a callback function with 17the database connection identified by the first 18argument to be invoked whenever a row is updated, inserted or deleted 19in a rowid table. 20Any callback set by a previous call to this function for the same database 21connection is overridden. 22.Pp 23The second argument is a pointer to the function to invoke when a row 24is updated, inserted or deleted in a rowid table. 25The first argument to the callback is a copy of the third argument 26to sqlite3_update_hook(). 27The second callback argument is one of SQLITE_INSERT, 28SQLITE_DELETE, or SQLITE_UPDATE, depending 29on the operation that caused the callback to be invoked. 30The third and fourth arguments to the callback contain pointers to 31the database and table name containing the affected row. 32The final callback parameter is the rowid of the row. 33In the case of an update, this is the rowid after the update takes 34place. 35.Pp 36The update hook is not invoked when internal system tables are modified 37(i.e. 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 52.Fn sqlite3_step 53call that triggered the update hook. 54Note that 55.Fn sqlite3_prepare_v2 56and 57.Fn sqlite3_step 58both modify their database connections for the meaning of "modify" 59in this paragraph. 60.Pp 61The sqlite3_update_hook(D,C,P) function returns the P argument from 62the previous call on the same database connection 63D, or NULL for the first call on D. 64.Pp 65See also the 66.Fn sqlite3_commit_hook , 67.Fn sqlite3_rollback_hook , 68and 69.Fn sqlite3_preupdate_hook 70interfaces. 71.Sh IMPLEMENTATION NOTES 72These declarations were extracted from the 73interface documentation at line 6838. 74.Bd -literal 75SQLITE_API void *sqlite3_update_hook( 76 sqlite3*, 77 void(*)(void *,int ,char const *,char const *,sqlite3_int64), 78 void* 79); 80.Ed 81.Sh SEE ALSO 82.Xr sqlite3 3 , 83.Xr sqlite3_commit_hook 3 , 84.Xr sqlite3_prepare 3 , 85.Xr sqlite3_preupdate_hook 3 , 86.Xr sqlite3_step 3 , 87.Xr SQLITE_CREATE_INDEX 3 88