Re: Command Triggers, v16 - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Command Triggers, v16
Date
Msg-id 201203160943.53950.andres@anarazel.de
Whole thread Raw
In response to Re: Command Triggers, v16  (Dimitri Fontaine <dimitri@2ndQuadrant.fr>)
Responses Re: Command Triggers, v16
Re: Command Triggers, v16
List 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


pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Proposal: Create index on foreign table
Next
From: Andres Freund
Date:
Subject: Re: Command Triggers, v16