]> granicus.if.org Git - postgresql/commitdiff
Improve comments.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Oct 2000 23:06:24 +0000 (23:06 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Oct 2000 23:06:24 +0000 (23:06 +0000)
src/backend/utils/cache/temprel.c

index af584591e576711a149e4a023e88ccdacb8b3023..460cf56a408f6d66f5aa88dffe60cff03759f0af 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.28 2000/10/11 21:28:19 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.29 2000/10/19 23:06:24 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -91,24 +91,37 @@ create_temp_relation(const char *relname, HeapTuple pg_class_tuple)
 void
 remove_all_temp_relations(void)
 {
+       /* skip xact start overhead if nothing to do */
+       if (temp_rels == NIL)
+               return;
+
        AbortOutOfAnyTransaction();
        StartTransactionCommand();
 
+       /*
+        * The way this works is that each time through the loop, we delete
+        * the frontmost entry.  The DROP will call remove_temp_rel_by_relid()
+        * as a side effect, thereby removing the entry in the temp_rels list.
+        * So this is not an infinite loop, even though it looks like one.
+        */
        while (temp_rels != NIL)
        {
-               char            relname[NAMEDATALEN];
                TempTable  *temp_rel = (TempTable *) lfirst(temp_rels);
 
                if (temp_rel->relkind != RELKIND_INDEX)
                {
+                       char            relname[NAMEDATALEN];
+
                        /* safe from deallocation */
                        strcpy(relname, temp_rel->user_relname);
                        heap_drop_with_catalog(relname, allowSystemTableMods);
                }
                else
                        index_drop(temp_rel->relid);
+               /* advance cmd counter to make catalog changes visible */
                CommandCounterIncrement();
        }
+
        CommitTransactionCommand();
 }