pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Demitri Muna <postgresql@demitri.com>
Cc: pgsql-general@postgresql.org
Subject: Re: ddl_command_end not firing DROP events
Date: Sun, 8 Jul 2018 14:19:29 -0400
Message-ID: <20180708181929.ef6nooxn43ppdoqv@alvherre.pgsql> (raw)
In-Reply-To: <E73C07B3-2E50-43A4-94BE-DEF6277AA5AB@demitri.com>

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%40...

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




view thread (3+ messages)  latest in thread

Message-ID: <20180708181929.ef6nooxn43ppdoqv@alvherre.pgsql>
Permalink:  ../20180708181929.ef6nooxn43ppdoqv@alvherre.pgsql/
Also on:    postgresql.org/message-id/20180708181929.ef6nooxn43ppdoqv@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: alvherre@2ndquadrant.com, postgresql@demitri.com
  Subject: Re: ddl_command_end not firing DROP events
  In-Reply-To: <20180708181929.ef6nooxn43ppdoqv@alvherre.pgsql>
  References: <E73C07B3-2E50-43A4-94BE-DEF6277AA5AB@demitri.com> <20180708181929.ef6nooxn43ppdoqv@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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