Re: ddl_command_end not firing DROP events - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: ddl_command_end not firing DROP events
Date
Msg-id 20180708181929.ef6nooxn43ppdoqv@alvherre.pgsql
Whole thread Raw
In response to ddl_command_end not firing DROP events  (Demitri Muna <postgresql@demitri.com>)
Responses Re: ddl_command_end not firing DROP events  (Demitri Muna <postgresql@demitri.com>)
List 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


pgsql-general by date:

Previous
From: Demitri Muna
Date:
Subject: ddl_command_end not firing DROP events
Next
From: Paul A Jungwirth
Date:
Subject: Re: User-defined function with anyrange[]