BUG #15359: event_trigger via pg_event_trigger_ddl_commands() not returning "CREATE SEQUENCE" command

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: tarek_heiland(at)debortoli(dot)com(dot)au
Subject: BUG #15359: event_trigger via pg_event_trigger_ddl_commands() not returning "CREATE SEQUENCE" command
Date: 2018-08-30 04:11:04
Message-ID: 153560226458.1484.15293934964985286328@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 15359
Logged by: Tarek Heiland
Email address: tarek_heiland(at)debortoli(dot)com(dot)au
PostgreSQL version: 9.6.9
Operating system: windows/linux
Description:

1) Event Trigger Function (redacted to raise notice only for proscribed
events)

CREATE OR REPLACE FUNCTION admin.trg_create_set_owner()
RETURNS event_trigger AS
$BODY$
DECLARE
obj record;
BEGIN
FOR obj IN SELECT * FROM pg_event_trigger_ddl_commands()
WHERE command_tag in ('CREATE TABLE','CREATE TABLE AS','CREATE SEQUENCE')
LOOP
RAISE NOTICE 'event % for object %',obj.command_tag,
obj.object_identity;

END LOOP;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION admin.trg_create_set_owner()
OWNER TO postgres;
GRANT EXECUTE ON FUNCTION admin.trg_create_set_owner() TO public;

2) Test with CREATE TABLE

CREATE TABLE test (id integer);

NOTICE: event CREATE TABLE for object historian.test
CONTEXT: PL/pgSQL function admin.trg_create_set_owner() line 7 at RAISE

Query returned successfully with no result in 11 msec

3) Test with CREATE SEQUENCE

CREATE SEQUENCE test_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;

Query returned successfully with no result in 11 msec.

No event raised.

4) https://www.postgresql.org/docs/9.6/static/event-trigger-matrix.html
indicates the CREATE SEQUENCE is supported in this context and
https://www.postgresql.org/docs/9.6/static/event-trigger-definition.html
indicates pg_event_trigger_ddl_commands() is the correct function to call.

Regards

Tarek

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2018-08-30 04:35:20 Re: BUG #15358: PostgreSQL fails to build on 10.14 when Perl is enabled.
Previous Message Tom Lane 2018-08-30 03:49:28 Re: BUG #15358: PostgreSQL fails to build on 10.14 when Perl is enabled.