Re: feature proposal - triggers by semantics - Mailing list pgsql-hackers

From Darren Duncan
Subject Re: feature proposal - triggers by semantics
Date
Msg-id 50A54822.9020202@darrenduncan.net
Whole thread Raw
In response to Re: feature proposal - triggers by semantics  (Craig Ringer <craig@2ndQuadrant.com>)
Responses Re: feature proposal - triggers by semantics  (Christopher Browne <cbbrowne@gmail.com>)
List 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



pgsql-hackers by date:

Previous
From: Jeff Davis
Date:
Subject: Re: Enabling Checksums
Next
From: Greg Stark
Date:
Subject: Re: tuplesort memory usage: grow_memtuples