Re: Command Triggers, patch v11

From: Thom Brown <thom(at)linux(dot)com>
To: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Command Triggers, patch v11
Date: 2012-03-03 15:55:35
Message-ID: CAA-aLv6ddTAwT3LcghhVWMCvtXz7WHO2GuoqFvo5WzWcaCtGag@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 3 March 2012 14:34, Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr> wrote:
> Thom Brown <thom(at)linux(dot)com> writes:
>> problem.  It was the DROP COMMAND TRIGGER statement that garnered
>> comment, as it makes more sense to drop the entire trigger than
>> individual commands for that trigger.
>
> What you're saying here is that a single command could have more than
> one command attached to it, and what I understand Tom, Robert and Kevin
> are saying is that any given command trigger should only be attached to
> a single command.

I hadn't interpreted it that way, but then that could just be my
misinterpretation. I'm still of the opinion that a single command
trigger should be able to attach to multiple commands, just not
amendable once the trigger has been created. If that's not how others
saw it, I'm outnumbered.

So my vote was for:

CREATE COMMAND TRIGGER name { BEFORE | AFTER } command [, ... ]
EXECUTE PROCEDURE function_name ()

ALTER COMMAND TRIGGER name SET enabled

DROP COMMAND TRIGGER [ IF EXISTS ] name [ CASCADE | RESTRICT ]

The only difference shown above compared to the current implementation
in your patch is [, ... ] after command in the CREATE COMMAND TRIGGER
statement.

My argument for this is that you may wish to implement the same
trigger for tables, views and foreign tables rather than create 3
separate triggers.

> If we wanted to be more consistent we would need to have a way to attach
> the same trigger to both BEFORE and AFTER the command, as of now you
> need two triggers here.

I'm not sure I understand. Attaching a trigger to both BEFORE and
AFTER isn't possible for regular triggers so I don't see why that
would introduce consistency. Could you explain?

--
Thom

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin Grittner 2012-03-03 16:12:54 Re: Command Triggers, patch v11
Previous Message Thom Brown 2012-03-03 15:37:02 Re: Command Triggers, patch v11