* Portions Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.136 2004/05/26 04:41:33 neilc Exp $
+ *   $PostgreSQL: pgsql/src/backend/rewrite/rewriteHandler.c,v 1.137 2004/05/29 05:55:13 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
         */
        if (locks != NIL)
        {
-           List       *newActiveRIRs;
            ListCell   *l;
 
            if (oidMember(RelationGetRelid(rel), activeRIRs))
                        (errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
                         errmsg("infinite recursion detected in rules for relation \"%s\"",
                                RelationGetRelationName(rel))));
-           newActiveRIRs = lconso(RelationGetRelid(rel), activeRIRs);
+           activeRIRs = lconso(RelationGetRelid(rel), activeRIRs);
 
            foreach(l, locks)
            {
                                              rule->attrno == -1,
                                              rel,
                                              relIsUsed,
-                                             newActiveRIRs);
+                                             activeRIRs);
            }
+
+           activeRIRs = list_delete_first(activeRIRs);
        }
 
        heap_close(rel, NoLock);