Fix previous patch so that it actually works --- consider TRUNCATE foo, public.foo
authorTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Jul 2008 19:33:25 +0000 (19:33 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Wed, 16 Jul 2008 19:33:25 +0000 (19:33 +0000)
src/backend/commands/tablecmds.c

index dcd7eaa50522bed46b81d4af377db4da84bd7d47..88bed4ab9630a00aa28f4f366d6de01bb71bbb10 100644 (file)
@@ -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));