]> granicus.if.org Git - postgresql/commitdiff
Some changes to prepare for LONG attributes.
authorJan Wieck <JanWieck@Yahoo.com>
Thu, 16 Dec 1999 22:20:03 +0000 (22:20 +0000)
committerJan Wieck <JanWieck@Yahoo.com>
Thu, 16 Dec 1999 22:20:03 +0000 (22:20 +0000)
Jan

43 files changed:
src/backend/access/common/heaptuple.c
src/backend/access/heap/heapam.c
src/backend/bootstrap/bootstrap.c
src/backend/catalog/heap.c
src/backend/catalog/index.c
src/backend/catalog/indexing.c
src/backend/catalog/pg_operator.c
src/backend/catalog/pg_type.c
src/backend/commands/async.c
src/backend/commands/cluster.c
src/backend/commands/command.c
src/backend/commands/comment.c
src/backend/commands/copy.c
src/backend/commands/creatinh.c
src/backend/commands/indexcmds.c
src/backend/commands/proclang.c
src/backend/commands/remove.c
src/backend/commands/rename.c
src/backend/commands/trigger.c
src/backend/commands/vacuum.c
src/backend/executor/_deadcode/nodeTee.c
src/backend/executor/execMain.c
src/backend/executor/execTuples.c
src/backend/executor/nodeGroup.c
src/backend/executor/nodeHash.c
src/backend/executor/nodeHashjoin.c
src/backend/executor/nodeSubplan.c
src/backend/executor/nodeTidscan.c
src/backend/executor/spi.c
src/backend/nodes/freefuncs.c
src/backend/parser/parse_func.c
src/backend/rewrite/rewriteRemove.c
src/backend/rewrite/rewriteSupport.c
src/backend/storage/large_object/inv_api.c
src/backend/utils/adt/regproc.c
src/backend/utils/cache/catcache.c
src/backend/utils/cache/relcache.c
src/backend/utils/misc/database.c
src/backend/utils/sort/tuplesort.c
src/include/access/heapam.h
src/include/access/htup.h
src/include/executor/spi.h
src/test/regress/regress.c

index a88d68855988167b3dff9428d5ddd059faa53f94..469a5ba252aa93c5f1a58f9acc4ae4c457a2d3d6 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.58 1999/07/19 07:07:15 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.59 1999/12/16 22:19:34 wieck Exp $
  *
  * NOTES
  *       The old interface functions have been converted to macros
@@ -562,6 +562,7 @@ heap_copytuple(HeapTuple tuple)
        newTuple = (HeapTuple) palloc(HEAPTUPLESIZE + tuple->t_len);
        newTuple->t_len = tuple->t_len;
        newTuple->t_self = tuple->t_self;
+       newTuple->t_datamcxt = CurrentMemoryContext;
        newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE);
        memmove((char *) newTuple->t_data,
                        (char *) tuple->t_data, (int) tuple->t_len);
@@ -585,6 +586,7 @@ heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
 
        dest->t_len = src->t_len;
        dest->t_self = src->t_self;
+       dest->t_datamcxt = CurrentMemoryContext;
        dest->t_data = (HeapTupleHeader) palloc(src->t_len);
        memmove((char *) dest->t_data,
                        (char *) src->t_data, (int) src->t_len);
@@ -682,6 +684,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
        len += ComputeDataSize(tupleDescriptor, value, nulls);
 
        tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len);
+       tuple->t_datamcxt = CurrentMemoryContext;
        td = tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
 
        MemSet((char *) td, 0, (int) len);
@@ -792,6 +795,27 @@ heap_modifytuple(HeapTuple tuple,
        return newTuple;
 }
 
+
+/* ----------------
+ *             heap_freetuple
+ * ----------------
+ */
+void
+heap_freetuple(HeapTuple htup)
+{
+       extern int getpid();
+
+       if (htup->t_data != NULL)
+               if (htup->t_datamcxt != NULL && (char *)(htup->t_data) != 
+                                                                       ((char *) htup + HEAPTUPLESIZE))
+               {
+                       elog(NOTICE, "TELL Jan Wieck: heap_freetuple() found separate t_data");
+               }
+
+       pfree(htup);
+}
+
+
 /* ----------------------------------------------------------------
  *                                             other misc functions
  * ----------------------------------------------------------------
@@ -814,6 +838,7 @@ heap_addheader(uint32 natts,        /* max domain index */
        hoff = len = MAXALIGN(len);             /* be conservative */
        len += structlen;
        tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len);
+       tuple->t_datamcxt = CurrentMemoryContext;
        td = tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
 
        MemSet((char *) td, 0, (int) len);
index 610066893bc9f8eb21ae2667433026d586110014..7b03545bf1c985454bc27ea458a9d04b81fb7ad8 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.60 1999/11/24 00:44:28 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.61 1999/12/16 22:19:36 wieck Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -117,6 +117,8 @@ initscan(HeapScanDesc scan,
                 *      relation is empty
                 * ----------------
                 */
+               scan->rs_ntup.t_datamcxt = scan->rs_ctup.t_datamcxt =
+               scan->rs_ptup.t_datamcxt = NULL;
                scan->rs_ntup.t_data = scan->rs_ctup.t_data =
                scan->rs_ptup.t_data = NULL;
                scan->rs_nbuf = scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
@@ -127,8 +129,10 @@ initscan(HeapScanDesc scan,
                 *      reverse scan
                 * ----------------
                 */
+               scan->rs_ntup.t_datamcxt = scan->rs_ctup.t_datamcxt = NULL;
                scan->rs_ntup.t_data = scan->rs_ctup.t_data = NULL;
                scan->rs_nbuf = scan->rs_cbuf = InvalidBuffer;
+               scan->rs_ptup.t_datamcxt = NULL;
                scan->rs_ptup.t_data = NULL;
                scan->rs_pbuf = UnknownBuffer;
        }
@@ -138,8 +142,10 @@ initscan(HeapScanDesc scan,
                 *      forward scan
                 * ----------------
                 */
+               scan->rs_ctup.t_datamcxt = scan->rs_ptup.t_datamcxt = NULL;
                scan->rs_ctup.t_data = scan->rs_ptup.t_data = NULL;
                scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
+               scan->rs_ntup.t_datamcxt = NULL;
                scan->rs_ntup.t_data = NULL;
                scan->rs_nbuf = UnknownBuffer;
        }                                                       /* invalid too */
@@ -272,6 +278,7 @@ heapgettup(Relation relation,
         */
        if (!(pages = relation->rd_nblocks))
        {
+               tuple->t_datamcxt = NULL;
                tuple->t_data = NULL;
                return;
        }
@@ -290,6 +297,7 @@ heapgettup(Relation relation,
                if (ItemPointerIsValid(tid) == false)
                {
                        *buffer = InvalidBuffer;
+                       tuple->t_datamcxt = NULL;
                        tuple->t_data = NULL;
                        return;
                }
@@ -306,6 +314,7 @@ heapgettup(Relation relation,
                lineoff = ItemPointerGetOffsetNumber(tid);
                lpp = PageGetItemId(dp, lineoff);
 
+               tuple->t_datamcxt = NULL;
                tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
                tuple->t_len = ItemIdGetLength(lpp);
                LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
@@ -376,6 +385,7 @@ heapgettup(Relation relation,
                if (page >= pages)
                {
                        *buffer = InvalidBuffer;
+                       tuple->t_datamcxt = NULL;
                        tuple->t_data = NULL;
                        return;
                }
@@ -415,6 +425,7 @@ heapgettup(Relation relation,
                {
                        if (ItemIdIsUsed(lpp))
                        {
+                               tuple->t_datamcxt = NULL;
                                tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
                                tuple->t_len = ItemIdGetLength(lpp);
                                ItemPointerSet(&(tuple->t_self), page, lineoff);
@@ -466,6 +477,7 @@ heapgettup(Relation relation,
                        if (BufferIsValid(*buffer))
                                ReleaseBuffer(*buffer);
                        *buffer = InvalidBuffer;
+                       tuple->t_datamcxt = NULL;
                        tuple->t_data = NULL;
                        return;
                }
@@ -836,6 +848,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
                {
                        if (BufferIsValid(scan->rs_nbuf))
                                ReleaseBuffer(scan->rs_nbuf);
+                       scan->rs_ntup.t_datamcxt = NULL;
                        scan->rs_ntup.t_data = NULL;
                        scan->rs_nbuf = UnknownBuffer;
                        return NULL;
@@ -892,10 +905,12 @@ heap_getnext(HeapScanDesc scandesc, int backw)
                {
                        if (BufferIsValid(scan->rs_pbuf))
                                ReleaseBuffer(scan->rs_pbuf);
+                       scan->rs_ptup.t_datamcxt = NULL;
                        scan->rs_ptup.t_data = NULL;
                        scan->rs_pbuf = InvalidBuffer;
                        if (BufferIsValid(scan->rs_nbuf))
                                ReleaseBuffer(scan->rs_nbuf);
+                       scan->rs_ntup.t_datamcxt = NULL;
                        scan->rs_ntup.t_data = NULL;
                        scan->rs_nbuf = InvalidBuffer;
                        return NULL;
@@ -903,6 +918,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 
                if (BufferIsValid(scan->rs_pbuf))
                        ReleaseBuffer(scan->rs_pbuf);
+               scan->rs_ptup.t_datamcxt = NULL;
                scan->rs_ptup.t_data = NULL;
                scan->rs_pbuf = UnknownBuffer;
 
@@ -918,6 +934,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
                {
                        if (BufferIsValid(scan->rs_pbuf))
                                ReleaseBuffer(scan->rs_pbuf);
+                       scan->rs_ptup.t_datamcxt = NULL;
                        scan->rs_ptup.t_data = NULL;
                        scan->rs_pbuf = UnknownBuffer;
                        HEAPDEBUG_3;            /* heap_getnext returns NULL at end */
@@ -976,10 +993,12 @@ heap_getnext(HeapScanDesc scandesc, int backw)
                {
                        if (BufferIsValid(scan->rs_nbuf))
                                ReleaseBuffer(scan->rs_nbuf);
+                       scan->rs_ntup.t_datamcxt = NULL;
                        scan->rs_ntup.t_data = NULL;
                        scan->rs_nbuf = InvalidBuffer;
                        if (BufferIsValid(scan->rs_pbuf))
                                ReleaseBuffer(scan->rs_pbuf);
+                       scan->rs_ptup.t_datamcxt = NULL;
                        scan->rs_ptup.t_data = NULL;
                        scan->rs_pbuf = InvalidBuffer;
                        HEAPDEBUG_6;            /* heap_getnext returning EOS */
@@ -988,6 +1007,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 
                if (BufferIsValid(scan->rs_nbuf))
                        ReleaseBuffer(scan->rs_nbuf);
+               scan->rs_ntup.t_datamcxt = NULL;
                scan->rs_ntup.t_data = NULL;
                scan->rs_nbuf = UnknownBuffer;
        }
@@ -1066,10 +1086,12 @@ heap_fetch(Relation relation,
        {
                ReleaseBuffer(buffer);
                *userbuf = InvalidBuffer;
+               tuple->t_datamcxt = NULL;
                tuple->t_data = NULL;
                return;
        }
 
+       tuple->t_datamcxt = NULL;
        tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
        tuple->t_len = ItemIdGetLength(lp);
 
@@ -1156,6 +1178,7 @@ heap_get_latest_tid(Relation relation,
         * ----------------
         */
 
+       tp.t_datamcxt = NULL;
        t_data = tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
        tp.t_len = ItemIdGetLength(lp);
        tp.t_self = *tid;
@@ -1270,6 +1293,7 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
 
        dp = (PageHeader) BufferGetPage(buffer);
        lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid));
+       tp.t_datamcxt = NULL;
        tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
        tp.t_len = ItemIdGetLength(lp);
        tp.t_self = *tid;
@@ -1365,6 +1389,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
        dp = (PageHeader) BufferGetPage(buffer);
        lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(otid));
 
+       oldtup.t_datamcxt = NULL;
        oldtup.t_data = (HeapTupleHeader) PageGetItem(dp, lp);
        oldtup.t_len = ItemIdGetLength(lp);
        oldtup.t_self = *otid;
@@ -1488,6 +1513,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
 
        dp = (PageHeader) BufferGetPage(*buffer);
        lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid));
+       tuple->t_datamcxt = NULL;
        tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
        tuple->t_len = ItemIdGetLength(lp);
 
@@ -1665,10 +1691,14 @@ heap_restrpos(HeapScanDesc scan)
        scan->rs_nbuf = InvalidBuffer;
 
        if (!ItemPointerIsValid(&scan->rs_mptid))
+       {
+               scan->rs_ptup.t_datamcxt = NULL;
                scan->rs_ptup.t_data = NULL;
+       }
        else
        {
                scan->rs_ptup.t_self = scan->rs_mptid;
+               scan->rs_ptup.t_datamcxt = NULL;
                scan->rs_ptup.t_data = (HeapTupleHeader) 0x1;   /* for heapgettup */
                heapgettup(scan->rs_rd,
                                   &(scan->rs_ptup),
@@ -1680,10 +1710,14 @@ heap_restrpos(HeapScanDesc scan)
        }
 
        if (!ItemPointerIsValid(&scan->rs_mctid))
+       {
+               scan->rs_ctup.t_datamcxt = NULL;
                scan->rs_ctup.t_data = NULL;
+       }
        else
        {
                scan->rs_ctup.t_self = scan->rs_mctid;
+               scan->rs_ctup.t_datamcxt = NULL;
                scan->rs_ctup.t_data = (HeapTupleHeader) 0x1;   /* for heapgettup */
                heapgettup(scan->rs_rd,
                                   &(scan->rs_ctup),
@@ -1695,9 +1729,13 @@ heap_restrpos(HeapScanDesc scan)
        }
 
        if (!ItemPointerIsValid(&scan->rs_mntid))
+       {
+               scan->rs_ntup.t_datamcxt = NULL;
                scan->rs_ntup.t_data = NULL;
+       }
        else
        {
+               scan->rs_ntup.t_datamcxt = NULL;
                scan->rs_ntup.t_self = scan->rs_mntid;
                scan->rs_ntup.t_data = (HeapTupleHeader) 0x1;   /* for heapgettup */
                heapgettup(scan->rs_rd,
index 1c44fe0edf159203c1c1b5168070f4d61b6a8a71..b55dd8dcc05e77632307c911a30a9147e32b3d54 100644 (file)
@@ -7,7 +7,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.72 1999/11/24 00:58:48 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.73 1999/12/16 22:19:37 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -628,7 +628,7 @@ InsertOneTuple(Oid objectid)
        if (objectid != (Oid) 0)
                tuple->t_data->t_oid = objectid;
        heap_insert(reldesc, tuple);
-       pfree(tuple);
+       heap_freetuple(tuple);
        if (DebugMode)
        {
                printf("End InsertOneTuple, objectid=%u\n", objectid);
index 08107385b413b859865d18de3cfa913088899811..39974c30fa91552601c50be52e4f16f0cc4f2b76 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.112 1999/12/10 03:55:47 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.113 1999/12/16 22:19:38 wieck Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -608,7 +608,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
                if (hasindex)
                        CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup);
 
-               pfree(tup);
+               heap_freetuple(tup);
                dpp++;
        }
 
@@ -631,7 +631,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
                if (hasindex)
                        CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup);
 
-               pfree(tup);
+               heap_freetuple(tup);
                dpp++;
        }
 
@@ -727,7 +727,7 @@ AddNewRelationTuple(Relation pg_class_desc,
                CatalogCloseIndices(Num_pg_class_indices, idescs);
        }
 
-       pfree(tup);
+       heap_freetuple(tup);
 }
 
 
@@ -1084,7 +1084,7 @@ DeleteRelationTuple(Relation rel)
         * ----------------
         */
        heap_delete(pg_class_desc, &tup->t_self, NULL);
-       pfree(tup);
+       heap_freetuple(tup);
 
        heap_close(pg_class_desc, RowExclusiveLock);
 }
@@ -1314,7 +1314,7 @@ DeleteAttributeTuples(Relation rel)
                  DeleteComments(tup->t_data->t_oid);
 
                  heap_delete(pg_attribute_desc, &tup->t_self, NULL);
-                 pfree(tup);
+                 heap_freetuple(tup);
 
                }
        }
@@ -1753,7 +1753,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
 
        pfree(DatumGetPointer(values[Anum_pg_attrdef_adbin - 1]));
        pfree(DatumGetPointer(values[Anum_pg_attrdef_adsrc - 1]));
-       pfree(tuple);
+       heap_freetuple(tuple);
        pfree(adsrc);
 
        if (! updatePgAttribute)
@@ -1778,7 +1778,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
                CatalogCloseIndices(Num_pg_attr_indices, attridescs);
        }
        heap_close(attrrel, RowExclusiveLock);
-       pfree(atttup);
+       heap_freetuple(atttup);
 }
 
 /*
@@ -1833,7 +1833,7 @@ StoreRelCheck(Relation rel, char *ccname, char *ccbin)
        pfree(DatumGetPointer(values[Anum_pg_relcheck_rcname - 1]));
        pfree(DatumGetPointer(values[Anum_pg_relcheck_rcbin - 1]));
        pfree(DatumGetPointer(values[Anum_pg_relcheck_rcsrc - 1]));
-       pfree(tuple);
+       heap_freetuple(tuple);
        pfree(ccsrc);
 }
 
@@ -2101,7 +2101,7 @@ AddRelationRawConstraints(Relation rel,
        CatalogCloseIndices(Num_pg_class_indices, relidescs);
 
        heap_close(relrel, RowExclusiveLock);
-       pfree(reltup);
+       heap_freetuple(reltup);
 
        /*
         * Force rebuild of our own relcache entry, otherwise subsequent commands
index ef49a46bd72b7bdf555d7dfe9eb6ef083f25e0c2..2efdb9331dd4a000579e8339b711f42a49d9b4cb 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.99 1999/12/10 03:55:48 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.100 1999/12/16 22:19:39 wieck Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -489,7 +489,7 @@ UpdateRelationRelation(Relation indexRelation, char *temp_relname)
        }
 
        tupleOid = tuple->t_data->t_oid;
-       pfree(tuple);
+       heap_freetuple(tuple);
        heap_close(pg_class, RowExclusiveLock);
 
        return tupleOid;
@@ -581,7 +581,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
                                                                 value,
                                                                 nullv,
                                                                 replace);
-       pfree(init_tuple);
+       heap_freetuple(init_tuple);
 
        heap_insert(pg_attribute, cur_tuple);
        if (hasind)
@@ -611,7 +611,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
                                                                         value,
                                                                         nullv,
                                                                         replace);
-               pfree(cur_tuple);
+               heap_freetuple(cur_tuple);
 
                heap_insert(pg_attribute, new_tuple);
                if (hasind)
@@ -626,7 +626,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
        }
 
        if (cur_tuple)
-               pfree(cur_tuple);
+               heap_freetuple(cur_tuple);
        heap_close(pg_attribute, RowExclusiveLock);
        if (hasind)
                CatalogCloseIndices(Num_pg_attr_indices, idescs);
@@ -768,7 +768,7 @@ UpdateIndexRelation(Oid indexoid,
        heap_close(pg_index, RowExclusiveLock);
        pfree(predText);
        pfree(indexForm);
-       pfree(tuple);
+       heap_freetuple(tuple);
 }
 
 /* ----------------------------------------------------------------
@@ -841,7 +841,7 @@ UpdateIndexPredicate(Oid indexoid, Node *oldPred, Node *predicate)
 
        heap_update(pg_index, &newtup->t_self, newtup, NULL);
 
-       pfree(newtup);
+       heap_freetuple(newtup);
        heap_close(pg_index, RowExclusiveLock);
        pfree(predText);
 }
@@ -1170,7 +1170,7 @@ index_drop(Oid indexId)
        Assert(HeapTupleIsValid(tuple));
 
        heap_delete(relationRelation, &tuple->t_self, NULL);
-       pfree(tuple);
+       heap_freetuple(tuple);
        heap_close(relationRelation, RowExclusiveLock);
 
        /* ----------------
@@ -1187,7 +1187,7 @@ index_drop(Oid indexId)
                                                                                                                        0, 0)))
        {
                heap_delete(attributeRelation, &tuple->t_self, NULL);
-               pfree(tuple);
+               heap_freetuple(tuple);
                attnum++;
        }
        heap_close(attributeRelation, RowExclusiveLock);
@@ -1204,7 +1204,7 @@ index_drop(Oid indexId)
        Assert(HeapTupleIsValid(tuple));
 
        heap_delete(indexRelation, &tuple->t_self, NULL);
-       pfree(tuple);
+       heap_freetuple(tuple);
        heap_close(indexRelation, RowExclusiveLock);
 
        /*
@@ -1433,11 +1433,11 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
                CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
                CatalogIndexInsert(idescs, Num_pg_class_indices, pg_class, newtup);
                CatalogCloseIndices(Num_pg_class_indices, idescs);
-               pfree(newtup);
+               heap_freetuple(newtup);
        }
 
        if (!IsBootstrapProcessingMode())
-               pfree(tuple);
+               heap_freetuple(tuple);
        else
                heap_endscan(pg_class_scan);
 
index 20e2f2d5e67ee264e9e68811a07182f58796e74d..7918fbd6a7359ba482646505d39f74224cea0d6d 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.53 1999/11/25 00:15:56 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.54 1999/12/16 22:19:39 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -178,7 +178,7 @@ CatalogIndexInsert(Relation *idescs,
                if (indexRes)
                        pfree(indexRes);
 
-               pfree(index_tup);
+               heap_freetuple(index_tup);
        }
 }
 
@@ -248,6 +248,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
        Buffer          buffer;
 
        sd = index_beginscan(idesc, false, num_keys, skey);
+       tuple.t_datamcxt = CurrentMemoryContext;
        tuple.t_data = NULL;
        while ((indexRes = index_getnext(sd, ForwardScanDirection)))
        {
index 5ce7655edd47010bd9c30f8e19ff37885d15c7ca..da967a23dfcf7495339066e344117be8317e1a95 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.44 1999/11/24 00:44:29 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.45 1999/12/16 22:19:39 wieck Exp $
  *
  * NOTES
  *       these routines moved here from commands/define.c and somewhat cleaned up.
@@ -306,7 +306,7 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
         *      free the tuple and return the operator oid
         * ----------------
         */
-       pfree(tup);
+       heap_freetuple(tup);
 
        return operatorObjectId;
 }
index 9ec3c3fd82250cdfda0d83267efa30a851e5cd30..4a2bdca1c1ba75bcdcd33671715b9f5aaeb7f3b0 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.43 1999/11/24 00:44:29 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.44 1999/12/16 22:19:39 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -218,7 +218,7 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
         *      free the tuple and return the type-oid
         * ----------------
         */
-       pfree(tup);
+       heap_freetuple(tup);
 
        return typoid;
 }
@@ -551,7 +551,7 @@ TypeRename(char *oldTypeName, char *newTypeName)
                                                                 0, 0, 0);
        if (HeapTupleIsValid(newtup))
        {
-               pfree(oldtup);
+               heap_freetuple(oldtup);
                heap_close(pg_type_desc, RowExclusiveLock);
                elog(ERROR, "TypeRename: type %s already defined", newTypeName);
        }
@@ -567,7 +567,7 @@ TypeRename(char *oldTypeName, char *newTypeName)
        CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, oldtup);
        CatalogCloseIndices(Num_pg_type_indices, idescs);
 
-       pfree(oldtup);
+       heap_freetuple(oldtup);
        heap_close(pg_type_desc, RowExclusiveLock);
 }
 
index 2267a2415e7cd2360e04303d67478afcd0930a1e..627ef19d286c78b487b314fcbe4db846019ab71b 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.56 1999/11/24 00:44:29 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.57 1999/12/16 22:19:41 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -247,7 +247,7 @@ Async_Listen(char *relname, int pid)
        tupDesc = lRel->rd_att;
        newtup = heap_formtuple(tupDesc, values, nulls);
        heap_insert(lRel, newtup);
-       pfree(newtup);
+       heap_freetuple(newtup);
 
        heap_close(lRel, AccessExclusiveLock);
 
index ded4c7ea61d562626de63cf96b3b3ee28ac856be..0184d738dc91a156927305344cc125309df54c04 100644 (file)
@@ -14,7 +14,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.48 1999/12/10 03:55:49 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.49 1999/12/16 22:19:41 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -328,6 +328,8 @@ rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
        {
 
                LocalHeapTuple.t_self = ScanResult->heap_iptr;
+               LocalHeapTuple.t_datamcxt = NULL;
+               LocalHeapTuple.t_data = NULL;
                heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer);
                OIDNewHeapInsert = heap_insert(LocalNewHeap, &LocalHeapTuple);
                pfree(ScanResult);
index ddf89b8d7ddc20e28d7cfdd616ddf6a16608b9e6..30c2bc14e327b8b3a509244b30f620d159c65cc8 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.60 1999/12/14 03:35:20 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.61 1999/12/16 22:19:41 wieck Exp $
  *
  * NOTES
  *       The PortalExecutorHeapMemory crap needs to be eliminated
@@ -481,7 +481,7 @@ PerformAddAttribute(char *relationName,
        CatalogIndexInsert(ridescs, Num_pg_class_indices, rel, reltup);
        CatalogCloseIndices(Num_pg_class_indices, ridescs);
 
-       pfree(reltup);
+       heap_freetuple(reltup);
        heap_close(rel, RowExclusiveLock);
 }
 
index 1b046a5f57a3cb35efb8e93df3d55ea98ec9d181..e98f4be885050e8a32dea881af9c2722b6a1a8fd 100644 (file)
@@ -190,7 +190,7 @@ void CreateComments(Oid oid, char *comment) {
                         desctuple);
       CatalogCloseIndices(Num_pg_description_indices, idescs);
     }
-    pfree(desctuple);
+    heap_freetuple(desctuple);
 
   }
 
index 04ee4fc870820df1a883b234681cf1facc1c3791..f42665a956482ff672f4691f5a4cd3c98ab229ef 100644 (file)
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.93 1999/12/14 00:08:13 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.94 1999/12/16 22:19:41 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -837,7 +837,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
                                skip_tuple = true;
                        else if (newtuple != tuple) /* modified by Trigger(s) */
                        {
-                               pfree(tuple);
+                               heap_freetuple(tuple);
                                tuple = newtuple;
                        }
                }
@@ -905,7 +905,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
                                nulls[i] = ' ';
                }
 
-               pfree(tuple);
+               heap_freetuple(tuple);
                tuples_read++;
 
                if (!reading_to_eof && ntuples == tuples_read)
index 4dded845afd2db5996a306c4307c0d5df1761451..8cf8918fa3631e84f32134556bd36165aea16c49 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.53 1999/12/10 03:55:49 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.54 1999/12/16 22:19:41 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -505,7 +505,7 @@ StoreCatalogInheritance(Oid relationId, List *supers)
                        CatalogCloseIndices(Num_pg_inherits_indices, idescs);
                }
 
-               pfree(tuple);
+               heap_freetuple(tuple);
 
                seqNumber += 1;
        }
@@ -620,7 +620,7 @@ again:
                tuple = heap_formtuple(desc, datum, nullarr);
 
                heap_insert(relation, tuple);
-               pfree(tuple);
+               heap_freetuple(tuple);
 
                seqNumber += 1;
        }
index ab3badf9704974bffc7eb916189244e7e1ce8984..e4607d93a558487652f1fadca199dcc25f6f0d60 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.15 1999/12/10 03:55:49 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.16 1999/12/16 22:19:41 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -518,7 +518,7 @@ NormIndexAttrs(List *attList,       /* list of IndexElem's */
                                 attribute->class);
                }
                *classOidP++ = tuple->t_data->t_oid;
-               pfree(atttuple);
+               heap_freetuple(atttuple);
        }
 }
 
index aad945bd6bba2bebb33624cb32bf5f40a35bb1fb..718e06dee47f2ca0eeaa455cce28d185022eb56b 100644 (file)
@@ -183,6 +183,6 @@ DropProceduralLanguage(DropPLangStmt *stmt)
 
        heap_delete(rel, &langTup->t_self, NULL);
 
-       pfree(langTup);
+       heap_freetuple(langTup);
        heap_close(rel, RowExclusiveLock);
 }
index 6cf94518e2d2be39a93eebcf3b9cb57080797929..07b552dedd70c75d7ef5bcb74541aaa42e3aec11 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.41 1999/12/10 03:55:49 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.42 1999/12/16 22:19:41 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -125,7 +125,7 @@ RemoveOperator(char *operatorName,          /* operator name */
                                 typeName2);
                }
        }
-       pfree(tup);
+       heap_freetuple(tup);
        heap_close(relation, RowExclusiveLock);
 }
 
index b3f1e53989e6661090a38ddf761b48531f2b1849..8a94597770e77d1221365e10ac5039d13689fdfd 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.38 1999/12/14 03:35:20 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.39 1999/12/16 22:19:42 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -147,7 +147,7 @@ renameatt(char *relname,
        /* should not already exist */
        if (HeapTupleIsValid(newatttup))
        {
-               pfree(oldatttup);
+               heap_freetuple(oldatttup);
                elog(ERROR, "renameatt: attribute \"%s\" exists", newattname);
        }
 
@@ -164,7 +164,7 @@ renameatt(char *relname,
                CatalogCloseIndices(Num_pg_attr_indices, irelations);
        }
        
-       pfree(oldatttup);
+       heap_freetuple(oldatttup);
        heap_close(attrelation, RowExclusiveLock);
 }
 
index 695b216fb554ad93d6f4d79cf0f936be5baa0972..2615ea43ccea658497c79f1f0895ffbb885638d0 100644 (file)
@@ -235,7 +235,7 @@ CreateTrigger(CreateTrigStmt *stmt)
        CatalogOpenIndices(Num_pg_trigger_indices, Name_pg_trigger_indices, idescs);
        CatalogIndexInsert(idescs, Num_pg_trigger_indices, tgrel, tuple);
        CatalogCloseIndices(Num_pg_trigger_indices, idescs);
-       pfree(tuple);
+       heap_freetuple(tuple);
        heap_close(tgrel, RowExclusiveLock);
 
        pfree(DatumGetPointer(values[Anum_pg_trigger_tgname - 1]));
@@ -255,7 +255,7 @@ CreateTrigger(CreateTrigStmt *stmt)
        CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
        CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple);
        CatalogCloseIndices(Num_pg_class_indices, ridescs);
-       pfree(tuple);
+       heap_freetuple(tuple);
        heap_close(pgrel, RowExclusiveLock);
 
        CommandCounterIncrement();
@@ -334,7 +334,7 @@ DropTrigger(DropTrigStmt *stmt)
        CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
        CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple);
        CatalogCloseIndices(Num_pg_class_indices, ridescs);
-       pfree(tuple);
+       heap_freetuple(tuple);
        heap_close(pgrel, RowExclusiveLock);
 
        CommandCounterIncrement();
@@ -690,7 +690,7 @@ ExecBRInsertTriggers(Relation rel, HeapTuple trigtuple)
                if (newtuple == NULL)
                        break;
                else if (oldtuple != newtuple && oldtuple != trigtuple)
-                       pfree(oldtuple);
+                       heap_freetuple(oldtuple);
        }
        CurrentTriggerData = NULL;
        pfree(SaveTriggerData);
@@ -735,11 +735,11 @@ ExecBRDeleteTriggers(EState *estate, ItemPointer tupleid)
                if (newtuple == NULL)
                        break;
                if (newtuple != trigtuple)
-                       pfree(newtuple);
+                       heap_freetuple(newtuple);
        }
        CurrentTriggerData = NULL;
        pfree(SaveTriggerData);
-       pfree(trigtuple);
+       heap_freetuple(trigtuple);
 
        return (newtuple == NULL) ? false : true;
 }
@@ -793,11 +793,11 @@ ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
                if (newtuple == NULL)
                        break;
                else if (oldtuple != newtuple && oldtuple != intuple)
-                       pfree(oldtuple);
+                       heap_freetuple(oldtuple);
        }
        CurrentTriggerData = NULL;
        pfree(SaveTriggerData);
-       pfree(trigtuple);
+       heap_freetuple(trigtuple);
        return newtuple;
 }
 
@@ -886,6 +886,7 @@ ltrmark:;
 
                Assert(ItemIdIsUsed(lp));
 
+               tuple.t_datamcxt = NULL;
                tuple.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
                tuple.t_len = ItemIdGetLength(lp);
                tuple.t_self = *tid;
@@ -1150,7 +1151,7 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno)
        rettuple = ExecCallTriggerFunc(SaveTriggerData.tg_trigger);
        CurrentTriggerData = NULL;
        if (rettuple != NULL && rettuple != &oldtuple && rettuple != &newtuple)
-               pfree(rettuple);
+               heap_freetuple(rettuple);
 
        /* ----------
         * Might have been a referential integrity constraint trigger.
index 7e0c47ef4af4ed9dc3e939cc6ec41311465fa670..054a4ad6d60287668ee13c3dc1fd5fca1e576b2d 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.130 1999/12/10 03:55:49 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.131 1999/12/16 22:19:42 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -710,6 +710,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
                                continue;
                        }
 
+                       tuple.t_datamcxt = NULL;
                        tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
                        tuple.t_len = ItemIdGetLength(itemid);
                        ItemPointerSet(&(tuple.t_self), blkno, offnum);
@@ -1153,6 +1154,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                        if (!ItemIdIsUsed(itemid))
                                continue;
 
+                       tuple.t_datamcxt = NULL;
                        tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
                        tuple_len = tuple.t_len = ItemIdGetLength(itemid);
                        ItemPointerSet(&(tuple.t_self), blkno, offnum);
@@ -1264,6 +1266,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                                                elog(NOTICE, "Child itemid in update-chain marked as unused - can't continue vc_rpfheap");
                                                break;
                                        }
+                                       tp.t_datamcxt = NULL;
                                        tp.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid);
                                        tp.t_self = Ctid;
                                        tlen = tp.t_len = ItemIdGetLength(Citemid);
@@ -1360,6 +1363,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                                                           ItemPointerGetOffsetNumber(&(tp.t_self)));
                                                if (!ItemIdIsUsed(Pitemid))
                                                        elog(ERROR, "Parent itemid marked as unused");
+                                               Ptp.t_datamcxt = NULL;
                                                Ptp.t_data = (HeapTupleHeader) PageGetItem(Ppage, Pitemid);
                                                Assert(ItemPointerEquals(&(vtld.new_tid),
                                                                                                &(Ptp.t_data->t_ctid)));
@@ -1409,6 +1413,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                                                        continue;
                                                }
 #endif
+                                               tp.t_datamcxt = Ptp.t_datamcxt;
                                                tp.t_data = Ptp.t_data;
                                                tlen = tp.t_len = ItemIdGetLength(Pitemid);
                                                if (freeCbuf)
@@ -1437,6 +1442,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
                                        Cpage = BufferGetPage(Cbuf);
                                        Citemid = PageGetItemId(Cpage,
                                                        ItemPointerGetOffsetNumber(&(tuple.t_self)));
+                                       tuple.t_datamcxt = NULL;
                                        tuple.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid);
                                        tuple_len = tuple.t_len = ItemIdGetLength(Citemid);
                                        /* Get page to move in */
@@ -1468,6 +1474,7 @@ moving chain: failed to add item with len = %u to page %u",
                                        }
                                        newitemid = PageGetItemId(ToPage, newoff);
                                        pfree(newtup.t_data);
+                                       newtup.t_datamcxt = NULL;
                                        newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid);
                                        ItemPointerSet(&(newtup.t_self), vtmove[ti].vpd->vpd_blkno, newoff);
 
@@ -1599,6 +1606,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
                        }
                        newitemid = PageGetItemId(ToPage, newoff);
                        pfree(newtup.t_data);
+                       newtup.t_datamcxt = NULL;
                        newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid);
                        ItemPointerSet(&(newtup.t_data->t_ctid), cur_page->vpd_blkno, newoff);
                        newtup.t_self = newtup.t_data->t_ctid;
@@ -1652,6 +1660,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
                                itemid = PageGetItemId(page, off);
                                if (!ItemIdIsUsed(itemid))
                                        continue;
+                               tuple.t_datamcxt = NULL;
                                tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
                                if (tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)
                                        continue;
@@ -1756,6 +1765,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
                                itemid = PageGetItemId(page, newoff);
                                if (!ItemIdIsUsed(itemid))
                                        continue;
+                               tuple.t_datamcxt = NULL;
                                tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
                                if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
                                {
@@ -1827,6 +1837,7 @@ Elapsed %u/%u sec.",
                                itemid = PageGetItemId(page, offnum);
                                if (!ItemIdIsUsed(itemid))
                                        continue;
+                               tuple.t_datamcxt = NULL;
                                tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
 
                                if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
@@ -2332,7 +2343,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex,
        /* get the buffer cache tuple */
        rtup.t_self = ctup->t_self;
        heap_fetch(rd, SnapshotNow, &rtup, &buffer);
-       pfree(ctup);
+       heap_freetuple(ctup);
 
        /* overwrite the existing statistics in the tuple */
        pgcform = (Form_pg_class) GETSTRUCT(&rtup);
@@ -2521,7 +2532,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex,
                                        pfree(DatumGetPointer(values[Anum_pg_statistic_stacommonval-1]));
                                        pfree(DatumGetPointer(values[Anum_pg_statistic_staloval-1]));
                                        pfree(DatumGetPointer(values[Anum_pg_statistic_stahival-1]));
-                                       pfree(stup);
+                                       heap_freetuple(stup);
                                }
                        }
                }
index 1931ebcf535867cecdf2dd8067869dd5bcb3e569..983904bd237c563c5241c676b6298fc3135ad80f 100644 (file)
@@ -14,7 +14,7 @@
  *             ExecInitTee
  *             ExecEndTee
  *
- *     $Id: nodeTee.c,v 1.6 1999/12/10 03:55:52 momjian Exp $
+ *     $Id: nodeTee.c,v 1.7 1999/12/16 22:19:45 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -350,7 +350,7 @@ ExecTee(Tee * node, Plan *parent)
                        heap_insert(bufferRel, heapTuple);
 
                        if (slot->ttc_buffer != InvalidBuffer)
-                               pfree(heapTuple);
+                               heap_freetuple(heapTuple);
 
                        /*
                         * once there is data in the temporary relation, ensure that
index bea42714aa44c7dca556aa81d47894a0cecc1c3d..02f04912bd82db50f91cb486f8eb2b003ba4115c 100644 (file)
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.102 1999/12/10 03:55:51 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.103 1999/12/16 22:19:44 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1147,7 +1147,7 @@ ExecAppend(TupleTableSlot *slot,
                if (newtuple != tuple)  /* modified by Trigger(s) */
                {
                        Assert(slot->ttc_shouldFree);
-                       pfree(tuple);
+                       heap_freetuple(tuple);
                        slot->val = tuple = newtuple;
                }
        }
@@ -1334,7 +1334,7 @@ ExecReplace(TupleTableSlot *slot,
                if (newtuple != tuple)  /* modified by Trigger(s) */
                {
                        Assert(slot->ttc_shouldFree);
-                       pfree(tuple);
+                       heap_freetuple(tuple);
                        slot->val = tuple = newtuple;
                }
        }
@@ -1472,7 +1472,7 @@ ExecAttrDefault(Relation rel, HeapTuple tuple)
        newtuple = heap_modifytuple(tuple, rel, replValue, replNull, repl);
 
        pfree(repl);
-       pfree(tuple);
+       heap_freetuple(tuple);
        pfree(replNull);
        pfree(replValue);
 
@@ -1614,7 +1614,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
                        /* stop execution */
                        ExecEndNode(epq->plan, epq->plan);
                    epqstate->es_tupleTable->next = 0;
-                       pfree(epqstate->es_evTuple[epq->rti - 1]);
+                       heap_freetuple(epqstate->es_evTuple[epq->rti - 1]);
                        epqstate->es_evTuple[epq->rti - 1] = NULL;
                        /* push current PQ to freePQ stack */
                        oldepq->free = epq;
@@ -1689,7 +1689,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
        /* free old RTE' tuple */
        if (epqstate->es_evTuple[epq->rti - 1] != NULL)
        {
-               pfree(epqstate->es_evTuple[epq->rti - 1]);
+               heap_freetuple(epqstate->es_evTuple[epq->rti - 1]);
                epqstate->es_evTuple[epq->rti - 1] = NULL;
        }
 
@@ -1738,7 +1738,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
                         * Nice! We got tuple - now copy it.
                         */
                        if (epqstate->es_evTuple[epq->rti - 1] != NULL)
-                               pfree(epqstate->es_evTuple[epq->rti - 1]);
+                               heap_freetuple(epqstate->es_evTuple[epq->rti - 1]);
                        epqstate->es_evTuple[epq->rti - 1] = heap_copytuple(&tuple);
                        ReleaseBuffer(buffer);
                        break;
@@ -1815,7 +1815,7 @@ lpqnext:;
        {
                ExecEndNode(epq->plan, epq->plan);
            epqstate->es_tupleTable->next = 0;
-               pfree(epqstate->es_evTuple[epq->rti - 1]);
+               heap_freetuple(epqstate->es_evTuple[epq->rti - 1]);
                epqstate->es_evTuple[epq->rti - 1] = NULL;
                /* pop old PQ from the stack */
                oldepq = (evalPlanQual *) epqstate->es_evalPlanQual;
index e31d7993a281b5d75bfd6520d211164d533cc43b..66b8909d559f9345e38e5252cd30d7bf586bc1c3 100644 (file)
@@ -14,7 +14,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.33 1999/12/10 03:55:51 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.34 1999/12/16 22:19:44 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
 #undef ExecStoreTuple
 
 #include "catalog/pg_type.h"
+#include "access/heapam.h"
 
 static TupleTableSlot *NodeGetResultTupleSlot(Plan *node);
 
@@ -420,7 +421,7 @@ ExecClearTuple(TupleTableSlot *slot)        /* slot in which to store tuple */
         * ----------------
         */
        if (slot->ttc_shouldFree && oldtuple != NULL)
-               pfree(oldtuple);
+               heap_freetuple(oldtuple);
 
        slot->val = (HeapTuple) NULL;
 
index 38f7a0365db9e56e6d00c71f12cccf8321655872..79edf78a274d4ec9edf862154cac481af6ca719e 100644 (file)
@@ -13,7 +13,7 @@
  *       columns. (ie. tuples from the same group are consecutive)
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.30 1999/09/24 00:24:23 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.31 1999/12/16 22:19:44 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -124,7 +124,7 @@ ExecGroupEveryTuple(Group *node)
                                                   ExecGetScanType(&grpstate->csstate)))
                        {
                                grpstate->grp_useFirstTuple = TRUE;
-                               pfree(firsttuple);
+                               heap_freetuple(firsttuple);
                                grpstate->grp_firstTuple = heap_copytuple(outerTuple);
 
                                return NULL;    /* signifies the end of the group */
@@ -242,7 +242,7 @@ ExecGroupOneTuple(Group *node)
        /* save outerTuple if we are not done yet */
        if (!grpstate->grp_done)
        {
-               pfree(firsttuple);
+               heap_freetuple(firsttuple);
                grpstate->grp_firstTuple = heap_copytuple(outerTuple);
        }
 
@@ -341,7 +341,7 @@ ExecEndGroup(Group *node)
        ExecClearTuple(grpstate->csstate.css_ScanTupleSlot);
        if (grpstate->grp_firstTuple != NULL)
        {
-               pfree(grpstate->grp_firstTuple);
+               heap_freetuple(grpstate->grp_firstTuple);
                grpstate->grp_firstTuple = NULL;
        }
 }
@@ -429,7 +429,7 @@ ExecReScanGroup(Group *node, ExprContext *exprCtxt, Plan *parent)
        grpstate->grp_done = FALSE;
        if (grpstate->grp_firstTuple != NULL)
        {
-               pfree(grpstate->grp_firstTuple);
+               heap_freetuple(grpstate->grp_firstTuple);
                grpstate->grp_firstTuple = NULL;
        }
 
index 12dbcec122fb67f49742d25dc53f2c6ee7508afa..3d5083a7ba9b6981b5ab558107e1c372be44526e 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  *
- *     $Id: nodeHash.c,v 1.40 1999/12/10 03:55:51 momjian Exp $
+ *     $Id: nodeHash.c,v 1.41 1999/12/16 22:19:44 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -482,6 +482,7 @@ ExecHashTableInsert(HashJoinTable hashtable,
                memcpy((char *) &hashTuple->htup,
                           (char *) heapTuple,
                           sizeof(hashTuple->htup));
+               hashTuple->htup.t_datamcxt = hashtable->batchCxt;
                hashTuple->htup.t_data = (HeapTupleHeader)
                        (((char *) hashTuple) + MAXALIGN(sizeof(*hashTuple)));
                memcpy((char *) hashTuple->htup.t_data,
index ffda9723182a7b04594b223f642cd2c497f3911f..9d5034307fe34a6c33cf9538bfe14bdee17dbacc 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.27 1999/10/13 15:02:25 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.28 1999/12/16 22:19:44 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -485,6 +485,7 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate,
                elog(ERROR, "Read from hashjoin temp file failed");
        heapTuple = palloc(HEAPTUPLESIZE + htup.t_len);
        memcpy((char *) heapTuple, (char *) &htup, sizeof(HeapTupleData));
+       heapTuple->t_datamcxt = CurrentMemoryContext;
        heapTuple->t_data = (HeapTupleHeader)
                ((char *) heapTuple + HEAPTUPLESIZE);
        nread = BufFileRead(file, (void *) heapTuple->t_data, htup.t_len);
index 65c42b61b3b23f100870f87569c30ff1af76f912..60b484d708b66cc6c051a58426381806110bc81a 100644 (file)
@@ -6,7 +6,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.17 1999/11/15 03:28:05 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/nodeSubplan.c,v 1.18 1999/12/16 22:19:44 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -117,7 +117,7 @@ ExecSubPlan(SubPlan *node, List *pvar, ExprContext *econtext, bool *isNull)
                         */
                        tup = heap_copytuple(tup);
                        if (node->curTuple)
-                               pfree(node->curTuple);
+                               heap_freetuple(node->curTuple);
                        node->curTuple = tup;
                        result = heap_getattr(tup, col, tdesc, isNull);
                        /* keep scanning subplan to make sure there's only one tuple */
@@ -351,7 +351,7 @@ ExecSetParamPlan(SubPlan *node)
                 */
                tup = heap_copytuple(tup);
                if (node->curTuple)
-                       pfree(node->curTuple);
+                       heap_freetuple(node->curTuple);
                node->curTuple = tup;
 
                foreach(lst, node->setParam)
@@ -408,7 +408,7 @@ ExecEndSubPlan(SubPlan *node)
        }
        if (node->curTuple)
        {
-               pfree(node->curTuple);
+               heap_freetuple(node->curTuple);
                node->curTuple = NULL;
        }
 }
index 8d6481bf8ad4b823cc89b3bc3e6ef593edefc844..6a9e7e5e0701d99e2edd3059c9d20dbb6f6d752c 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.1 1999/11/23 20:06:51 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.2 1999/12/16 22:19:44 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -148,6 +148,7 @@ TidNext(TidScan *node)
                bool            slot_is_valid = false;
 
                itemptr = tidList[tidstate->tss_TidPtr];
+               tuple->t_datamcxt = NULL;
                tuple->t_data = NULL;
                if (itemptr)
                {
index c0231ce317aeeba06d1d41538d6b0a96f2c77ee8..7c65c66814f863bdaa590c88af77936c27d0e3ea 100644 (file)
@@ -3,7 +3,7 @@
  * spi.c
  *                             Server Programming Interface
  *
- * $Id: spi.c,v 1.43 1999/12/10 03:55:51 momjian Exp $
+ * $Id: spi.c,v 1.44 1999/12/16 22:19:44 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -543,6 +543,26 @@ SPI_pfree(void *pointer)
        return;
 }
 
+void
+SPI_freetuple(HeapTuple tuple)
+{
+       MemoryContext oldcxt = NULL;
+
+       if (_SPI_curid + 1 == _SPI_connected)           /* connected */
+       {
+               if (_SPI_current != &(_SPI_stack[_SPI_curid + 1]))
+                       elog(FATAL, "SPI: stack corrupted");
+               oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt);
+       }
+
+       heap_freetuple(tuple);
+
+       if (oldcxt)
+               MemoryContextSwitchTo(oldcxt);
+
+       return;
+}
+
 /* =================== private functions =================== */
 
 /*
index 66368afd6871a1fd5ccc4d5aaeb695110b5b2f80..7e9ae5d06f63afb915ed56178292633f585c1ea7 100644 (file)
@@ -7,15 +7,15 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.28 1999/11/23 20:06:53 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/nodes/Attic/freefuncs.c,v 1.29 1999/12/16 22:19:47 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
 
 #include "postgres.h"
 
-
 #include "optimizer/planmain.h"
+#include "access/heapam.h"
 
 /* ****************************************************************
  *                                      plannodes.h free functions
@@ -465,7 +465,7 @@ _freeSubPlan(SubPlan *node)
        freeObject(node->sublink);
 
        if (node->curTuple)
-               pfree(node->curTuple);
+               heap_freetuple(node->curTuple);
 
        pfree(node);
 }
index 42143746b815c77cfa5c7964eaa01e439af49308..2a197237841c410d2d4f49124d9f1d87512fd8a1 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.64 1999/12/10 07:37:35 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.65 1999/12/16 22:19:48 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -697,6 +697,8 @@ func_get_candidates(char *funcname, int nargs)
                {
                        Buffer          buffer;
 
+                       tuple.t_datamcxt = NULL;
+                       tuple.t_data = NULL;
                        tuple.t_self = indexRes->heap_iptr;
                        heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer);
                        pfree(indexRes);
index ec473fb47183d9adbdacc539d7d3dddb3c1178bc..a3f8eda940e997c288ac6f51a4c51563b2c89a22 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.33 1999/11/22 17:56:23 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.34 1999/12/16 22:19:49 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -108,7 +108,7 @@ RemoveRewriteRule(char *ruleName)
        if (isNull)
        {
                /* XXX strange!!! */
-               pfree(tuple);
+               heap_freetuple(tuple);
                elog(ERROR, "RemoveRewriteRule: internal error; null event target relation!");
        }
        eventRelationOid = DatumGetObjectId(eventRelationOidDatum);
@@ -133,7 +133,7 @@ RemoveRewriteRule(char *ruleName)
         */
        heap_delete(RewriteRelation, &tuple->t_self, NULL);
 
-       pfree(tuple);
+       heap_freetuple(tuple);
        heap_close(RewriteRelation, RowExclusiveLock);
 }
 
index 08438d2ae6c2028f5e097142753e816bc2f8fc6f..02ae94b7747d9ddef8f4c549c54e0ddcca707b7e 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.39 1999/11/24 00:44:34 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.40 1999/12/16 22:19:50 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -113,7 +113,7 @@ setRelhasrulesInRelation(Oid relationId, bool relhasrules)
        CatalogIndexInsert(idescs, Num_pg_class_indices, relationRelation, tuple);
        CatalogCloseIndices(Num_pg_class_indices, idescs);
 
-       pfree(tuple);
+       heap_freetuple(tuple);
        heap_close(relationRelation, RowExclusiveLock);
 }
 
index 9026e8124fc5c15b0eb35bea5b6d5084aa0afff6..f066d418e76da16a114538690c79ebb963df7ba5 100644 (file)
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.62 1999/12/10 03:55:57 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.63 1999/12/16 22:19:51 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -654,6 +654,7 @@ inv_fetchtup(LargeObjectDesc *obj_desc, HeapTuple tuple, Buffer *buffer)
                        if (res == (RetrieveIndexResult) NULL)
                        {
                                ItemPointerSetInvalid(&(obj_desc->htid));
+                               tuple->t_datamcxt = NULL;
                                tuple->t_data = NULL;
                                return;
                        }
@@ -797,7 +798,7 @@ inv_wrnew(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 
        ntup = inv_newtuple(obj_desc, buffer, page, buf, nwritten);
        inv_indextup(obj_desc, ntup);
-       pfree(ntup);
+       heap_freetuple(ntup);
 
        /* new tuple is inserted */
        WriteBuffer(buffer);
@@ -971,7 +972,7 @@ inv_wrold(LargeObjectDesc *obj_desc,
 
        /* index the new tuple */
        inv_indextup(obj_desc, ntup);
-       pfree(ntup);
+       heap_freetuple(ntup);
 
        /*
         * move the scandesc forward so we don't reread the newly inserted
@@ -1059,6 +1060,7 @@ inv_newtuple(LargeObjectDesc *obj_desc,
        ph->pd_lower = lower;
        ph->pd_upper = upper;
 
+       ntup->t_datamcxt = NULL;
        ntup->t_data = (HeapTupleHeader) ((char *) page + upper);
 
        /*
index f5ebcdf0eb32e971cf7f9813d957eaa2b2f8a15d..e346639994f65b0a8384e4fc20801136dec765aa 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.45 1999/11/22 17:56:29 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.46 1999/12/16 22:19:52 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -84,6 +84,8 @@ regprocin(char *pro_name_or_oid)
                        sd = index_beginscan(idesc, false, 1, skey);
                        while ((indexRes = index_getnext(sd, ForwardScanDirection)))
                        {
+                               tuple.t_datamcxt = NULL;
+                               tuple.t_data = NULL;
                                tuple.t_self = indexRes->heap_iptr;
                                heap_fetch(hdesc, SnapshotNow,
                                                   &tuple,
index 96e8288916a51dbd12c8b5f1ed3c4750286739ed..e061e8feaefd4b380ebcbbb3978cff4a2b23f250 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.54 1999/11/22 17:56:31 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.55 1999/12/16 22:19:54 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -839,7 +839,7 @@ SearchSelfReferences(struct catcache * cache)
                                elog(ERROR, "SearchSelfReferences: %s not found in %s",
                                        IndexRelidIndex, RelationRelationName);
                        indexSelfOid = ntp->t_data->t_oid;
-                       pfree(ntp);
+                       heap_freetuple(ntp);
                        heap_close(rel, AccessShareLock);
                }
                /* Looking for something other than pg_index_indexrelid_index? */
index c2f5a7d655cd55fc7accb617b5084dcc89eb6cef..007adfb01f0c76e66b4350d462e62ba3b4fa3c16 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.81 1999/11/22 17:56:32 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.82 1999/12/16 22:19:54 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -871,7 +871,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo,
         *      and for lock data pointed to by pg_class_tuple
         * -------------------
         */
-       pfree(pg_class_tuple);
+       heap_freetuple(pg_class_tuple);
 
        MemoryContextSwitchTo(oldcxt);
 
@@ -1714,6 +1714,7 @@ AttrDefaultFetch(Relation relation)
        adrel = heap_openr(AttrDefaultRelationName, AccessShareLock);
        irel = index_openr(AttrDefaultIndex);
        sd = index_beginscan(irel, false, 1, &skey);
+       tuple.t_datamcxt = NULL;
        tuple.t_data = NULL;
 
        for (found = 0;;)
@@ -1793,6 +1794,7 @@ RelCheckFetch(Relation relation)
        rcrel = heap_openr(RelCheckRelationName, AccessShareLock);
        irel = index_openr(RelCheckIndex);
        sd = index_beginscan(irel, false, 1, &skey);
+       tuple.t_datamcxt = NULL;
        tuple.t_data = NULL;
 
        for (found = 0;;)
index c7cd9f838de0133d7ba7ce5dda779d20f7db4f12..62a4303f717cf06caefba512337ca0e8ccbb18f5 100644 (file)
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.32 1999/11/07 23:08:29 momjian Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.33 1999/12/16 22:19:55 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -222,6 +222,7 @@ GetRawDatabaseInfo(char *name, Oid *db_id, char *path)
 
                        /* get a pointer to the tuple itself */
                        offset = (int) ph->pd_linp[i].lp_off;
+                       tup.t_datamcxt = NULL;
                        tup.t_data = (HeapTupleHeader) (((char *) pg) + offset);
 
                        /*
index 6e9a23f1cd12cb4b50ed48f8baaf07c0a70402aa..557843428c56c0febeb1bec113894cc92f5c93a1 100644 (file)
@@ -77,7 +77,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *       $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.3 1999/12/13 01:27:04 tgl Exp $
+ *       $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.4 1999/12/16 22:19:56 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1697,7 +1697,7 @@ writetup_heap(Tuplesortstate *state, int tapenum, void *tup)
                                                 (void*) &tuplen, sizeof(tuplen));
 
        FREEMEM(state, HEAPTUPLESIZE + tuple->t_len);
-       pfree(tuple);
+       heap_freetuple(tuple);
 }
 
 static void *
@@ -1710,6 +1710,7 @@ readtup_heap(Tuplesortstate *state, int tapenum, unsigned int len)
        /* reconstruct the HeapTupleData portion */
        tuple->t_len = len - sizeof(unsigned int);
        ItemPointerSetInvalid(&(tuple->t_self));
+       tuple->t_datamcxt = CurrentMemoryContext;
        tuple->t_data = (HeapTupleHeader) (((char *) tuple) + HEAPTUPLESIZE);
        /* read in the tuple proper */
        if (LogicalTapeRead(state->tapeset, tapenum, (void *) tuple->t_data,
index 239c3c468eb5848b295ca70062f26a82df43ca8f..39da1553290bc558b655c39fb727ae9ef0d30f04 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: heapam.h,v 1.48 1999/11/24 00:44:37 momjian Exp $
+ * $Id: heapam.h,v 1.49 1999/12/16 22:19:58 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -281,6 +281,7 @@ extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor,
                           Datum *value, char *nulls);
 extern HeapTuple heap_modifytuple(HeapTuple tuple,
                Relation relation, Datum *replValue, char *replNull, char *repl);
+extern void heap_freetuple(HeapTuple tuple);
 HeapTuple      heap_addheader(uint32 natts, int structlen, char *structure);
 
 /* in common/heap/stats.c */
index e091208e52e5a69396f874a7cd05a08f8d76b8ae..c81dcfd6a8823b83b2105e259f0c56cd1e8fe6c1 100644 (file)
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: htup.h,v 1.25 1999/07/19 07:07:28 momjian Exp $
+ * $Id: htup.h,v 1.26 1999/12/16 22:19:58 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -78,11 +78,17 @@ extern long heap_sysoffset[];
  *       updated version of tuple (required by MVCC);
  * 3. someday someone let tuple to cross block boundaries -
  *       he have to add something below...
+ *
+ * Change for 7.0:
+ *    Up to now t_data could be NULL, the memory location directly following
+ *    HeapTupleData or pointing into a buffer. Now, it could also point to
+ *    a separate allocation that was done in the t_datamcxt memory context.
  */
 typedef struct HeapTupleData
 {
        uint32          t_len;                  /* length of *t_data */
        ItemPointerData t_self;         /* SelfItemPointer */
+       MemoryContext   t_datamcxt; /* */
        HeapTupleHeader t_data;         /* */
 } HeapTupleData;
 
index 9c5f8d5cfc239e48e19aa21af837f1c9721e0d17..1c1e75876df41e511a7431e17b3727247db5abcb 100644 (file)
@@ -93,5 +93,6 @@ extern char *SPI_getrelname(Relation rel);
 extern void *SPI_palloc(Size size);
 extern void *SPI_repalloc(void *pointer, Size size);
 extern void SPI_pfree(void *pointer);
+extern void SPI_freetuple(HeapTuple pointer);
 
 #endif  /* SPI_H */
index 0904d01d1f41a24757f91c1e57db5fc97d42be1b..44172452d6c35f3fa2938957c749ab9823230c97 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.34 1999/10/22 02:08:37 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.35 1999/12/16 22:20:03 wieck Exp $
  */
 
 #include <float.h>                             /* faked on sunos */
@@ -608,7 +608,7 @@ ttdummy()
 
                tmptuple = SPI_copytuple(trigtuple);
                rettuple = SPI_modifytuple(rel, tmptuple, 1, &(attnum[1]), &newoff, NULL);
-               SPI_pfree(tmptuple);
+               SPI_freetuple(tmptuple);
        }
        else
 /* DELETE */