Subject | Re: [Firebird-Architect] DDL Triggers |
---|---|
Author | Vlad Khorsun |
Post date | 2008-09-21T07:06:06Z |
> Usage:Why this limitation ?
> 1) Log database changes for inspection or replication.
> 2) Enforce object name convention. For example, DBA decides that all
> procedures should have prefix "SP_".
> 3) Implement (flexible) metadata security using exceptions.
>
> Syntax:
>
> CREATE TRIGGER <name> { BEFORE | AFTER } <ddl event> ...
>
> <ddl event> ::=
> ANY DDL EVENT
> | <ddl event list>
>
> <ddl event list> ::=
> <ddl event item>
> | <ddl event list> OR <ddl event item>
> * There will be a limit on number of items on this list. If I'm not
> wrong, it can have a max of 13 items.
> <ddl event item> ::=...
> CREATE TABLE
> DDL_TRIGGER context namespaceNot sure i like context's more than old good 'OLD' and 'NEW' pseudo tables.
> - DDL_EVENT: event name (<ddl event item>)We already have UPDATED and DELETED system functions for table's triggers.
I prefer to be consistent with it. For example we may introduce new system functions
such as CREATED\ALTERED\DROPPED or even use existing UPDATED (for ALTER)
and DELETED (for DROP) functions. And, of course, introduce new function OBJECT_TYPE.
> - OBJECT_NAME: metadata object nameIts ok and may be used with OLD and NEW
> - SQL_TEXT: sql statement textThis one we can use with NEW only. Note, when CREATEing and ALTERing procedures
and triggers our parser cut off statement header. I think it is not good and like to change it
in FB3. But i worry about backward compatibility... DDL Triggers adds one more argument
to store full text of procedures and triggers.
> Triggers are fired (from DYN or DdlNodes) in these moments:Seems ok
> - BEFORE triggers executes before system table changes.
> - AFTER triggers executes just after system table changes.
> The only practical difference from them should be that AFTER triggersIn system tables only. And we must explicitly warn user about it.
> see updated metadata.
> With CREATE OR ALTER statements, trigger is fired one time using theOf course.
> CREATE or ALTER event based on previous existence of the object.
> With RECREATE statements, trigger is fired for DROP (when object exists)
> and for CREATE events.
Regards,
Vlad