Re: Command Triggers, v16

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, Thom Brown <thombrown(at)gmail(dot)com>
Subject: Re: Command Triggers, v16
Date: 2012-03-16 08:43:53
Message-ID: 201203160943.53950.andres@anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Thursday, March 15, 2012 10:58:49 PM Dimitri Fontaine wrote:
> I tricked that in the grammar, the type is called cmdtrigger but I
> though it wouldn't be a good choice for the SQL statement.
Hm. I am decidedly unhappy with that grammar hackery... But then maybe I am
squeamish.

> + oid | typname | oid | proname
> +------+------------+------+------------
> + 1790 | refcursor | 46 | textin
> + 3838 | cmdtrigger | 2300 | trigger_in
> +(2 rows)
Hm. Wonder if its a good idea to reuse trigger_in. So far we have duplicated
functions for that.

> @@ -482,12 +494,21 @@ ListCommandTriggers(CommandContext cmd)
>
> switch (form->ctgtype)
> {
>
> case CMD_TRIGGER_FIRED_BEFORE:
> - cmd->before = lappend_oid(cmd->before, form->ctgfoid);
> + {
> + if (list_any_triggers)
> + cmd->before_any = lappend_oid(cmd->before_any,
> form->ctgfoid); + else
> + cmd->before = lappend_oid(cmd->before, form->ctgfoid);
>
> break;
>
> -
> ...
> + case CMD_TRIGGER_FIRED_BEFORE:
> + {
> + whenstr = "BEFORE";
> +
> + foreach(cell, cmd->before_any)
> + {
> + Oid proc = lfirst_oid(cell);
> +
> + call_cmdtrigger_procedure(cmd, (RegProcedure)proc,
> whenstr); + }
> + foreach(cell, cmd->before)
> + {
> + Oid proc = lfirst_oid(cell);
> +
> + call_cmdtrigger_procedure(cmd, (RegProcedure)proc,
> whenstr); + }
> + break;
> + }
This will have the effect of calling triggers outside of alphabetic order. I
don't think thats a good idea even if one part is ANY and the other a specific
command.
I don't think there is any reason anymore to separate the two? The only
callsite seems to look like:

632- default:
633: ListCommandTriggers(cmd, true); /* list ANY command triggers */
634: ListCommandTriggers(cmd, false); /* and triggers for this
command tag */

Andres

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Etsuro Fujita 2012-03-16 08:44:25 Proposal: Create index on foreign table
Previous Message Thom Brown 2012-03-16 08:30:58 Re: Command Triggers, v16