From 5ef5abe3729dde236e4a8b36c33b0e264de79e8e Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Wed, 16 Jul 2008 19:33:25 +0000 Subject: [PATCH] Fix previous patch so that it actually works --- consider TRUNCATE foo, public.foo --- src/backend/commands/tablecmds.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 18a86b8f01..58454dcba9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.260 2008/07/16 16:54:08 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.261 2008/07/16 19:33:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -762,9 +762,6 @@ ExecuteTruncate(TruncateStmt *stmt) ResultRelInfo *resultRelInfo; ListCell *cell; - /* make list unique */ - stmt->relations = list_union(NIL, stmt->relations); - /* * Open, exclusive-lock, and check all the explicitly-specified relations */ @@ -774,6 +771,12 @@ ExecuteTruncate(TruncateStmt *stmt) Relation rel; rel = heap_openrv(rv, AccessExclusiveLock); + /* don't throw error for "TRUNCATE foo, foo" */ + if (list_member_oid(relids, RelationGetRelid(rel))) + { + heap_close(rel, AccessExclusiveLock); + continue; + } truncate_check_rel(rel); rels = lappend(rels, rel); relids = lappend_oid(relids, RelationGetRelid(rel)); -- 2.40.0