Small. Fast. Reliable.
Choose any three.

About Sitemap Documentation Download License News Developers Support

## SQLite C Interface

## Commit And Rollback Notification Callbacks

>     void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
>     void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);

The sqlite3_commit_hook() interface registers a callback function to be invoked whenever a transaction is committed. Any callback set by a previous call to sqlite3_commit_hook() for the same database connection is overridden. The sqlite3_rollback_hook() interface registers a callback function to be invoked whenever a transaction is committed. Any callback set by a previous call to sqlite3_commit_hook() for the same database connection is overridden. The pArg argument is passed through to the callback. If the callback on a commit hook function returns non-zero, then the commit is converted into a rollback.

If another function was previously registered, its pArg value is returned. Otherwise NULL is returned.

Registering a NULL function disables the callback.

For the purposes of this API, a transaction is said to have been rolled back if an explicit "ROLLBACK" statement is executed, or an error or constraint causes an implicit rollback to occur. The rollback callback is not invoked if a transaction is automatically rolled back because the database connection is closed. The rollback callback is not invoked if a transaction is rolled back because a commit callback returned non-zero. (TODO: Check on this )

These are experimental interfaces and are subject to change.

### Invariants:

F12951 | The sqlite3_commit_hook(D,F,P) interface registers the callback function F to be invoked with argument P whenever a transaction commits on database connection D.
F12952 | The sqlite3_commit_hook(D,F,P) interface returns the P argument from the previous call with the same database connection D , or NULL on the first call for a particular database connection D.
F12953 | Each call to sqlite3_commit_hook() overwrites the callback registered by prior calls.
F12954 | If the F argument to sqlite3_commit_hook(D,F,P) is NULL then the commit hook callback is cancelled and no callback is invoked when a transaction commits.
F12955 | If the commit callback returns non-zero then the commit is converted into a rollback.
F12961 | The sqlite3_rollback_hook(D,F,P) interface registers the callback function F to be invoked with argument P whenever a transaction rolls back on database connection D.
F12962 | The sqlite3_rollback_hook(D,F,P) interface returns the P argument from the previous call with the same database connection D , or NULL on the first call for a particular database connection D.
F12963 | Each call to sqlite3_rollback_hook() overwrites the callback registered by prior calls.
F12964 | If the F argument to sqlite3_rollback_hook(D,F,P) is NULL then the rollback hook callback is cancelled and no callback is invoked when a transaction rolls back.

See also lists of Objects, Constants, and Functions.

This page last modified 2008/05/12 13:08:44 UTC