Subject | Re: [Firebird-Architect] Database triggers |
---|---|
Author | Vlad Horsun |
Post date | 2006-09-19T12:55:23Z |
"Adriano dos Santos Fernandes" ...
fired after user validation and attachment creation but before
return from jrd8_attach_database. Worked in own auto-started
and auto-stoped transaction. Any unhandled exception prevent
CONNECT to be succsesfull and error code returns to client as
result
fired before erase of any attachment resources. Worked in own
auto-started and auto-stoped transaction. Any unhandled exception
don't prevent DISCONNECT but logged in firebird.log
fired just after transaction starts in context of that transaction.
Any unhandled exception breaks this transaction. Error code returns
to client
fired before transaction end (and therefore before any DFW works).
Unhandled exception leave transaction open. Error code returns to client
What to do with commit\rollback_retaining ? Needs read-only context variable
with kind of transaction end (commit\rollback).
Or use common syntax
ON <TRANSACTION | COMMIT | ROLLBACK>
where ON TRANSACTION fired after transaction start, ON COMMIT - before
commit, ON ROLLBACK - before rollback
Regards,
Vlad
PS What about triggers on DDL : CREATE\ALTER\DROP TABLE\PROCEDURE\etc ?
> Triggers fired in database events are useful for many things:And on rollback of course
> On connect/disconnect for logging or logon control.
> On begin transaction for implementation of a "writable transaction
> id" (incrementing a generator and storing in a context variable).
> On commit triggers for business rules validations.
> Proposed syntax:ON CONNECT
> CREATE TRIGGER <name> <type> AS ...
>
> Types:
> AFTER CONNECT (or LOGON as in Oracle?)
fired after user validation and attachment creation but before
return from jrd8_attach_database. Worked in own auto-started
and auto-stoped transaction. Any unhandled exception prevent
CONNECT to be succsesfull and error code returns to client as
result
> BEFORE DISCONNECT (or LOGOFF)ON DISCONNECT
fired before erase of any attachment resources. Worked in own
auto-started and auto-stoped transaction. Any unhandled exception
don't prevent DISCONNECT but logged in firebird.log
> AFTER BEGIN TRANSACTIONON BEGIN TRANSACTION
fired just after transaction starts in context of that transaction.
Any unhandled exception breaks this transaction. Error code returns
to client
> BEFORE COMMITON END TRANSACTION
fired before transaction end (and therefore before any DFW works).
Unhandled exception leave transaction open. Error code returns to client
What to do with commit\rollback_retaining ? Needs read-only context variable
with kind of transaction end (commit\rollback).
Or use common syntax
ON <TRANSACTION | COMMIT | ROLLBACK>
where ON TRANSACTION fired after transaction start, ON COMMIT - before
commit, ON ROLLBACK - before rollback
> They will be stored in RDB$TRIGGERS with RDB$RELATION_NAME = NULL.Agree
>
> RDB$TRIGGER_TYPE will store incompatible values with the current ones,
> but RDB$RELATION_NAME = NULL make they work in different ways.
> Or another field (RDB$TRIGGER_KIND?) could be created to store in whatFor now i don't see needs in such field
> event the trigger are fired (DML, DATABASE, DDL in the future), so the
> real trigger type become (RDB$TRIGGER_KIND, RDB$TRIGGER_TYPE).
> These triggers may make the database unusable (for example, an exceptionMaybe yes
> in a CONNECT trigger), so it could be disabled (only for the attachment)
> through a DPB, but only by sysdba/db-owner.
> Attachments from GBAK/GFIX/GSEC automatically make this flag ON.Why ?
> To run CONNECT/DISCONNECT, the engine will start and finish a snapshotAgree. What about other parameters ? concurrency, write, wait ?
> transaction.
> Exceptions in CONNECT, BEGIN TRANSACTION and COMMIT cancels theAgree
> operation. But not cancels (the detach) in DISCONNECT.
Regards,
Vlad
PS What about triggers on DDL : CREATE\ALTER\DROP TABLE\PROCEDURE\etc ?