Dan Kennedy wrote:
On Mon, 2007-03-12 at 10:51 +0100, Jef Driesen wrote:
I was planning to use the sqlite3_update_hook function to notify my GUI
about changes. The idea was that every part of the GUI can update itself
when a database change is detected. But during testing, I encountered
some problems with this approach together with transactions.
When I group some SQL statements inside a transaction (for performance
or because they have to succeed or fail all together), the callback
function is executed for every statement:
BEGIN
statement 1 -> callback function called
statement 2 -> callback function called
COMMIT
But if the COMMIT is replaced with a ROLLBACK (for instance when an
error is detected), the callback functions are still called and the GUI
is updated with data that is not actually written to the database.
Any ideas on how to prevent this from happening?
Accumulate updates in a custom data structure (list or something) each
time the update_hook() callback is invoked.
Also register callbacks with sqlite3_commit_hook() and
sqlite3_rollback_hook(). When the commit_hook() callback is invoked,
update the GUI. When either the commit or rollback hooks are invoked,
reset the data structure to empty.
I think that approach should work. But the function sqlite3_commit_hook
is marked experimental in the documentation. What does that means? Is it
safe to rely on it?
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------