pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14815: event trigger in extension
3+ messages / 3 participants
[nested] [flat]
* BUG #14815: event trigger in extension
@ 2017-09-13 07:55 gomer94@yandex.ru
2017-09-16 19:52 ` Re: BUG #14815: event trigger in extension Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 3+ messages in thread
From: gomer94@yandex.ru @ 2017-09-13 07:55 UTC (permalink / raw)
To: pgsql-bugs; +Cc: gomer94@yandex.ru
The following bug has been logged on the website:
Bug reference: 14815
Logged by: Galiev Mansur
Email address: gomer94@yandex.ru
PostgreSQL version: 9.6.5
Operating system: Ubuntu 16.04.3 LTS x64
Description:
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();
but when i'm use CREATE EXTENSION i have:
ERROR: pg_event_trigger_ddl_commands() can only be called in an event
trigger function
CONTEXT: SQL statement "SELECT classid, objid, objsubid FROM
pg_event_trigger_ddl_commands()"
PL/pgSQL function keep_any_ddl_command() line 3 at SQL statement
if create this objects without extension, all ok
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #14815: event trigger in extension
2017-09-13 07:55 BUG #14815: event trigger in extension gomer94@yandex.ru
@ 2017-09-16 19:52 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-10-02 02:21 ` Re: BUG #14815: event trigger in extension Michael Paquier <michael.paquier@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Tom Lane @ 2017-09-16 19:52 UTC (permalink / raw)
To: gomer94@yandex.ru; +Cc: 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
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #14815: event trigger in extension
2017-09-13 07:55 BUG #14815: event trigger in extension gomer94@yandex.ru
2017-09-16 19:52 ` Re: BUG #14815: event trigger in extension Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-10-02 02:21 ` Michael Paquier <michael.paquier@gmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Michael Paquier @ 2017-10-02 02:21 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs
On Sun, Sep 17, 2017 at 4:52 AM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> 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.
That's rather tricky, the failure happens when doing the CREATE EVENT
TRIGGER command within the CREATE EXTENSION command which is done
within ProcessUtilitySlow. I am wondering if a somewhat-elegant way to
solve such problems would be to introduce a function able to
temporarily disable and enable event triggers to happen in the context
of an extension creation, in a design similar to
pg_extension_config_dump.
--
Michael
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2017-10-02 02:21 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-09-13 07:55 BUG #14815: event trigger in extension gomer94@yandex.ru
2017-09-16 19:52 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-10-02 02:21 ` Michael Paquier <michael.paquier@gmail.com>
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