Re: Shorthand syntax for triggers

From: Craig Ringer <ringerc(at)ringerc(dot)id(dot)au>
To: Joe Van Dyk <joe(at)tanga(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Shorthand syntax for triggers
Date: 2012-10-11 05:13:47
Message-ID: 5076558B.4080102@ringerc.id.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tigran Najaryan 2012-10-11 05:21:12 Re: Storing large files in multiple schemas: BLOB or BYTEA
Previous Message Craig Ringer 2012-10-11 04:57:07 Re: moving from MySQL to pgsql