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 )

### Invariants:

H12951 | The sqlite3_commit_hook(D,F,P) interface registers the callback function F to be invoked with argument P whenever a transaction commits on the database connection D.
H12952 | 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.
H12953 | Each call to sqlite3_commit_hook() overwrites the callback registered by prior calls.
H12954 | If the F argument to sqlite3_commit_hook(D,F,P) is NULL then the commit hook callback is canceled and no callback is invoked when a transaction commits.
H12955 | If the commit callback returns non-zero then the commit is converted into a rollback.
H12961 | 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 the database connection D.
H12962 | 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.
H12963 | Each call to sqlite3_rollback_hook() overwrites the callback registered by prior calls.
H12964 | If the F argument to sqlite3_rollback_hook(D,F,P) is NULL then the rollback hook callback is canceled and no callback is invoked when a transaction rolls back.

See also lists of Objects, Constants, and Functions.

This page last modified 2008/08/11 17:57:43 UTC