Re: Command Triggers

From: Andres Freund <andres(at)anarazel(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Dimitri Fontaine <dimitri(at)2ndquadrant(dot)fr>, Robert Haas <robertmhaas(at)gmail(dot)com>, Greg Smith <greg(at)2ndquadrant(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Subject: Re: Command Triggers
Date: 2012-01-18 20:51:49
Message-ID: 201201182151.49439.andres@anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wednesday, January 18, 2012 08:31:49 PM Tom Lane wrote:
> Dimitri Fontaine <dimitri(at)2ndQuadrant(dot)fr> writes:
> > We can easily enough copy the parse tree and do another round of parse
> > analysis on it only when some command triggers are going to get called.
> > Is the cost of doing so acceptable?
>
> It's not the costs I'm worried about so much as the side effects ---
> locks and so forth. Also, things like assignment of specific names
> for indexes and sequences seem rather problematic. In the worst case
> the trigger could run seeing "foo_bar_idx1" as the name of an index
> to be created, and then when the action actually happens, the name
> turns out to be "foo_bar_idx2" because someone else took the first name
> meanwhile.
You can't generally assume such a thing anyway. Remember there can be BEFORE
command triggers. It would be easy to create a conflict there.

The CREATE TABLE will trigger command triggers on CREATE SEQUENCE and ALTER
SEQUENCE while creating the table. If one actually wants to do anything about
those that would be the place.

> As I said, I think this suggests that you're trying to do the triggers
> in the wrong place.
In my opinion it mostly shows that parse analysis of utlity statments is to
intermingled with other stuff.... Not sure what to do about that.

Andres

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Martin Pihlak 2012-01-18 20:56:15 Re: Patch review for logging hooks (CF 2012-01)
Previous Message Jignesh Shah 2012-01-18 20:50:35 Re: [WIP] Double-write with Fast Checksums