Re: [BUGS] BUG #14815: event trigger in extension - Mailing list pgsql-bugs

From Tom Lane
Subject Re: [BUGS] BUG #14815: event trigger in extension
Date
Msg-id 26965.1505591535@sss.pgh.pa.us
Whole thread Raw
In response to [BUGS] BUG #14815: event trigger in extension  (gomer94@yandex.ru)
Responses Re: [BUGS] BUG #14815: event trigger in extension
List pgsql-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

pgsql-bugs by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: [BUGS] Query planner skipping index depending on DISTINCTparameter order (2)
Next
From: Alexander Scott
Date:
Subject: Re: [BUGS] BUG #14817: pg_dumpall is not generating create databasestatements