Skip site navigation (1) Skip section navigation (2)

Re: trigger for TRUNCATE?

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: "Chris Browne" <cbbrowne(at)acm(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: trigger for TRUNCATE?
Date: 2008-01-08 21:38:37
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql

theoretically you can have trigger on any statement, but I am not sure
about conformance with std. But, you can wrap TRUNCATE statement into
some procedure, and then call this procedure with some other actions.

Pavel Stehule

On 08/01/2008, Chris Browne <cbbrowne(at)acm(dot)org> wrote:
> gherzig(at)fmed(dot)uba(dot)ar (Gerardo Herzig) writes:
> > Hi all. Acording to the docs, TRUNCATE will not fire a DELETE trigger
> > on the table being truncated.
> > There is a way to capture a TRUNCATE in any way?
> I think there's some sort of "to do" on that...
> It ought to be not *too* difficult (I imagine!) to be able to
> associate a trigger with the TRUNCATE action, and therefore run some
> stored function any time TRUNCATE takes place.
> For the Slony-I replication system, it would be attractive for this to
> lead to attaching two functions:
>   - One function would return an exception so that TRUNCATE against
>     a subscriber node would fail...
>   - Another would pretty much be as simple as submitting an event;
>     perform createEvent('_ourcluster', 'TRUNCATE_TABLE', table_id);
> A new event, TRUNCATE_TABLE, would do a TRUNCATE against the
> subscribers.
> This represents a pretty easy enhancement, given the new kind of
> trigger.
> --
> (reverse (concatenate 'string "moc.enworbbc" "@" "enworbbc"))
> Frisbeetarianism: The belief that when  you die, your  soul goes up on
> the roof and gets stuck...
> ---------------------------(end of broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?

In response to


pgsql-sql by date

Next:From: Steve MidgleyDate: 2008-01-09 18:20:21
Subject: Re: How to keep at-most N rows per group? periodic DELETEs or constraints or..?
Previous:From: Chris BrowneDate: 2008-01-08 20:57:21
Subject: Re: trigger for TRUNCATE?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group