FWIW, I'm making progress.  I've got BEGIN and COMMIT triggers firing,
but there's issues related to auto-commit which imply that I need to
be able to skip -at runtime- the trigger firing that I code with each
OP_Transaction and OP_AutoCommit operation, which I think means I need
a new op, but we'll see.

Also, I've decided to change the syntax so it's AFTER BEGIN and BEFORE COMMIT.

AFTER BEGIN triggers will only fire for RESERVED and IMMEDIATE
transactions, and on the first INSERT/UPDATE/DELETE in a RESERVED
transaction.

BEFORE COMMIT triggers can fire more than once: because the commit
might fail due to, e.g., deferred constraints, and even because the
triggers themselves might RAISE(...).  Speaking of which,
RAISE(IGNORE) in these triggers should be ignored and the BEGIN/COMMIT
proceeds as usual -- I've not tested that yet, but I suspect that one
of RAISE(ABORT/FAIL) or RAISE(IGNORE) in such triggers will not work
as expected without additional code.

I'll also code up BEFORE ROLLBACK trigger firing, but only for
synchronous rollbacks (i.e., when the app executes a ROLLBACK
statement).  I don't think ROLLBACK triggers could be of any use
unless there are functions and/or virtual tables with side-effects
(think logging).

Database connect/disconnect triggers will not fire by default; a new
pragma will be needed to enable them.  Connect triggers will fire when
that pragma is enabled (or if compiled as enabled, then when the DB
handle is opened).  Disconnect triggers will fire immediately upon
entry to sqlite3_close(), and if sqlite3_close fails (e.g., due to
SQLITE_BUSY), their firing may seem spurious, just as with BEFORE
COMMIT triggers.

I've no need for AFTER ROLLBACK/COMMIT triggers (besides, those seem daunting).

My patches so far are small, believe it or not.  (But I spent a lot of
time figuring out how to create the crutch views automatically, and a
lot of time figuring out how to fire the triggers.)  Things work, with
some quirks and some missing functionality, so it's not ready yet.

Nico
--
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to