pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: gomer94@yandex.ru
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14815: event trigger in extension
Date: Sat, 16 Sep 2017 15:52:15 -0400
Message-ID: <26965.1505591535@sss.pgh.pa.us> (raw)
In-Reply-To: <20170913075559.25630.41587@wrigleys.postgresql.org>
References: <20170913075559.25630.41587@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

gomer94@yandex.ru writes:
> I want to create extension with sql like:

> CREATE OR REPLACE FUNCTION keep_any_ddl_command() RETURNS event_trigger
>     LANGUAGE plpgsql
>     AS $$
>     BEGIN
>         SELECT classid, objid, objsubid FROM
> pg_event_trigger_ddl_commands();

>         -- some insert code;
>     END;
> $$;

> CREATE TABLE ddl_events();

> CREATE EVENT TRIGGER keep_all_ddl ON ddl_command_end
>    EXECUTE PROCEDURE keep_any_ddl_command();

I think the reason this fails is that on the way out of the CREATE
EXTENSION command, the event trigger code sees that an event trigger
exists, so it tries to call it.  But because no event trigger existed
when we started the CREATE EXTENSION command, the necessary
infrastructure hasn't been set up --- in particular,
EventTriggerBeginCompleteQuery did nothing at the time.

This seems like it would be an equal hazard for any situation where
CREATE EVENT TRIGGER is executed not at top level.  Don't see an
easy fix right offhand.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (3+ messages)  latest in thread

Message-ID: <26965.1505591535@sss.pgh.pa.us>
Permalink:  ../26965.1505591535@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26965.1505591535@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, gomer94@yandex.ru
  Subject: Re: BUG #14815: event trigger in extension
  In-Reply-To: <26965.1505591535@sss.pgh.pa.us>
  References: <20170913075559.25630.41587@wrigleys.postgresql.org> <26965.1505591535@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox