Re: TODO-Item: TRUNCATE ... CASCADE - Mailing list pgsql-patches

From Alvaro Herrera
Subject Re: TODO-Item: TRUNCATE ... CASCADE
Date
Msg-id 20060202153427.GA5173@surnet.cl
Whole thread Raw
In response to TODO-Item: TRUNCATE ... CASCADE  (Joachim Wieland <joe@mcknight.de>)
Responses Re: TODO-Item: TRUNCATE ... CASCADE  (Joachim Wieland <joe@mcknight.de>)
List pgsql-patches
Joachim Wieland wrote:
> The proposed patch implements TRUNCATE ... CASCADE:
>
> * %Allow TRUNCATE ... CASCADE/RESTRICT
>   This is like DELETE CASCADE, but truncates.
>
> The patch also adds a function makeRangeVarFromRelId() to namespace.c that I
> thought would be useful. I hope I didn't overlook something similar that
> exists already.

That's the wrong way to go about it -- better refactor the code so that
a function gets a list of Oids instead of RangeVars, and truncates them.
ExecuteTruncate should build the list and pass it down.

Also I think all the involved relations should be opened and locked
before any of them is touched (so maybe instead of passing Oids you
should be passing Relations).


> + static
> + List* BuildReferencingRelationList(List* oids, List* found_earlier)

Minor stylistic gripe: this should be

static List *
BuildReferencingRelationList(List *oids, List *found_earlier)

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-patches by date:

Previous
From: Joachim Wieland
Date:
Subject: TODO-Item: TRUNCATE ... CASCADE
Next
From: Andrew Dunstan
Date:
Subject: Re: [BUGS] BUG #2171: Differences compiling plpgsql in