Thread: DDL triggers [was Re: [GENERAL] database constraints]
On Thu, Oct 07, 2004 at 11:47:55AM +0700, David Garamond wrote: > Joshua D. Drake wrote: > >>This brings up an interesting idea. What if it were possible to set > >>some kind of rules on DDL at database creation time? For example, I'd > >>like to be able to throw an error if somebody tries to name an object > >>any of the SQL keywords. > >> > >>Other possible rules: > >> > >>* Every table must have a comment > >>* noCamelCaps > >>* downcase all entities > >>* underbar_separators_required > >>* abbrev_w_beg, nt_by_rmvng_vwls > >>* Your favorite algorithmic coding standard here > > > >Hmmm.. like a PostgreSQL syntax mode... in the PostgreSQL.conf: > > > >syntax_mode = lazy, standard, strict > > > >Where lazy is the current , standard would throw exceptions if you > >try to use a reserved word or use uppercase, and strict would do > >things like force a comment. > > I'd much prefer if PostgreSQL had a generalized event or trigger > system. That way, one can install a trigger (or a plugin, or > whatever) to trap CREATE TABLE, CREATE VIEW, etc. > > IMO, your proposed solution is too specific. There are too many > coding styles that people might want to enforce in their > environment. Forwarding to -hackers... Folks, How big a project would it be to have generalized DDL triggers? Apart from resource allocation, what are some downsides of providing such a facility? Cheers, D -- David Fetter david@fetter.org http://fetter.org/ phone: +1 510 893 6100 mobile: +1 415 235 3778 Remember to vote!
David Fetter <david@fetter.org> writes: > How big a project would it be to have generalized DDL triggers? Apart > from resource allocation, what are some downsides of providing such a > facility? BEFORE triggers on the system catalogs are Right Out. In principle we could support AFTER triggers, which would only fire after the catalog operation is fully complete (but before it's committed of course). So you could have a veto, but not really affect the system behavior on-the-fly. See past discussions in the pghackers archives. regards, tom lane
On Thu, 7 Oct 2004, David Fetter wrote: > On Thu, Oct 07, 2004 at 11:47:55AM +0700, David Garamond wrote: > > Joshua D. Drake wrote: > > >>This brings up an interesting idea. What if it were possible to set > > >>some kind of rules on DDL at database creation time? For example, I'd > > >>like to be able to throw an error if somebody tries to name an object > > >>any of the SQL keywords. > > >> > > >>Other possible rules: > > >> > > >>* Every table must have a comment > > >>* noCamelCaps > > >>* downcase all entities > > >>* underbar_separators_required > > >>* abbrev_w_beg, nt_by_rmvng_vwls > > >>* Your favorite algorithmic coding standard here > > > > > >Hmmm.. like a PostgreSQL syntax mode... in the PostgreSQL.conf: > > > > > >syntax_mode = lazy, standard, strict > > > > > >Where lazy is the current , standard would throw exceptions if you > > >try to use a reserved word or use uppercase, and strict would do > > >things like force a comment. > > > > I'd much prefer if PostgreSQL had a generalized event or trigger > > system. That way, one can install a trigger (or a plugin, or > > whatever) to trap CREATE TABLE, CREATE VIEW, etc. > > > > IMO, your proposed solution is too specific. There are too many > > coding styles that people might want to enforce in their > > environment. > > Forwarding to -hackers... > > Folks, > > How big a project would it be to have generalized DDL triggers? Apart > from resource allocation, what are some downsides of providing such a > facility? I discussed this earlier in the year on hackers (say, Jan or Feb). I did not have any time to do this for 8.0 but there is discussion and I believe Bruce added a TODO item. > > Cheers, > D Gavin