Re: Should TRUNCATE fire DDL triggers - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: Should TRUNCATE fire DDL triggers
Date
Msg-id CAKFQuwYZV1CCbrvvMObiab+nX2fu3K6rF8Rax9pUea13tUitcg@mail.gmail.com
Whole thread Raw
In response to Re: Should TRUNCATE fire DDL triggers  (Hari Krishna Sunder <hari.db.pg@gmail.com>)
List pgsql-hackers
On Wednesday, July 9, 2025, Hari Krishna Sunder <hari.db.pg@gmail.com> wrote:
> I disagree here.  There are regular ON TRUNCATE triggers on tables, so I don't
> see the need.  You can define a trigger with the same trigger function on
> several tables.

You have to create a trigger for each table, and drop them before you drop the table. The DDL trigger will just work more seamlessly.
If we say this is not a DDL, then how about supporting a wildcard as the table_name in the BEFORE/ALTER TRUNCATE trigger? 

We avoid top-posting replies here.

I’d probably go with adding truncate_start and truncate_end (or maybe just start…)  events for event triggers if we don’t want to include them under DDL events.  I’d be strongly disinclined to touch regular triggers to accommodate whatever use case you have that would benefit from this capability.  Stating what that is helps to get agreement, or just spending time helping, making such changes.

David J.

pgsql-hackers by date:

Previous
From: Damien Clochard
Date:
Subject: [PATCH] Generate random dates/times in a specified range
Next
From: Christoph Berg
Date:
Subject: Re: CHECKPOINT unlogged data