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.