Re: feature proposal - triggers by semantics

From: Christopher Browne <cbbrowne(at)gmail(dot)com>
To: Darren Duncan <darren(at)darrenduncan(dot)net>
Cc: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: feature proposal - triggers by semantics
Date: 2012-11-15 20:02:19
Message-ID: CAFNqd5XoQUV98_rkBWJj5KigzDai8NZg1Bnv=tdChnUiXhaR1w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 15, 2012 at 2:53 PM, Darren Duncan <darren(at)darrenduncan(dot)net>
wrote:
> I still think the syntax of TRUNCATE FOR EACH ROW would be useful, but if
no one agrees...

I'm compelled to disagree.

What was useful about TRUNCATE in the first place was that it quickly
operated against the entire table.

If you want to change that to row-by-row processing, then it is actually a
little bit worse than
DELETE FROM some_table, in that it is introducing an irregularity in
language that no longer
provides any corresponding benefit. (e.g. - such as that TRUNCATE is fast).

If you want to be certain of doing row-by-row processing, then the better
answer is to:
a) Use DELETE instead in your application, and
b) Put a guard on to prevent using TRUNCATE. (e.g. - attach triggers that
react to TRUNCATE with "go away, don't bother me!")

I observe that the Slony replication system initially implemented that
'guard' approach when TRUNCATE
triggers were first provided, until we came up with a suitable strategy to
capture and replicate the
TRUNCATE request.
--
When confronted by a difficult problem, solve it by reducing it to the
question, "How would the Lone Ranger handle this?"

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Dimitri Fontaine 2012-11-15 20:09:34 Re: Dumping an Extension's Script
Previous Message Greg Stark 2012-11-15 19:54:25 Re: tuplesort memory usage: grow_memtuples