Re: TODO-Item: TRUNCATE ... CASCADE

From: Joachim Wieland <joe(at)mcknight(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-patches(at)postgresql(dot)org, alvherre(at)commandprompt(dot)com
Subject: Re: TODO-Item: TRUNCATE ... CASCADE
Date: 2006-02-05 17:24:04
Message-ID: 20060205172404.GA2449@mcknight.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

On Fri, Feb 03, 2006 at 10:27:30AM -0500, Tom Lane wrote:
> Basically: it's the user's fault if he says "TRUNCATE t2" in a situation
> where the referent of t2 might be changing concurrently. But once
> you've identified t2, it's your fault if you don't track the
> dependencies of t2 correctly, even if someone else is busy renaming them.

Ok, the attached patch now does it correctly as suggested by Alvaro.

For code simplicity I changed the locking order of the tables in the
RESTRICT-case as well.
Before they got locked and then checked one by one. To simplify integration
of the CASCADE-case however, I changed it to lock all - check all.

So it is now:

CASCADE:
lock direct - add and lock cascaded tables - check all - truncate all

RESTRICT:
lock direct (= all) - check all - truncate all.

Joachim

Attachment Content-Type Size
pg_truncate_cascade.2.diff text/plain 18.2 KB

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Stephen Frost 2006-02-05 17:53:01 Re: Krb5 & multiple DB connections
Previous Message Andrew Dunstan 2006-02-05 16:15:42 Re: drop if exists remainder