Re: Shorthand syntax for triggers - Mailing list pgsql-general

From Craig Ringer
Subject Re: Shorthand syntax for triggers
Date
Msg-id 5076558B.4080102@ringerc.id.au
Whole thread Raw
In response to Shorthand syntax for triggers  (Joe Van Dyk <joe@tanga.com>)
List pgsql-general
On 10/11/2012 12:22 AM, Joe Van Dyk wrote:

> 3. Triggers can access a special CHANGED value that's either NEW for
> insert or updates, or OLD for deletes.

I'm not a big fan of the prior comments about small syntax changes, but
this would simplify quite a bit of code. I'd *really* like a way to
refer to "NEW for INSERT or UPDATE, OLD for DELETE" as an implicit
automatic variable.

I do see the appeal of making trigger functions anonymous, but I really
doubt it's worth the hassle.

> 4. Default for 'after insert' triggers is to return null, as I believe
> it doesn't matter what you return here.

This is a trivial convenience, but not one I'd be against.

> 5. Way less repetitive typing.

If you're repeating the same triggers over and over you may want to look
at writing them to be re-usable. See eg:

     http://wiki.postgresql.org/wiki/Audit_trigger_91plus

--
Craig Ringer



pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: moving from MySQL to pgsql
Next
From:
Date:
Subject: Re: Storing large files in multiple schemas: BLOB or BYTEA