Re: deparsing utility commands

From: Andres Freund <andres(at)anarazel(dot)de>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Ryan Pedela <rpedela(at)datalanche(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: deparsing utility commands
Date: 2015-04-02 16:11:08
Message-ID: 20150402161108.GF17586@awork2.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2015-04-02 12:05:13 -0400, Robert Haas wrote:
> On Wed, Mar 25, 2015 at 3:21 PM, Ryan Pedela <rpedela(at)datalanche(dot)com> wrote:
> > On Wed, Mar 25, 2015 at 11:59 AM, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
> > wrote:
> >> * Should we prohibit DDL from within event triggers?
> >
> > Please don't prohibit DDL unless there is a really, really good reason to do
> > so. I have several use cases in mind for event triggers, but they are only
> > useful if I can perform DDL.
> >
> > For example, I want to create an Elasticsearch FDW and use that to index and
> > search Postgres tables. When a table is created, I am planning to use an
> > event trigger to capture the CREATE event and automatically create a foreign
> > table via the Elasticsearch FDW. In addition, I would add normal triggers to
> > the new table which capture DML and update the foreign table accordingly. In
> > other words, I want to use FDWs and event triggers to automatically sync
> > table DDL and DML to Elasticsearch.
>
> +1. I think that if it's unsafe to run DDL from with event triggers,
> then that might be a sign that it's not safe to run *any* user-defined
> code at that location. I think it's the job of the event trigger to
> make sure that it doesn't assume anything about what may have changed
> while the user-defined code was running.

First of: I don't see a fundamental reason to forbid it, I think it's
just simpler to analyze that way. But I'm unconvinced by that
reasoning. As you know we prohibit executing DDL on some objects in
*lots* of places c.f. CheckTableNotInUse(), without that imo being a
sign of a more fundamental problem.

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2015-04-02 16:14:45 Re: Abbreviated keys for Numeric
Previous Message Robert Haas 2015-04-02 16:05:13 Re: deparsing utility commands