Re: ddl_command_end not firing DROP events

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Demitri Muna <postgresql(at)demitri(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ddl_command_end not firing DROP events
Date: 2018-07-08 18:19:29
Message-ID: 20180708181929.ef6nooxn43ppdoqv@alvherre.pgsql
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2018-Jul-08, Demitri Muna wrote:

Hi

> I’ve created a trigger where I want to capture schema-changing events.
> I’m finding that DROP events are not being triggered when using
> “ddl_command_end". The test case below demonstrates this. I am running
> PostgreSQL 10.4. The trigger is fired for the CREATE event, but not
> DROP TYPE or DROP TABLE.
>
> I came across the same question on the mailing list, but the solution
> was to use the “sql_drop” trigger instead.
>
> https://www.postgresql.org/message-id/CAHE3wgjX-N%3DX9mccp4Bs-y-%3DHE%3DqayHEpXpCs1jMT%3DW0ZsYc5A%40mail.gmail.com

As I recall, handling of DROP events in the ddl_command_end event is not
completely consistent. You may even find that some DROP events are not
returned by pg_event_trigger_ddl_commands. I suggest you stick to
pg_event_trigger_dropped_objects() instead (for which you need
sql_drop).

--
Álvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul A Jungwirth 2018-07-08 23:56:37 Re: User-defined function with anyrange[]
Previous Message Demitri Muna 2018-07-08 17:46:25 ddl_command_end not firing DROP events