Re: Delete rule does not prevent truncate

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Tim Smith <randomdev4(at)gmail(dot)com>
Cc: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Delete rule does not prevent truncate
Date: 2015-07-24 13:36:55
Message-ID: 55B23F77.5010204@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 07/24/2015 02:24 AM, Tim Smith wrote:
>>
>> Just in case it has not been made obvious yet, rules are silently
>> deprecated. They still exist because views depend on them, but it is
>> generally considered best practices to not use them outside that realm.
>
>
> Well, the manual doesn't seem to reflect that fact.
>
> If that's how the developers feel about rules, i.e they can't be
> bothered to make any changes to the rules code any more, no matter how
> minor (e.g. this TRUNCATE issue), then you should explicitly state in
> the manual that they are depreciated, and stop making stupid
> statements like "so if many rows are affected in one statement, a rule
> issuing one extra command is likely to be faster than a trigger" that
> encourage people to use rules !
>

Seems that section needs editing to make it clearer that this depends on
what type of trigger you use. Or as it states here:

http://www.postgresql.org/docs/9.4/interactive/sql-createtrigger.html
"
A trigger that is marked FOR EACH ROW is called once for every row that
the operation modifies. For example, a DELETE that affects 10 rows will
cause any ON DELETE triggers on the target relation to be called 10
separate times, once for each deleted row. In contrast, a trigger that
is marked FOR EACH STATEMENT only executes once for any given operation,
regardless of how many rows it modifies (in particular, an operation
that modifies zero rows will still result in the execution of any
applicable FOR EACH STATEMENT triggers).
"

At any rate you know what the situation is. Getting increasingly
belligerent is not going to help that situation and the energy would
seem to me better spent on adapting to reality and moving on.

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message JPLapham 2015-07-24 13:51:32 Re: Using the database to validate data
Previous Message Zdeněk Bělehrádek 2015-07-24 12:17:48 Re: Using the database to validate data