Re: Truncate Triggers

From: David Fetter <david(at)fetter(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: 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 19:43:32
Message-ID: 20080202194332.GC4153@fetter.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Feb 02, 2008 at 02:23:40PM -0500, Tom Lane wrote:
> David Fetter <david(at)fetter(dot)org> writes:
> > On Thu, Jan 31, 2008 at 10:22:42AM +0000, Gregory Stark wrote:
> >> There are plenty of DDL commands which modify data (CREATE INDEX,
> >> ATLER TABLE ALTER COLUMN TYPE). The defining characteristic of DDL
> >> is not that it doesn't modify the data but that it does modify the
> >> table definition.
>
> > Counter-example: ALTER TABLE ALTER COLUMN USING will almost certainly
> > modify data, but it's DDL nonetheless.
>
> Uh, how is that a counter-example to what Greg said?

Oops. I misread. D'oh.

> I think the real question here is whether there is a defensible
> use-case for a trigger. In the case of TRUNCATE it's pretty obvious
> what you might want the trigger for: to do the same thing your
> per-row ON DELETE trigger does, but across all rows. It's much less
> easy to envision a scriptable-in-advance response to arbitrary ALTER
> TABLE operations.
>
> Looked at in this light, TRUNCATE is clearly more nearly DML than
> DDL, in the sense that its effects are predictable and involve only
> the data not the schema (at least in the user's view).

It still involves DDL-like operations in the sense of changing (for
the duration of the query) trigger behavior.

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 Andrew Dunstan 2008-02-02 20:01:41 Re: configurability of OOM killer
Previous Message Florian Weimer 2008-02-02 19:39:15 Re: configurability of OOM killer