Re: BUG #16177: pg_event_trigger_ddl_commands() returns empty set for ddl_command_start and "drop table"

Alvaro Herrera <[email protected]> Mon, 23 Dec 2019 11:36:38 -0300
Newsgroups gmane.comp.db.postgresql.bugs
Message-ID <[email protected]>
On 2019-Dec-22, PG Bug reporting form wrote:

> 1. use case is to delete rows with oid references  to the table before "drop
> table"

I think you could achieve that with an event trigger on event sql_drop.
IIRC that event trigger is run for the objects before the drops are
actually executed.

ddl_command_start is pretty useless, because it doesn't have much info
abot the command being run; I'm sure that
pg_event_trigger_ddl_commands() would always return empty there.
The function would return non-empty only during ddl_command_end, but
that's no useful to you because the drops will already have run.

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