Re: Delete rule does not prevent truncate

Поиск
Список
Период
Сортировка
От Scott Marlowe
Тема Re: Delete rule does not prevent truncate
Дата
Msg-id CAOR=d=1VXkVihWe68P7qUy7ycxZjxk_pwiAru2NNwmD=zZ+pAQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Delete rule does not prevent truncate  (Adrian Klaver <adrian.klaver@aklaver.com>)
Ответы Re: Delete rule does not prevent truncate  (Tim Smith <randomdev4@gmail.com>)
Список pgsql-general
On Thu, Jul 23, 2015 at 12:09 PM, Adrian Klaver
<adrian.klaver@aklaver.com> wrote:
> On 07/23/2015 04:57 AM, Tim Smith wrote:
>>
>> Andrew,
>>
>>  From the manual:
>>
>> It is important to realize that a rule is really a command
>> transformation mechanism, or command macro. The transformation happens
>> before the execution of the command starts. If you actually want an
>> operation that fires independently for each physical row, you probably
>> want to use a trigger, not a rule
>>
>>
>> Thus, I should not have to use a trigger for TRUNCATE because the "each
>> row" concept does not apply.     Plus it makes perfect sense to want to
>> transform the truncate command and transform into ignore
>>
>
> 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. So
> if you want the rule behavior to change for TRUNCATE(if that is even
> possible) you are fighting an uphill battle. You may pursue that fight of
> course, but I would think you will get a quicker return on your time if you
> just forget about using a RULE and stick to a TRIGGER instead.
>


Also OP needs to know that COPY commands are ignored by rules as well.
I agree, stick to triggers, they're faster and less error prone.


В списке pgsql-general по дате отправления:

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: Delete rule does not prevent truncate
Следующее
От: Rob Sargent
Дата:
Сообщение: Re: Delete rule does not prevent truncate