Re: Delete rule does not prevent truncate - Mailing list pgsql-general

From Geoff Winkless
Subject Re: Delete rule does not prevent truncate
Date
Msg-id CAEzk6fdsWd4Vq7d_AH6e7UiK8pbrdhva4Uq4hwUSwodAxwgGZA@mail.gmail.com
Whole thread Raw
In response to Re: Delete rule does not prevent truncate  ("Joshua D. Drake" <jd@commandprompt.com>)
Responses Re: Delete rule does not prevent truncate  (Tim Smith <randomdev4+postgres@gmail.com>)
List pgsql-general
On 22 July 2015 at 16:55, Joshua D. Drake <jd@commandprompt.com> wrote:

On 07/22/2015 08:42 AM, Geoff Winkless wrote:
On 22 July 2015 at 16:32, Joshua D. Drake <jd@commandprompt.com
<mailto:jd@commandprompt.com>>wrote:

    This is actually wrong. The end result is the same but it does not
    in any way have the same effect.


"in any way"? ​I'd say in the primary way it has the same effect: all rows are removed
from the table.

Thus the end result is the same as I said but the in practice effect is quite different from a visibility, maintenance and programmability perspective.

But to say "it does not in any way have the same effect" explicitly excludes that any effect of the two things might be the same. In actual fact, in the simple case (no triggers) the effect is the same. 

FWIW, the difference between "in practice effect" and "end result" is pretty esoteric, frankly - I'm not really sure what you're driving at there. The "end result" would surely include the behaviour of any triggers that might be fired.

    TRUNCATE is NOT DELETE.


​I don't think anyone is suggesting that it is.​

Except Tim Smith who started this thread.


​I don't believe he suggested that at all: he made an assumption that his DELETE triggers would fire on TRUNCATE, and when it was pointed out that he was mistaken he posted half a sentence from the documentation that supported his view, ignoring the second half of that sentence that makes it clear that the behaviour of the two commands is different, and ignoring the explicit statement on the very same page of the documentation viz:

"
TRUNCATE will not fire any ON DELETE triggers that might exist for the tables
​"​.

​Geoff​

pgsql-general by date:

Previous
From: "Joshua D. Drake"
Date:
Subject: Re: Delete rule does not prevent truncate
Next
From: Миша Тюрин
Date:
Subject: Re: [GENERAL] Way to get timeline