Re: feature proposal - triggers by semantics

From: Darren Duncan <darren(at)darrenduncan(dot)net>
To: Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: feature proposal - triggers by semantics
Date: 2012-11-15 19:53:06
Message-ID: 50A54822.9020202@darrenduncan.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Craig Ringer wrote:
> On 11/15/2012 06:25 PM, Hannu Krosing wrote:
>> On 11/15/2012 09:48 AM, Craig Ringer wrote:
>>> If you want to prevent TRUNCATE, deny the privilege or add a trigger
>>> that aborts the command.
>> You can abort the transaction but not skip action as currently it is only
>> possible to skip in ROW level triggers.
>>
>> So I'd modify this request to allow BEFORE EACH STATEMENT triggers
>> to also be able to silently skip current action like BEFORE EACH ROW
>> triggers can.
>>
>> Then this request would simply be satisfied by a simple trigger which
>> rewrites TRUNCATE into DELETE .
> That seems sensible to me, too.

To further explain ...

What I'm desiring here with respect to TRUNCATE is that users are allowed to use
TRUNCATE syntax as an alternative to DELETE (they are GRANTed both) but that any
triggers defined for DELETE can also be applied to TRUNCATE without too much
difficulty. So users can use different syntactic constructs that look similar
without having to think about, is this going to be audited.

I understand that ROW level triggers don't exist yet for TRUNCATE (this is
already clearly documented in the manual) and adding them would mean TRUNCATE
would do a table scan in their presence.

I still think the syntax of TRUNCATE FOR EACH ROW would be useful, but if no one
agrees, then I'll just make do with alternative solutions mentioned here. That
is, either a statement-level TRUNCATE trigger of some kind, or simply disallow
TRUNCATE privileges.

Thank you.

-- Darren Duncan

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2012-11-15 19:54:25 Re: tuplesort memory usage: grow_memtuples
Previous Message Jeff Davis 2012-11-15 19:44:45 Re: Enabling Checksums