Fix temp relation handling for indexes, cleanup
authorBruce Momjian
Wed, 11 Oct 2000 21:28:19 +0000 (21:28 +0000)
committerBruce Momjian
Wed, 11 Oct 2000 21:28:19 +0000 (21:28 +0000)
src/backend/access/transam/xact.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/utils/cache/temprel.c
src/include/utils/temprel.h

index 9a52b2ff09cda048e89b2602f0b1b2055e4661dc..1e50b9e3e7f9b37d815256e6b88104a31920da87 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.71 2000/09/27 10:41:55 petere Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.72 2000/10/11 21:28:17 momjian Exp $
  *
  * NOTES
  *     Transaction aborts can now occur two ways:
@@ -1119,7 +1119,7 @@ AbortTransaction()
    AtEOXact_portals();
    RecordTransactionAbort();
    RelationPurgeLocalRelation(false);
-   invalidate_temp_relations();
+   remove_temp_rel_in_myxid();
    AtEOXact_SPI();
    AtEOXact_nbtree();
    AtAbort_Cache();
index a9feacd2add7a2ccfc145cb1821b044a25d8fc9d..5353108b98ead7ef9a203f9d054cd001b03a41aa 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.147 2000/10/05 19:48:21 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.148 2000/10/11 21:28:18 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -131,11 +131,11 @@ static FormData_pg_attribute a6 = {
    MaxCommandIdAttributeNumber, 0, -1, -1, '\001', 'p', '\0', 'i', '\0', '\0'
 };
 
-/* 
+/*
    We decide to call this attribute "tableoid" rather than say
 "classoid" on the basis that in the future there may be more than one
 table of a particular class/type. In any case table is still the word
-used in SQL. 
+used in SQL.
 */
 static FormData_pg_attribute a7 = {
    0xffffffff, {"tableoid"}, OIDOID, 0, sizeof(Oid),
@@ -1489,7 +1489,7 @@ heap_drop_with_catalog(const char *relname,
    RelationForgetRelation(rid);
 
    if (istemp)
-       remove_temp_relation(rid);
+       remove_temp_rel_by_relid(rid);
 
    if (has_toasttable)
    {
index 307f4834b167046e7f6983a1dddf742ba558f4d4..33aa67fe45153d5f74e58ce0932af3b49368b0c0 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.127 2000/10/05 19:48:21 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.128 2000/10/11 21:28:18 momjian Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -1145,7 +1145,7 @@ index_drop(Oid indexId)
    RelationForgetRelation(indexId);
 
    /* does something only if it is a temp index */
-   remove_temp_relation(indexId);
+   remove_temp_rel_by_relid(indexId);
 }
 
 /* ----------------------------------------------------------------
@@ -1374,7 +1374,7 @@ IndexesAreActive(Oid relid, bool confirmCommitted)
    if (!LockClassinfoForUpdate(relid, &tuple, &buffer, confirmCommitted))
        elog(ERROR, "IndexesAreActive couldn't lock %u", relid);
    if (((Form_pg_class) GETSTRUCT(&tuple))->relkind != RELKIND_RELATION &&
-       ((Form_pg_class) GETSTRUCT(&tuple))->relkind != RELKIND_TOASTVALUE)
+       ((Form_pg_class) GETSTRUCT(&tuple))->relkind != RELKIND_TOASTVALUE)
        elog(ERROR, "relation %u isn't an indexable relation", relid);
    isactive = ((Form_pg_class) GETSTRUCT(&tuple))->relhasindex;
    ReleaseBuffer(buffer);
index 6ba2d1765122d49e30308d7363f6e0c6edda5a28..af584591e576711a149e4a023e88ccdacb8b3023 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *   $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.27 2000/07/12 18:04:45 momjian Exp $
+ *   $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/temprel.c,v 1.28 2000/10/11 21:28:19 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -91,35 +91,24 @@ create_temp_relation(const char *relname, HeapTuple pg_class_tuple)
 void
 remove_all_temp_relations(void)
 {
-   List       *l,
-              *next;
-
-   if (temp_rels == NIL)
-       return;
-
    AbortOutOfAnyTransaction();
    StartTransactionCommand();
 
-   l = temp_rels;
-   while (l != NIL)
+   while (temp_rels != NIL)
    {
-       TempTable  *temp_rel = (TempTable *) lfirst(l);
-
-       next = lnext(l);        /* do this first, l is deallocated */
+       char        relname[NAMEDATALEN];
+       TempTable  *temp_rel = (TempTable *) lfirst(temp_rels);
 
-       /* Indexes are dropped during heap drop */
        if (temp_rel->relkind != RELKIND_INDEX)
        {
-           char        relname[NAMEDATALEN];
-
            /* safe from deallocation */
            strcpy(relname, temp_rel->user_relname);
            heap_drop_with_catalog(relname, allowSystemTableMods);
        }
-
-       l = next;
+       else
+           index_drop(temp_rel->relid);
+       CommandCounterIncrement();
    }
-   temp_rels = NIL;
    CommitTransactionCommand();
 }
 
@@ -129,7 +118,7 @@ remove_all_temp_relations(void)
  * we don't have the relname for indexes, so we just pass the oid
  */
 void
-remove_temp_relation(Oid relid)
+remove_temp_rel_by_relid(Oid relid)
 {
    MemoryContext oldcxt;
    List       *l,
@@ -179,7 +168,7 @@ remove_temp_relation(Oid relid)
  * We just have to delete the map entry.
  */
 void
-invalidate_temp_relations(void)
+remove_temp_rel_in_myxid(void)
 {
    MemoryContext oldcxt;
    List       *l,
index 337188b61245001c7072ced86a2d21d047f9c9a9..a99839ac266e8e92aaa7cad8c743f56e4f0b79b5 100644 (file)
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2000, PostgreSQL, Inc
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Id: temprel.h,v 1.10 2000/06/20 06:41:11 tgl Exp $
+ * $Id: temprel.h,v 1.11 2000/10/11 21:28:19 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 extern void create_temp_relation(const char *relname,
                                 HeapTuple pg_class_tuple);
-extern void remove_temp_relation(Oid relid);
+extern void remove_temp_rel_by_relid(Oid relid);
 extern bool rename_temp_relation(const char *oldname,
                                 const char *newname);
 
 extern void remove_all_temp_relations(void);
-extern void invalidate_temp_relations(void);
+extern void remove_temp_rel_in_myxid(void);
 
 extern char *get_temp_rel_by_username(const char *user_relname);
 extern char *get_temp_rel_by_physicalname(const char *relname);