Re: Truncate Triggers

From: David Fetter <david(at)fetter(dot)org>
To: Christopher Browne <cbbrowne(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Gregory Stark <stark(at)enterprisedb(dot)com>, Decibel! <decibel(at)decibel(dot)org>, Alvaro Herrera <alvherre(at)commandprompt(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Truncate Triggers
Date: 2008-02-02 22:26:52
Message-ID: 20080202222652.GG4153@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Feb 02, 2008 at 05:23:39PM -0500, Christopher Browne wrote:
> On Feb 2, 2008 2:43 PM, David Fetter <david(at)fetter(dot)org> wrote:
> > It still involves DDL-like operations in the sense of changing
> > (for the duration of the query) trigger behavior.
>
> But that "change of trigger behavior" is still more in the "DML"
> sense than "DDL sense."
>
> The point of TRUNCATE is that we have an optimization that's
> superior (in some important senses) to "DELETE FROM."
>
> The differences between TRUNCATE FOO and DELETE FROM FOO do not have
> to do with the one altering the schema for the table. The schema
> remains the same.

In essence, the schema changes for the duration of the TRUNCATE. Any
data integrity constraints that triggers used are therefore violated,
and it's DDL-like. To put it another way, if you want to duplicate
the trigger-suppression behavior, you have to issue DDL.

> I think it would be nice to be able to have more "trigger hooks"
> relating to DDL changes, but I also think that will represent some
> fundamentally more difficult problems being raised than is the case
> for a TRUNCATE trigger.

Are they really?

Cheers,
David.
--
David Fetter <david(at)fetter(dot)org> http://fetter.org/
Phone: +1 415 235 3778 AIM: dfetter666 Yahoo!: dfetter
Skype: davidfetter XMPP: david(dot)fetter(at)gmail(dot)com

Remember to vote!
Consider donating to Postgres: http://www.postgresql.org/about/donate

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2008-02-02 22:28:50 Re: <IDLE> and waiting
Previous Message Christopher Browne 2008-02-02 22:23:39 Re: Truncate Triggers