]> granicus.if.org Git - postgresql/commitdiff
Fixes: Errors when PQexec() in backend creates temp
authorMarc G. Fournier <scrappy@hub.org>
Thu, 24 Oct 1996 07:38:22 +0000 (07:38 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Thu, 24 Oct 1996 07:38:22 +0000 (07:38 +0000)
              relations and transaction is aborted

Submitted by: wieck@sapserv.debis.de (Jan Wieck)

src/backend/catalog/heap.c
src/backend/postmaster/postmaster.c
src/backend/utils/cache/relcache.c
src/backend/utils/rel.h

index 6e9634aa95a0450b21a6e27de1d2efbccf298693..1fbe99331bfe8407793a0058cb8112cf3ed79c74 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.1.1.1 1996/07/09 06:21:15 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.1.1.1.2.1 1996/10/24 07:37:31 scrappy Exp $
  *
  * INTERFACE ROUTINES
  *     heap_creatr()           - Create an uncataloged heap relation
@@ -315,6 +315,13 @@ heap_creatr(char *name,
        rdesc->rd_rel->reltype = relid;
      }
 
+    /* ----------------
+     *  remember if this is a temp relation
+     * ----------------
+     */
+
+    rdesc->rd_istemp = isTemp;
+
     /* ----------------
      * have the storage manager create the relation.
      * ----------------
@@ -1306,6 +1313,9 @@ heap_destroy(char *relname)
      * ----------------
      */
     (void) smgrunlink(rdesc->rd_rel->relsmgr, rdesc);
+    if(rdesc->rd_istemp) {
+        rdesc->rd_tmpunlinked = TRUE;
+    }
     heap_close(rdesc);
 }
 
@@ -1320,6 +1330,9 @@ heap_destroyr(Relation rdesc)
 {
     ReleaseTmpRelBuffers(rdesc);
     (void) smgrunlink(rdesc->rd_rel->relsmgr, rdesc);
+    if(rdesc->rd_istemp) {
+        rdesc->rd_tmpunlinked = TRUE;
+    }
     heap_close(rdesc);
     RemoveFromTempRelList(rdesc);
 }
@@ -1357,7 +1370,7 @@ InitTempRelList()
     tempRels = (TempRelList*)malloc(sizeof(TempRelList));
     tempRels->size = TEMP_REL_LIST_SIZE;
     tempRels->rels = (Relation*)malloc(sizeof(Relation) * tempRels->size);
-    memset(tempRels->rels, sizeof(Relation) * tempRels->size , 0);
+    memset(tempRels->rels, 0, sizeof(Relation) * tempRels->size);
     tempRels->num = 0;
 }
 
@@ -1418,7 +1431,7 @@ DestroyTempRels()
     for (i=0;i<tempRels->num;i++) {
        rdesc = tempRels->rels[i];
        /* rdesc may be NULL if it has been removed from the list already */
-       if (rdesc) 
+       if (rdesc)
            heap_destroyr(rdesc);
     }
     free(tempRels->rels);
index ef33d2fd13cc3e81c3ccb3530d3f9d2ff00f44be..29d7f2e5913aa7fc552ed9aa9947dc94a9cf410c 100644 (file)
@@ -10,7 +10,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.3.2.4 1996/10/07 07:19:38 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.3.2.5 1996/10/24 07:37:49 scrappy Exp $
  *
  * NOTES
  *
@@ -807,7 +807,7 @@ BackendStartup(StartupInfo *packet, /* client's startup packet */
     static char        envEntry[4][2 * ARGV_SIZE];
     
     for (i = 0; i < 4; ++i) {
-       memset(envEntry[i], 2*ARGV_SIZE,0);
+       memset(envEntry[i], 0, 2*ARGV_SIZE);
     }
     /*
      * Set up the necessary environment variables for the backend
index 4e3f28491b7259a41aea0ad30e85745cb02cba4d..dfb13876de0dd506f904cc6d220487181480e415 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *    $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.1.1.1 1996/07/09 06:22:06 scrappy Exp $
+ *    $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.1.1.1.2.1 1996/10/24 07:38:22 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1412,7 +1412,14 @@ RelationPurgeLocalRelation(bool xactCommitted)
             * remove the file if we abort. This is so that files for 
             * tables created inside a transaction block get removed.
             */
-           smgrunlink(reln->rd_rel->relsmgr, reln);
+           if(reln->rd_istemp) {
+               if(!(reln->rd_tmpunlinked)) {
+                   smgrunlink(reln->rd_rel->relsmgr, reln);
+                   reln->rd_tmpunlinked = TRUE;
+               } 
+           } else {
+               smgrunlink(reln->rd_rel->relsmgr, reln);
+           }
        }
        
        reln->rd_islocal = FALSE;
index d1d5a78dba77052b55d43f9c1f39225a368327af..7323bf16ef91e0b325c10c848d89be572b311665 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: rel.h,v 1.1.1.1 1996/07/09 06:22:02 scrappy Exp $
+ * $Id: rel.h,v 1.1.1.1.2.1 1996/10/24 07:38:08 scrappy Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -31,6 +31,8 @@ typedef struct RelationData {
     uint16             rd_refcnt;      /* reference count */
     bool               rd_islocal;     /* uses the local buffer mgr */
     bool               rd_isnailed;    /* rel is nailed in cache */
+    bool               rd_istemp;      /* rel is a temp rel */
+    bool               rd_tmpunlinked; /* temp rel already unlinked */
     Form_pg_am                 rd_am;          /* AM tuple */
     Form_pg_class      rd_rel;         /* RELATION tuple */
     Oid                        rd_id;          /* relations's object id */