Alexey Pechnikov <[EMAIL PROTECTED]>
> ÷ ÓÏÏÂÝÅÎÉÉ ÏÔ Tuesday 26 August 2008 16:44:56 Igor Tandetnik
>>> Can I group logged queries by any transaction id?
>> Well, BEGIN TRANSACTION and END TRANSACTION are themselves queries,
>> and thus will presumably appear in your log. Any queries in between
>> would then belong to that transaction.
> I don't know method to set triggers on begin and commit transaction
> events.

You could log begin/end transaction (along with any other statements) by 
installing sqlite3_trace hook.

Another approach would be to use sqlite3_commit_hook, 
sqlite3_rollback_hook, sqlite3_get_autocommit. Call 
sqlite3_get_autocommit from inside your custom function to see whether 
the statement is part of an explicit transaction. sqlite3_commit_hook 
and sqlite3_rollback_hook tell you when a transaction ends. The first 
query that's part of an explicit transaction after a previous 
transaction (if any) has ended, starts a new one.

By the way, see sqlite3_update_hook. Perhaps you could use that in lieu 
of your triggers.

Igor Tandetnik

sqlite-users mailing list

Reply via email to