FOR EACH STATEMENT triggers

From: Neil Conway <neilc(at)samurai(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: FOR EACH STATEMENT triggers
Date: 2002-11-15 02:56:17
Message-ID: 87vg2zh772.fsf@mailbox.samurai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'd like to implement FOR EACH STATEMENT triggers. AFAICS it shouldn't
be too tricky -- so if there's some show-stopper that prevented it
from being done earlier, let me know now, please :-)

Some random notes on the implementation I'm thinking of:

- in the function called by a per-statement trigger, no
references to the 'OLD' or 'NEW' rows will be allowed

- should we allow per-statement BEFORE triggers? DB2 doesn't,
but I'm not sure that's because they just cut corners, or if
there's some legitimate reason not to allow them. AFAICT SQL
200x doesn't specify that they *aren't* allowed, so I'm
inclined to allow them...

- if the statement effects zero rows, a per-statement trigger
is still executed

- COPY executes per-statement INSERT triggers, to stay
consistent with the current behavior WRT per-row INSERT
triggers

- specifying 'FOR EACH xxx' in CREATE TRIGGER should now be
optional; if neither is specified, FOR EACH STATEMENT is the
default. This is per SQL spec (SQL 200x, 11.39, 8)

Comments?

Cheers,

Neil

--
Neil Conway <neilc(at)samurai(dot)com> || PGP Key ID: DB3C29FC

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Marc G. Fournier 2002-11-15 03:02:25 Re: Propose RC1 for Friday ...
Previous Message Bruce Momjian 2002-11-15 02:26:10 log_* GUC variables