Re: Delete rule does not prevent truncate

From: Andrew Sullivan <ajs(at)crankycanuck(dot)ca>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Delete rule does not prevent truncate
Date: 2015-07-23 11:05:51
Message-ID: 20150723110548.GE9120@crankycanuck.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Jul 23, 2015 at 08:06:19AM +0100, Tim Smith wrote:
> What exactly is was the design decision that lead to TRUNCATE being
> supported by triggers but not by rules ?

There are two things. First, probably the design decision was, "I
care about triggers." TRUNCATE was added (I believe) in version 7.0,
and even then there was some caution indicated about the use of rules.
See for instance
http://www.postgresql.org/docs/7.0/static/rules19784.htm. So you
might be partly right.

But second, it isn't clear what it would mean for TRUNCATE to be
supported by rules. Rules do query parse tree rewriting. That is,
they rewrite the query on the way through the system before they can
possibly have any effect, changing one SQL statement into
(effectively) a different one by the time it executes. There is only
one possible effect from TRUNCATE, and that is to eliminate all the
data in the table. I don't know what rewriting such a query would
mean.

Best regards,

A

--
Andrew Sullivan
ajs(at)crankycanuck(dot)ca

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jens Depuydt 2015-07-23 11:09:43 plv8 package in PostgreSQL 9.4 Yum repositories
Previous Message amihay gonen 2015-07-23 09:55:21 Q: text query search and