On Tue, 26 Aug 2008 20:11:05 +0400, you wrote: >Hello! > >? ????????? ?? Tuesday 26 August 2008 18:59:55 Igor Tandetnik ???????(?): >> > 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. > >Thanks, it's better way for my task. But is it safe to logging uncommited >changes?
Logging uncommitted changes is fine as long as - you also log commits - only replay / evaluate complete transactions, complete being defined as "having a commit on the logfile" Logging rollbacks strictly isn't necessary, because rolled back transactions have to be identified by the missing commit logrecord, not by the presence of a rollback logrecord. Reason: In case of crashes you won't be able to log rollbacks, anyway, whereas SQLite will rollback using the journal the first time a new connection is made. >Best regards, Alexey. -- ( Kees Nuyt ) c[_] _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users