Some changes to prepare for LONG attributes.

Jan
This commit is contained in:
Jan Wieck 1999-12-16 22:20:03 +00:00
parent 5ca971a18a
commit 397e9b32a3
43 changed files with 235 additions and 115 deletions

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* The old interface functions have been converted to macros * 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 = (HeapTuple) palloc(HEAPTUPLESIZE + tuple->t_len);
newTuple->t_len = tuple->t_len; newTuple->t_len = tuple->t_len;
newTuple->t_self = tuple->t_self; newTuple->t_self = tuple->t_self;
newTuple->t_datamcxt = CurrentMemoryContext;
newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE); newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE);
memmove((char *) newTuple->t_data, memmove((char *) newTuple->t_data,
(char *) tuple->t_data, (int) tuple->t_len); (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_len = src->t_len;
dest->t_self = src->t_self; dest->t_self = src->t_self;
dest->t_datamcxt = CurrentMemoryContext;
dest->t_data = (HeapTupleHeader) palloc(src->t_len); dest->t_data = (HeapTupleHeader) palloc(src->t_len);
memmove((char *) dest->t_data, memmove((char *) dest->t_data,
(char *) src->t_data, (int) src->t_len); (char *) src->t_data, (int) src->t_len);
@ -682,6 +684,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
len += ComputeDataSize(tupleDescriptor, value, nulls); len += ComputeDataSize(tupleDescriptor, value, nulls);
tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len); tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len);
tuple->t_datamcxt = CurrentMemoryContext;
td = tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE); td = tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
MemSet((char *) td, 0, (int) len); MemSet((char *) td, 0, (int) len);
@ -792,6 +795,27 @@ heap_modifytuple(HeapTuple tuple,
return newTuple; 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 * other misc functions
* ---------------------------------------------------------------- * ----------------------------------------------------------------
@ -814,6 +838,7 @@ heap_addheader(uint32 natts, /* max domain index */
hoff = len = MAXALIGN(len); /* be conservative */ hoff = len = MAXALIGN(len); /* be conservative */
len += structlen; len += structlen;
tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len); tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len);
tuple->t_datamcxt = CurrentMemoryContext;
td = tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE); td = tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
MemSet((char *) td, 0, (int) len); MemSet((char *) td, 0, (int) len);

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * INTERFACE ROUTINES
@ -117,6 +117,8 @@ initscan(HeapScanDesc scan,
* relation is empty * 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_ntup.t_data = scan->rs_ctup.t_data =
scan->rs_ptup.t_data = NULL; scan->rs_ptup.t_data = NULL;
scan->rs_nbuf = scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer; scan->rs_nbuf = scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
@ -127,8 +129,10 @@ initscan(HeapScanDesc scan,
* reverse 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_ntup.t_data = scan->rs_ctup.t_data = NULL;
scan->rs_nbuf = scan->rs_cbuf = InvalidBuffer; scan->rs_nbuf = scan->rs_cbuf = InvalidBuffer;
scan->rs_ptup.t_datamcxt = NULL;
scan->rs_ptup.t_data = NULL; scan->rs_ptup.t_data = NULL;
scan->rs_pbuf = UnknownBuffer; scan->rs_pbuf = UnknownBuffer;
} }
@ -138,8 +142,10 @@ initscan(HeapScanDesc scan,
* forward 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_ctup.t_data = scan->rs_ptup.t_data = NULL;
scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer; scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
scan->rs_ntup.t_datamcxt = NULL;
scan->rs_ntup.t_data = NULL; scan->rs_ntup.t_data = NULL;
scan->rs_nbuf = UnknownBuffer; scan->rs_nbuf = UnknownBuffer;
} /* invalid too */ } /* invalid too */
@ -272,6 +278,7 @@ heapgettup(Relation relation,
*/ */
if (!(pages = relation->rd_nblocks)) if (!(pages = relation->rd_nblocks))
{ {
tuple->t_datamcxt = NULL;
tuple->t_data = NULL; tuple->t_data = NULL;
return; return;
} }
@ -290,6 +297,7 @@ heapgettup(Relation relation,
if (ItemPointerIsValid(tid) == false) if (ItemPointerIsValid(tid) == false)
{ {
*buffer = InvalidBuffer; *buffer = InvalidBuffer;
tuple->t_datamcxt = NULL;
tuple->t_data = NULL; tuple->t_data = NULL;
return; return;
} }
@ -306,6 +314,7 @@ heapgettup(Relation relation,
lineoff = ItemPointerGetOffsetNumber(tid); lineoff = ItemPointerGetOffsetNumber(tid);
lpp = PageGetItemId(dp, lineoff); lpp = PageGetItemId(dp, lineoff);
tuple->t_datamcxt = NULL;
tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp); tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
tuple->t_len = ItemIdGetLength(lpp); tuple->t_len = ItemIdGetLength(lpp);
LockBuffer(*buffer, BUFFER_LOCK_UNLOCK); LockBuffer(*buffer, BUFFER_LOCK_UNLOCK);
@ -376,6 +385,7 @@ heapgettup(Relation relation,
if (page >= pages) if (page >= pages)
{ {
*buffer = InvalidBuffer; *buffer = InvalidBuffer;
tuple->t_datamcxt = NULL;
tuple->t_data = NULL; tuple->t_data = NULL;
return; return;
} }
@ -415,6 +425,7 @@ heapgettup(Relation relation,
{ {
if (ItemIdIsUsed(lpp)) if (ItemIdIsUsed(lpp))
{ {
tuple->t_datamcxt = NULL;
tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp); tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
tuple->t_len = ItemIdGetLength(lpp); tuple->t_len = ItemIdGetLength(lpp);
ItemPointerSet(&(tuple->t_self), page, lineoff); ItemPointerSet(&(tuple->t_self), page, lineoff);
@ -466,6 +477,7 @@ heapgettup(Relation relation,
if (BufferIsValid(*buffer)) if (BufferIsValid(*buffer))
ReleaseBuffer(*buffer); ReleaseBuffer(*buffer);
*buffer = InvalidBuffer; *buffer = InvalidBuffer;
tuple->t_datamcxt = NULL;
tuple->t_data = NULL; tuple->t_data = NULL;
return; return;
} }
@ -836,6 +848,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
{ {
if (BufferIsValid(scan->rs_nbuf)) if (BufferIsValid(scan->rs_nbuf))
ReleaseBuffer(scan->rs_nbuf); ReleaseBuffer(scan->rs_nbuf);
scan->rs_ntup.t_datamcxt = NULL;
scan->rs_ntup.t_data = NULL; scan->rs_ntup.t_data = NULL;
scan->rs_nbuf = UnknownBuffer; scan->rs_nbuf = UnknownBuffer;
return NULL; return NULL;
@ -892,10 +905,12 @@ heap_getnext(HeapScanDesc scandesc, int backw)
{ {
if (BufferIsValid(scan->rs_pbuf)) if (BufferIsValid(scan->rs_pbuf))
ReleaseBuffer(scan->rs_pbuf); ReleaseBuffer(scan->rs_pbuf);
scan->rs_ptup.t_datamcxt = NULL;
scan->rs_ptup.t_data = NULL; scan->rs_ptup.t_data = NULL;
scan->rs_pbuf = InvalidBuffer; scan->rs_pbuf = InvalidBuffer;
if (BufferIsValid(scan->rs_nbuf)) if (BufferIsValid(scan->rs_nbuf))
ReleaseBuffer(scan->rs_nbuf); ReleaseBuffer(scan->rs_nbuf);
scan->rs_ntup.t_datamcxt = NULL;
scan->rs_ntup.t_data = NULL; scan->rs_ntup.t_data = NULL;
scan->rs_nbuf = InvalidBuffer; scan->rs_nbuf = InvalidBuffer;
return NULL; return NULL;
@ -903,6 +918,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
if (BufferIsValid(scan->rs_pbuf)) if (BufferIsValid(scan->rs_pbuf))
ReleaseBuffer(scan->rs_pbuf); ReleaseBuffer(scan->rs_pbuf);
scan->rs_ptup.t_datamcxt = NULL;
scan->rs_ptup.t_data = NULL; scan->rs_ptup.t_data = NULL;
scan->rs_pbuf = UnknownBuffer; scan->rs_pbuf = UnknownBuffer;
@ -918,6 +934,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
{ {
if (BufferIsValid(scan->rs_pbuf)) if (BufferIsValid(scan->rs_pbuf))
ReleaseBuffer(scan->rs_pbuf); ReleaseBuffer(scan->rs_pbuf);
scan->rs_ptup.t_datamcxt = NULL;
scan->rs_ptup.t_data = NULL; scan->rs_ptup.t_data = NULL;
scan->rs_pbuf = UnknownBuffer; scan->rs_pbuf = UnknownBuffer;
HEAPDEBUG_3; /* heap_getnext returns NULL at end */ HEAPDEBUG_3; /* heap_getnext returns NULL at end */
@ -976,10 +993,12 @@ heap_getnext(HeapScanDesc scandesc, int backw)
{ {
if (BufferIsValid(scan->rs_nbuf)) if (BufferIsValid(scan->rs_nbuf))
ReleaseBuffer(scan->rs_nbuf); ReleaseBuffer(scan->rs_nbuf);
scan->rs_ntup.t_datamcxt = NULL;
scan->rs_ntup.t_data = NULL; scan->rs_ntup.t_data = NULL;
scan->rs_nbuf = InvalidBuffer; scan->rs_nbuf = InvalidBuffer;
if (BufferIsValid(scan->rs_pbuf)) if (BufferIsValid(scan->rs_pbuf))
ReleaseBuffer(scan->rs_pbuf); ReleaseBuffer(scan->rs_pbuf);
scan->rs_ptup.t_datamcxt = NULL;
scan->rs_ptup.t_data = NULL; scan->rs_ptup.t_data = NULL;
scan->rs_pbuf = InvalidBuffer; scan->rs_pbuf = InvalidBuffer;
HEAPDEBUG_6; /* heap_getnext returning EOS */ HEAPDEBUG_6; /* heap_getnext returning EOS */
@ -988,6 +1007,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
if (BufferIsValid(scan->rs_nbuf)) if (BufferIsValid(scan->rs_nbuf))
ReleaseBuffer(scan->rs_nbuf); ReleaseBuffer(scan->rs_nbuf);
scan->rs_ntup.t_datamcxt = NULL;
scan->rs_ntup.t_data = NULL; scan->rs_ntup.t_data = NULL;
scan->rs_nbuf = UnknownBuffer; scan->rs_nbuf = UnknownBuffer;
} }
@ -1066,10 +1086,12 @@ heap_fetch(Relation relation,
{ {
ReleaseBuffer(buffer); ReleaseBuffer(buffer);
*userbuf = InvalidBuffer; *userbuf = InvalidBuffer;
tuple->t_datamcxt = NULL;
tuple->t_data = NULL; tuple->t_data = NULL;
return; return;
} }
tuple->t_datamcxt = NULL;
tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp); tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
tuple->t_len = ItemIdGetLength(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); t_data = tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
tp.t_len = ItemIdGetLength(lp); tp.t_len = ItemIdGetLength(lp);
tp.t_self = *tid; tp.t_self = *tid;
@ -1270,6 +1293,7 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
dp = (PageHeader) BufferGetPage(buffer); dp = (PageHeader) BufferGetPage(buffer);
lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid)); lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid));
tp.t_datamcxt = NULL;
tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp); tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
tp.t_len = ItemIdGetLength(lp); tp.t_len = ItemIdGetLength(lp);
tp.t_self = *tid; tp.t_self = *tid;
@ -1365,6 +1389,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
dp = (PageHeader) BufferGetPage(buffer); dp = (PageHeader) BufferGetPage(buffer);
lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(otid)); lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(otid));
oldtup.t_datamcxt = NULL;
oldtup.t_data = (HeapTupleHeader) PageGetItem(dp, lp); oldtup.t_data = (HeapTupleHeader) PageGetItem(dp, lp);
oldtup.t_len = ItemIdGetLength(lp); oldtup.t_len = ItemIdGetLength(lp);
oldtup.t_self = *otid; oldtup.t_self = *otid;
@ -1488,6 +1513,7 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
dp = (PageHeader) BufferGetPage(*buffer); dp = (PageHeader) BufferGetPage(*buffer);
lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid)); lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(tid));
tuple->t_datamcxt = NULL;
tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp); tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
tuple->t_len = ItemIdGetLength(lp); tuple->t_len = ItemIdGetLength(lp);
@ -1665,10 +1691,14 @@ heap_restrpos(HeapScanDesc scan)
scan->rs_nbuf = InvalidBuffer; scan->rs_nbuf = InvalidBuffer;
if (!ItemPointerIsValid(&scan->rs_mptid)) if (!ItemPointerIsValid(&scan->rs_mptid))
{
scan->rs_ptup.t_datamcxt = NULL;
scan->rs_ptup.t_data = NULL; scan->rs_ptup.t_data = NULL;
}
else else
{ {
scan->rs_ptup.t_self = scan->rs_mptid; scan->rs_ptup.t_self = scan->rs_mptid;
scan->rs_ptup.t_datamcxt = NULL;
scan->rs_ptup.t_data = (HeapTupleHeader) 0x1; /* for heapgettup */ scan->rs_ptup.t_data = (HeapTupleHeader) 0x1; /* for heapgettup */
heapgettup(scan->rs_rd, heapgettup(scan->rs_rd,
&(scan->rs_ptup), &(scan->rs_ptup),
@ -1680,10 +1710,14 @@ heap_restrpos(HeapScanDesc scan)
} }
if (!ItemPointerIsValid(&scan->rs_mctid)) if (!ItemPointerIsValid(&scan->rs_mctid))
{
scan->rs_ctup.t_datamcxt = NULL;
scan->rs_ctup.t_data = NULL; scan->rs_ctup.t_data = NULL;
}
else else
{ {
scan->rs_ctup.t_self = scan->rs_mctid; scan->rs_ctup.t_self = scan->rs_mctid;
scan->rs_ctup.t_datamcxt = NULL;
scan->rs_ctup.t_data = (HeapTupleHeader) 0x1; /* for heapgettup */ scan->rs_ctup.t_data = (HeapTupleHeader) 0x1; /* for heapgettup */
heapgettup(scan->rs_rd, heapgettup(scan->rs_rd,
&(scan->rs_ctup), &(scan->rs_ctup),
@ -1695,9 +1729,13 @@ heap_restrpos(HeapScanDesc scan)
} }
if (!ItemPointerIsValid(&scan->rs_mntid)) if (!ItemPointerIsValid(&scan->rs_mntid))
{
scan->rs_ntup.t_datamcxt = NULL;
scan->rs_ntup.t_data = NULL; scan->rs_ntup.t_data = NULL;
}
else else
{ {
scan->rs_ntup.t_datamcxt = NULL;
scan->rs_ntup.t_self = scan->rs_mntid; scan->rs_ntup.t_self = scan->rs_mntid;
scan->rs_ntup.t_data = (HeapTupleHeader) 0x1; /* for heapgettup */ scan->rs_ntup.t_data = (HeapTupleHeader) 0x1; /* for heapgettup */
heapgettup(scan->rs_rd, heapgettup(scan->rs_rd,

View File

@ -7,7 +7,7 @@
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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) if (objectid != (Oid) 0)
tuple->t_data->t_oid = objectid; tuple->t_data->t_oid = objectid;
heap_insert(reldesc, tuple); heap_insert(reldesc, tuple);
pfree(tuple); heap_freetuple(tuple);
if (DebugMode) if (DebugMode)
{ {
printf("End InsertOneTuple, objectid=%u\n", objectid); printf("End InsertOneTuple, objectid=%u\n", objectid);

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * INTERFACE ROUTINES
@ -608,7 +608,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
if (hasindex) if (hasindex)
CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup); CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup);
pfree(tup); heap_freetuple(tup);
dpp++; dpp++;
} }
@ -631,7 +631,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
if (hasindex) if (hasindex)
CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup); CatalogIndexInsert(idescs, Num_pg_attr_indices, rel, tup);
pfree(tup); heap_freetuple(tup);
dpp++; dpp++;
} }
@ -727,7 +727,7 @@ AddNewRelationTuple(Relation pg_class_desc,
CatalogCloseIndices(Num_pg_class_indices, idescs); 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); heap_delete(pg_class_desc, &tup->t_self, NULL);
pfree(tup); heap_freetuple(tup);
heap_close(pg_class_desc, RowExclusiveLock); heap_close(pg_class_desc, RowExclusiveLock);
} }
@ -1314,7 +1314,7 @@ DeleteAttributeTuples(Relation rel)
DeleteComments(tup->t_data->t_oid); DeleteComments(tup->t_data->t_oid);
heap_delete(pg_attribute_desc, &tup->t_self, NULL); 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_adbin - 1]));
pfree(DatumGetPointer(values[Anum_pg_attrdef_adsrc - 1])); pfree(DatumGetPointer(values[Anum_pg_attrdef_adsrc - 1]));
pfree(tuple); heap_freetuple(tuple);
pfree(adsrc); pfree(adsrc);
if (! updatePgAttribute) if (! updatePgAttribute)
@ -1778,7 +1778,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin,
CatalogCloseIndices(Num_pg_attr_indices, attridescs); CatalogCloseIndices(Num_pg_attr_indices, attridescs);
} }
heap_close(attrrel, RowExclusiveLock); 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_rcname - 1]));
pfree(DatumGetPointer(values[Anum_pg_relcheck_rcbin - 1])); pfree(DatumGetPointer(values[Anum_pg_relcheck_rcbin - 1]));
pfree(DatumGetPointer(values[Anum_pg_relcheck_rcsrc - 1])); pfree(DatumGetPointer(values[Anum_pg_relcheck_rcsrc - 1]));
pfree(tuple); heap_freetuple(tuple);
pfree(ccsrc); pfree(ccsrc);
} }
@ -2101,7 +2101,7 @@ AddRelationRawConstraints(Relation rel,
CatalogCloseIndices(Num_pg_class_indices, relidescs); CatalogCloseIndices(Num_pg_class_indices, relidescs);
heap_close(relrel, RowExclusiveLock); heap_close(relrel, RowExclusiveLock);
pfree(reltup); heap_freetuple(reltup);
/* /*
* Force rebuild of our own relcache entry, otherwise subsequent commands * Force rebuild of our own relcache entry, otherwise subsequent commands

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * INTERFACE ROUTINES
@ -489,7 +489,7 @@ UpdateRelationRelation(Relation indexRelation, char *temp_relname)
} }
tupleOid = tuple->t_data->t_oid; tupleOid = tuple->t_data->t_oid;
pfree(tuple); heap_freetuple(tuple);
heap_close(pg_class, RowExclusiveLock); heap_close(pg_class, RowExclusiveLock);
return tupleOid; return tupleOid;
@ -581,7 +581,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
value, value,
nullv, nullv,
replace); replace);
pfree(init_tuple); heap_freetuple(init_tuple);
heap_insert(pg_attribute, cur_tuple); heap_insert(pg_attribute, cur_tuple);
if (hasind) if (hasind)
@ -611,7 +611,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
value, value,
nullv, nullv,
replace); replace);
pfree(cur_tuple); heap_freetuple(cur_tuple);
heap_insert(pg_attribute, new_tuple); heap_insert(pg_attribute, new_tuple);
if (hasind) if (hasind)
@ -626,7 +626,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
} }
if (cur_tuple) if (cur_tuple)
pfree(cur_tuple); heap_freetuple(cur_tuple);
heap_close(pg_attribute, RowExclusiveLock); heap_close(pg_attribute, RowExclusiveLock);
if (hasind) if (hasind)
CatalogCloseIndices(Num_pg_attr_indices, idescs); CatalogCloseIndices(Num_pg_attr_indices, idescs);
@ -768,7 +768,7 @@ UpdateIndexRelation(Oid indexoid,
heap_close(pg_index, RowExclusiveLock); heap_close(pg_index, RowExclusiveLock);
pfree(predText); pfree(predText);
pfree(indexForm); 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); heap_update(pg_index, &newtup->t_self, newtup, NULL);
pfree(newtup); heap_freetuple(newtup);
heap_close(pg_index, RowExclusiveLock); heap_close(pg_index, RowExclusiveLock);
pfree(predText); pfree(predText);
} }
@ -1170,7 +1170,7 @@ index_drop(Oid indexId)
Assert(HeapTupleIsValid(tuple)); Assert(HeapTupleIsValid(tuple));
heap_delete(relationRelation, &tuple->t_self, NULL); heap_delete(relationRelation, &tuple->t_self, NULL);
pfree(tuple); heap_freetuple(tuple);
heap_close(relationRelation, RowExclusiveLock); heap_close(relationRelation, RowExclusiveLock);
/* ---------------- /* ----------------
@ -1187,7 +1187,7 @@ index_drop(Oid indexId)
0, 0))) 0, 0)))
{ {
heap_delete(attributeRelation, &tuple->t_self, NULL); heap_delete(attributeRelation, &tuple->t_self, NULL);
pfree(tuple); heap_freetuple(tuple);
attnum++; attnum++;
} }
heap_close(attributeRelation, RowExclusiveLock); heap_close(attributeRelation, RowExclusiveLock);
@ -1204,7 +1204,7 @@ index_drop(Oid indexId)
Assert(HeapTupleIsValid(tuple)); Assert(HeapTupleIsValid(tuple));
heap_delete(indexRelation, &tuple->t_self, NULL); heap_delete(indexRelation, &tuple->t_self, NULL);
pfree(tuple); heap_freetuple(tuple);
heap_close(indexRelation, RowExclusiveLock); 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); CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
CatalogIndexInsert(idescs, Num_pg_class_indices, pg_class, newtup); CatalogIndexInsert(idescs, Num_pg_class_indices, pg_class, newtup);
CatalogCloseIndices(Num_pg_class_indices, idescs); CatalogCloseIndices(Num_pg_class_indices, idescs);
pfree(newtup); heap_freetuple(newtup);
} }
if (!IsBootstrapProcessingMode()) if (!IsBootstrapProcessingMode())
pfree(tuple); heap_freetuple(tuple);
else else
heap_endscan(pg_class_scan); heap_endscan(pg_class_scan);

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) if (indexRes)
pfree(indexRes); pfree(indexRes);
pfree(index_tup); heap_freetuple(index_tup);
} }
} }
@ -248,6 +248,7 @@ CatalogIndexFetchTuple(Relation heapRelation,
Buffer buffer; Buffer buffer;
sd = index_beginscan(idesc, false, num_keys, skey); sd = index_beginscan(idesc, false, num_keys, skey);
tuple.t_datamcxt = CurrentMemoryContext;
tuple.t_data = NULL; tuple.t_data = NULL;
while ((indexRes = index_getnext(sd, ForwardScanDirection))) while ((indexRes = index_getnext(sd, ForwardScanDirection)))
{ {

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* these routines moved here from commands/define.c and somewhat cleaned up. * 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 * free the tuple and return the operator oid
* ---------------- * ----------------
*/ */
pfree(tup); heap_freetuple(tup);
return operatorObjectId; return operatorObjectId;
} }

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * free the tuple and return the type-oid
* ---------------- * ----------------
*/ */
pfree(tup); heap_freetuple(tup);
return typoid; return typoid;
} }
@ -551,7 +551,7 @@ TypeRename(char *oldTypeName, char *newTypeName)
0, 0, 0); 0, 0, 0);
if (HeapTupleIsValid(newtup)) if (HeapTupleIsValid(newtup))
{ {
pfree(oldtup); heap_freetuple(oldtup);
heap_close(pg_type_desc, RowExclusiveLock); heap_close(pg_type_desc, RowExclusiveLock);
elog(ERROR, "TypeRename: type %s already defined", newTypeName); 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); CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, oldtup);
CatalogCloseIndices(Num_pg_type_indices, idescs); CatalogCloseIndices(Num_pg_type_indices, idescs);
pfree(oldtup); heap_freetuple(oldtup);
heap_close(pg_type_desc, RowExclusiveLock); heap_close(pg_type_desc, RowExclusiveLock);
} }

View File

@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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; tupDesc = lRel->rd_att;
newtup = heap_formtuple(tupDesc, values, nulls); newtup = heap_formtuple(tupDesc, values, nulls);
heap_insert(lRel, newtup); heap_insert(lRel, newtup);
pfree(newtup); heap_freetuple(newtup);
heap_close(lRel, AccessExclusiveLock); heap_close(lRel, AccessExclusiveLock);

View File

@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * 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_self = ScanResult->heap_iptr;
LocalHeapTuple.t_datamcxt = NULL;
LocalHeapTuple.t_data = NULL;
heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer); heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer);
OIDNewHeapInsert = heap_insert(LocalNewHeap, &LocalHeapTuple); OIDNewHeapInsert = heap_insert(LocalNewHeap, &LocalHeapTuple);
pfree(ScanResult); pfree(ScanResult);

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* The PortalExecutorHeapMemory crap needs to be eliminated * The PortalExecutorHeapMemory crap needs to be eliminated
@ -481,7 +481,7 @@ PerformAddAttribute(char *relationName,
CatalogIndexInsert(ridescs, Num_pg_class_indices, rel, reltup); CatalogIndexInsert(ridescs, Num_pg_class_indices, rel, reltup);
CatalogCloseIndices(Num_pg_class_indices, ridescs); CatalogCloseIndices(Num_pg_class_indices, ridescs);
pfree(reltup); heap_freetuple(reltup);
heap_close(rel, RowExclusiveLock); heap_close(rel, RowExclusiveLock);
} }

View File

@ -190,7 +190,7 @@ void CreateComments(Oid oid, char *comment) {
desctuple); desctuple);
CatalogCloseIndices(Num_pg_description_indices, idescs); CatalogCloseIndices(Num_pg_description_indices, idescs);
} }
pfree(desctuple); heap_freetuple(desctuple);
} }

View File

@ -6,7 +6,7 @@
* *
* *
* IDENTIFICATION * 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; skip_tuple = true;
else if (newtuple != tuple) /* modified by Trigger(s) */ else if (newtuple != tuple) /* modified by Trigger(s) */
{ {
pfree(tuple); heap_freetuple(tuple);
tuple = newtuple; tuple = newtuple;
} }
} }
@ -905,7 +905,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim, char *null
nulls[i] = ' '; nulls[i] = ' ';
} }
pfree(tuple); heap_freetuple(tuple);
tuples_read++; tuples_read++;
if (!reading_to_eof && ntuples == tuples_read) if (!reading_to_eof && ntuples == tuples_read)

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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); CatalogCloseIndices(Num_pg_inherits_indices, idescs);
} }
pfree(tuple); heap_freetuple(tuple);
seqNumber += 1; seqNumber += 1;
} }
@ -620,7 +620,7 @@ again:
tuple = heap_formtuple(desc, datum, nullarr); tuple = heap_formtuple(desc, datum, nullarr);
heap_insert(relation, tuple); heap_insert(relation, tuple);
pfree(tuple); heap_freetuple(tuple);
seqNumber += 1; seqNumber += 1;
} }

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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); attribute->class);
} }
*classOidP++ = tuple->t_data->t_oid; *classOidP++ = tuple->t_data->t_oid;
pfree(atttuple); heap_freetuple(atttuple);
} }
} }

View File

@ -183,6 +183,6 @@ DropProceduralLanguage(DropPLangStmt *stmt)
heap_delete(rel, &langTup->t_self, NULL); heap_delete(rel, &langTup->t_self, NULL);
pfree(langTup); heap_freetuple(langTup);
heap_close(rel, RowExclusiveLock); heap_close(rel, RowExclusiveLock);
} }

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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); typeName2);
} }
} }
pfree(tup); heap_freetuple(tup);
heap_close(relation, RowExclusiveLock); heap_close(relation, RowExclusiveLock);
} }

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 */ /* should not already exist */
if (HeapTupleIsValid(newatttup)) if (HeapTupleIsValid(newatttup))
{ {
pfree(oldatttup); heap_freetuple(oldatttup);
elog(ERROR, "renameatt: attribute \"%s\" exists", newattname); elog(ERROR, "renameatt: attribute \"%s\" exists", newattname);
} }
@ -164,7 +164,7 @@ renameatt(char *relname,
CatalogCloseIndices(Num_pg_attr_indices, irelations); CatalogCloseIndices(Num_pg_attr_indices, irelations);
} }
pfree(oldatttup); heap_freetuple(oldatttup);
heap_close(attrelation, RowExclusiveLock); heap_close(attrelation, RowExclusiveLock);
} }

View File

@ -235,7 +235,7 @@ CreateTrigger(CreateTrigStmt *stmt)
CatalogOpenIndices(Num_pg_trigger_indices, Name_pg_trigger_indices, idescs); CatalogOpenIndices(Num_pg_trigger_indices, Name_pg_trigger_indices, idescs);
CatalogIndexInsert(idescs, Num_pg_trigger_indices, tgrel, tuple); CatalogIndexInsert(idescs, Num_pg_trigger_indices, tgrel, tuple);
CatalogCloseIndices(Num_pg_trigger_indices, idescs); CatalogCloseIndices(Num_pg_trigger_indices, idescs);
pfree(tuple); heap_freetuple(tuple);
heap_close(tgrel, RowExclusiveLock); heap_close(tgrel, RowExclusiveLock);
pfree(DatumGetPointer(values[Anum_pg_trigger_tgname - 1])); 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); CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple); CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple);
CatalogCloseIndices(Num_pg_class_indices, ridescs); CatalogCloseIndices(Num_pg_class_indices, ridescs);
pfree(tuple); heap_freetuple(tuple);
heap_close(pgrel, RowExclusiveLock); heap_close(pgrel, RowExclusiveLock);
CommandCounterIncrement(); CommandCounterIncrement();
@ -334,7 +334,7 @@ DropTrigger(DropTrigStmt *stmt)
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs); CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple); CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple);
CatalogCloseIndices(Num_pg_class_indices, ridescs); CatalogCloseIndices(Num_pg_class_indices, ridescs);
pfree(tuple); heap_freetuple(tuple);
heap_close(pgrel, RowExclusiveLock); heap_close(pgrel, RowExclusiveLock);
CommandCounterIncrement(); CommandCounterIncrement();
@ -690,7 +690,7 @@ ExecBRInsertTriggers(Relation rel, HeapTuple trigtuple)
if (newtuple == NULL) if (newtuple == NULL)
break; break;
else if (oldtuple != newtuple && oldtuple != trigtuple) else if (oldtuple != newtuple && oldtuple != trigtuple)
pfree(oldtuple); heap_freetuple(oldtuple);
} }
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
pfree(SaveTriggerData); pfree(SaveTriggerData);
@ -735,11 +735,11 @@ ExecBRDeleteTriggers(EState *estate, ItemPointer tupleid)
if (newtuple == NULL) if (newtuple == NULL)
break; break;
if (newtuple != trigtuple) if (newtuple != trigtuple)
pfree(newtuple); heap_freetuple(newtuple);
} }
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
pfree(SaveTriggerData); pfree(SaveTriggerData);
pfree(trigtuple); heap_freetuple(trigtuple);
return (newtuple == NULL) ? false : true; return (newtuple == NULL) ? false : true;
} }
@ -793,11 +793,11 @@ ExecBRUpdateTriggers(EState *estate, ItemPointer tupleid, HeapTuple newtuple)
if (newtuple == NULL) if (newtuple == NULL)
break; break;
else if (oldtuple != newtuple && oldtuple != intuple) else if (oldtuple != newtuple && oldtuple != intuple)
pfree(oldtuple); heap_freetuple(oldtuple);
} }
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
pfree(SaveTriggerData); pfree(SaveTriggerData);
pfree(trigtuple); heap_freetuple(trigtuple);
return newtuple; return newtuple;
} }
@ -886,6 +886,7 @@ ltrmark:;
Assert(ItemIdIsUsed(lp)); Assert(ItemIdIsUsed(lp));
tuple.t_datamcxt = NULL;
tuple.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp); tuple.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
tuple.t_len = ItemIdGetLength(lp); tuple.t_len = ItemIdGetLength(lp);
tuple.t_self = *tid; tuple.t_self = *tid;
@ -1150,7 +1151,7 @@ deferredTriggerExecute(DeferredTriggerEvent event, int itemno)
rettuple = ExecCallTriggerFunc(SaveTriggerData.tg_trigger); rettuple = ExecCallTriggerFunc(SaveTriggerData.tg_trigger);
CurrentTriggerData = NULL; CurrentTriggerData = NULL;
if (rettuple != NULL && rettuple != &oldtuple && rettuple != &newtuple) if (rettuple != NULL && rettuple != &oldtuple && rettuple != &newtuple)
pfree(rettuple); heap_freetuple(rettuple);
/* ---------- /* ----------
* Might have been a referential integrity constraint trigger. * Might have been a referential integrity constraint trigger.

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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; continue;
} }
tuple.t_datamcxt = NULL;
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid); tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
tuple.t_len = ItemIdGetLength(itemid); tuple.t_len = ItemIdGetLength(itemid);
ItemPointerSet(&(tuple.t_self), blkno, offnum); ItemPointerSet(&(tuple.t_self), blkno, offnum);
@ -1153,6 +1154,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
if (!ItemIdIsUsed(itemid)) if (!ItemIdIsUsed(itemid))
continue; continue;
tuple.t_datamcxt = NULL;
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid); tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
tuple_len = tuple.t_len = ItemIdGetLength(itemid); tuple_len = tuple.t_len = ItemIdGetLength(itemid);
ItemPointerSet(&(tuple.t_self), blkno, offnum); 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"); elog(NOTICE, "Child itemid in update-chain marked as unused - can't continue vc_rpfheap");
break; break;
} }
tp.t_datamcxt = NULL;
tp.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid); tp.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid);
tp.t_self = Ctid; tp.t_self = Ctid;
tlen = tp.t_len = ItemIdGetLength(Citemid); tlen = tp.t_len = ItemIdGetLength(Citemid);
@ -1360,6 +1363,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
ItemPointerGetOffsetNumber(&(tp.t_self))); ItemPointerGetOffsetNumber(&(tp.t_self)));
if (!ItemIdIsUsed(Pitemid)) if (!ItemIdIsUsed(Pitemid))
elog(ERROR, "Parent itemid marked as unused"); elog(ERROR, "Parent itemid marked as unused");
Ptp.t_datamcxt = NULL;
Ptp.t_data = (HeapTupleHeader) PageGetItem(Ppage, Pitemid); Ptp.t_data = (HeapTupleHeader) PageGetItem(Ppage, Pitemid);
Assert(ItemPointerEquals(&(vtld.new_tid), Assert(ItemPointerEquals(&(vtld.new_tid),
&(Ptp.t_data->t_ctid))); &(Ptp.t_data->t_ctid)));
@ -1409,6 +1413,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
continue; continue;
} }
#endif #endif
tp.t_datamcxt = Ptp.t_datamcxt;
tp.t_data = Ptp.t_data; tp.t_data = Ptp.t_data;
tlen = tp.t_len = ItemIdGetLength(Pitemid); tlen = tp.t_len = ItemIdGetLength(Pitemid);
if (freeCbuf) if (freeCbuf)
@ -1437,6 +1442,7 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
Cpage = BufferGetPage(Cbuf); Cpage = BufferGetPage(Cbuf);
Citemid = PageGetItemId(Cpage, Citemid = PageGetItemId(Cpage,
ItemPointerGetOffsetNumber(&(tuple.t_self))); ItemPointerGetOffsetNumber(&(tuple.t_self)));
tuple.t_datamcxt = NULL;
tuple.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid); tuple.t_data = (HeapTupleHeader) PageGetItem(Cpage, Citemid);
tuple_len = tuple.t_len = ItemIdGetLength(Citemid); tuple_len = tuple.t_len = ItemIdGetLength(Citemid);
/* Get page to move in */ /* 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); newitemid = PageGetItemId(ToPage, newoff);
pfree(newtup.t_data); pfree(newtup.t_data);
newtup.t_datamcxt = NULL;
newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid); newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid);
ItemPointerSet(&(newtup.t_self), vtmove[ti].vpd->vpd_blkno, newoff); 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); newitemid = PageGetItemId(ToPage, newoff);
pfree(newtup.t_data); pfree(newtup.t_data);
newtup.t_datamcxt = NULL;
newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid); newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid);
ItemPointerSet(&(newtup.t_data->t_ctid), cur_page->vpd_blkno, newoff); ItemPointerSet(&(newtup.t_data->t_ctid), cur_page->vpd_blkno, newoff);
newtup.t_self = newtup.t_data->t_ctid; 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); itemid = PageGetItemId(page, off);
if (!ItemIdIsUsed(itemid)) if (!ItemIdIsUsed(itemid))
continue; continue;
tuple.t_datamcxt = NULL;
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid); tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
if (tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED) if (tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)
continue; 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); itemid = PageGetItemId(page, newoff);
if (!ItemIdIsUsed(itemid)) if (!ItemIdIsUsed(itemid))
continue; continue;
tuple.t_datamcxt = NULL;
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid); tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)) if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
{ {
@ -1827,6 +1837,7 @@ Elapsed %u/%u sec.",
itemid = PageGetItemId(page, offnum); itemid = PageGetItemId(page, offnum);
if (!ItemIdIsUsed(itemid)) if (!ItemIdIsUsed(itemid))
continue; continue;
tuple.t_datamcxt = NULL;
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid); tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED)) 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 */ /* get the buffer cache tuple */
rtup.t_self = ctup->t_self; rtup.t_self = ctup->t_self;
heap_fetch(rd, SnapshotNow, &rtup, &buffer); heap_fetch(rd, SnapshotNow, &rtup, &buffer);
pfree(ctup); heap_freetuple(ctup);
/* overwrite the existing statistics in the tuple */ /* overwrite the existing statistics in the tuple */
pgcform = (Form_pg_class) GETSTRUCT(&rtup); 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_stacommonval-1]));
pfree(DatumGetPointer(values[Anum_pg_statistic_staloval-1])); pfree(DatumGetPointer(values[Anum_pg_statistic_staloval-1]));
pfree(DatumGetPointer(values[Anum_pg_statistic_stahival-1])); pfree(DatumGetPointer(values[Anum_pg_statistic_stahival-1]));
pfree(stup); heap_freetuple(stup);
} }
} }
} }

View File

@ -14,7 +14,7 @@
* ExecInitTee * ExecInitTee
* ExecEndTee * 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); heap_insert(bufferRel, heapTuple);
if (slot->ttc_buffer != InvalidBuffer) if (slot->ttc_buffer != InvalidBuffer)
pfree(heapTuple); heap_freetuple(heapTuple);
/* /*
* once there is data in the temporary relation, ensure that * once there is data in the temporary relation, ensure that

View File

@ -26,7 +26,7 @@
* *
* *
* IDENTIFICATION * 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) */ if (newtuple != tuple) /* modified by Trigger(s) */
{ {
Assert(slot->ttc_shouldFree); Assert(slot->ttc_shouldFree);
pfree(tuple); heap_freetuple(tuple);
slot->val = tuple = newtuple; slot->val = tuple = newtuple;
} }
} }
@ -1334,7 +1334,7 @@ ExecReplace(TupleTableSlot *slot,
if (newtuple != tuple) /* modified by Trigger(s) */ if (newtuple != tuple) /* modified by Trigger(s) */
{ {
Assert(slot->ttc_shouldFree); Assert(slot->ttc_shouldFree);
pfree(tuple); heap_freetuple(tuple);
slot->val = tuple = newtuple; slot->val = tuple = newtuple;
} }
} }
@ -1472,7 +1472,7 @@ ExecAttrDefault(Relation rel, HeapTuple tuple)
newtuple = heap_modifytuple(tuple, rel, replValue, replNull, repl); newtuple = heap_modifytuple(tuple, rel, replValue, replNull, repl);
pfree(repl); pfree(repl);
pfree(tuple); heap_freetuple(tuple);
pfree(replNull); pfree(replNull);
pfree(replValue); pfree(replValue);
@ -1614,7 +1614,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
/* stop execution */ /* stop execution */
ExecEndNode(epq->plan, epq->plan); ExecEndNode(epq->plan, epq->plan);
epqstate->es_tupleTable->next = 0; 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; epqstate->es_evTuple[epq->rti - 1] = NULL;
/* push current PQ to freePQ stack */ /* push current PQ to freePQ stack */
oldepq->free = epq; oldepq->free = epq;
@ -1689,7 +1689,7 @@ EvalPlanQual(EState *estate, Index rti, ItemPointer tid)
/* free old RTE' tuple */ /* free old RTE' tuple */
if (epqstate->es_evTuple[epq->rti - 1] != NULL) 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; 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. * Nice! We got tuple - now copy it.
*/ */
if (epqstate->es_evTuple[epq->rti - 1] != NULL) 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); epqstate->es_evTuple[epq->rti - 1] = heap_copytuple(&tuple);
ReleaseBuffer(buffer); ReleaseBuffer(buffer);
break; break;
@ -1815,7 +1815,7 @@ lpqnext:;
{ {
ExecEndNode(epq->plan, epq->plan); ExecEndNode(epq->plan, epq->plan);
epqstate->es_tupleTable->next = 0; 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; epqstate->es_evTuple[epq->rti - 1] = NULL;
/* pop old PQ from the stack */ /* pop old PQ from the stack */
oldepq = (evalPlanQual *) epqstate->es_evalPlanQual; oldepq = (evalPlanQual *) epqstate->es_evalPlanQual;

View File

@ -14,7 +14,7 @@
* *
* *
* IDENTIFICATION * 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 $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -120,6 +120,7 @@
#undef ExecStoreTuple #undef ExecStoreTuple
#include "catalog/pg_type.h" #include "catalog/pg_type.h"
#include "access/heapam.h"
static TupleTableSlot *NodeGetResultTupleSlot(Plan *node); static TupleTableSlot *NodeGetResultTupleSlot(Plan *node);
@ -420,7 +421,7 @@ ExecClearTuple(TupleTableSlot *slot) /* slot in which to store tuple */
* ---------------- * ----------------
*/ */
if (slot->ttc_shouldFree && oldtuple != NULL) if (slot->ttc_shouldFree && oldtuple != NULL)
pfree(oldtuple); heap_freetuple(oldtuple);
slot->val = (HeapTuple) NULL; slot->val = (HeapTuple) NULL;

View File

@ -13,7 +13,7 @@
* columns. (ie. tuples from the same group are consecutive) * columns. (ie. tuples from the same group are consecutive)
* *
* IDENTIFICATION * 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))) ExecGetScanType(&grpstate->csstate)))
{ {
grpstate->grp_useFirstTuple = TRUE; grpstate->grp_useFirstTuple = TRUE;
pfree(firsttuple); heap_freetuple(firsttuple);
grpstate->grp_firstTuple = heap_copytuple(outerTuple); grpstate->grp_firstTuple = heap_copytuple(outerTuple);
return NULL; /* signifies the end of the group */ return NULL; /* signifies the end of the group */
@ -242,7 +242,7 @@ ExecGroupOneTuple(Group *node)
/* save outerTuple if we are not done yet */ /* save outerTuple if we are not done yet */
if (!grpstate->grp_done) if (!grpstate->grp_done)
{ {
pfree(firsttuple); heap_freetuple(firsttuple);
grpstate->grp_firstTuple = heap_copytuple(outerTuple); grpstate->grp_firstTuple = heap_copytuple(outerTuple);
} }
@ -341,7 +341,7 @@ ExecEndGroup(Group *node)
ExecClearTuple(grpstate->csstate.css_ScanTupleSlot); ExecClearTuple(grpstate->csstate.css_ScanTupleSlot);
if (grpstate->grp_firstTuple != NULL) if (grpstate->grp_firstTuple != NULL)
{ {
pfree(grpstate->grp_firstTuple); heap_freetuple(grpstate->grp_firstTuple);
grpstate->grp_firstTuple = NULL; grpstate->grp_firstTuple = NULL;
} }
} }
@ -429,7 +429,7 @@ ExecReScanGroup(Group *node, ExprContext *exprCtxt, Plan *parent)
grpstate->grp_done = FALSE; grpstate->grp_done = FALSE;
if (grpstate->grp_firstTuple != NULL) if (grpstate->grp_firstTuple != NULL)
{ {
pfree(grpstate->grp_firstTuple); heap_freetuple(grpstate->grp_firstTuple);
grpstate->grp_firstTuple = NULL; grpstate->grp_firstTuple = NULL;
} }

View File

@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California * 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, memcpy((char *) &hashTuple->htup,
(char *) heapTuple, (char *) heapTuple,
sizeof(hashTuple->htup)); sizeof(hashTuple->htup));
hashTuple->htup.t_datamcxt = hashtable->batchCxt;
hashTuple->htup.t_data = (HeapTupleHeader) hashTuple->htup.t_data = (HeapTupleHeader)
(((char *) hashTuple) + MAXALIGN(sizeof(*hashTuple))); (((char *) hashTuple) + MAXALIGN(sizeof(*hashTuple)));
memcpy((char *) hashTuple->htup.t_data, memcpy((char *) hashTuple->htup.t_data,

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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"); elog(ERROR, "Read from hashjoin temp file failed");
heapTuple = palloc(HEAPTUPLESIZE + htup.t_len); heapTuple = palloc(HEAPTUPLESIZE + htup.t_len);
memcpy((char *) heapTuple, (char *) &htup, sizeof(HeapTupleData)); memcpy((char *) heapTuple, (char *) &htup, sizeof(HeapTupleData));
heapTuple->t_datamcxt = CurrentMemoryContext;
heapTuple->t_data = (HeapTupleHeader) heapTuple->t_data = (HeapTupleHeader)
((char *) heapTuple + HEAPTUPLESIZE); ((char *) heapTuple + HEAPTUPLESIZE);
nread = BufFileRead(file, (void *) heapTuple->t_data, htup.t_len); nread = BufFileRead(file, (void *) heapTuple->t_data, htup.t_len);

View File

@ -6,7 +6,7 @@
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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); tup = heap_copytuple(tup);
if (node->curTuple) if (node->curTuple)
pfree(node->curTuple); heap_freetuple(node->curTuple);
node->curTuple = tup; node->curTuple = tup;
result = heap_getattr(tup, col, tdesc, isNull); result = heap_getattr(tup, col, tdesc, isNull);
/* keep scanning subplan to make sure there's only one tuple */ /* keep scanning subplan to make sure there's only one tuple */
@ -351,7 +351,7 @@ ExecSetParamPlan(SubPlan *node)
*/ */
tup = heap_copytuple(tup); tup = heap_copytuple(tup);
if (node->curTuple) if (node->curTuple)
pfree(node->curTuple); heap_freetuple(node->curTuple);
node->curTuple = tup; node->curTuple = tup;
foreach(lst, node->setParam) foreach(lst, node->setParam)
@ -408,7 +408,7 @@ ExecEndSubPlan(SubPlan *node)
} }
if (node->curTuple) if (node->curTuple)
{ {
pfree(node->curTuple); heap_freetuple(node->curTuple);
node->curTuple = NULL; node->curTuple = NULL;
} }
} }

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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; bool slot_is_valid = false;
itemptr = tidList[tidstate->tss_TidPtr]; itemptr = tidList[tidstate->tss_TidPtr];
tuple->t_datamcxt = NULL;
tuple->t_data = NULL; tuple->t_data = NULL;
if (itemptr) if (itemptr)
{ {

View File

@ -3,7 +3,7 @@
* spi.c * spi.c
* Server Programming Interface * 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; 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 =================== */ /* =================== private functions =================== */
/* /*

View File

@ -7,15 +7,15 @@
* *
* *
* IDENTIFICATION * 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 "postgres.h"
#include "optimizer/planmain.h" #include "optimizer/planmain.h"
#include "access/heapam.h"
/* **************************************************************** /* ****************************************************************
* plannodes.h free functions * plannodes.h free functions
@ -465,7 +465,7 @@ _freeSubPlan(SubPlan *node)
freeObject(node->sublink); freeObject(node->sublink);
if (node->curTuple) if (node->curTuple)
pfree(node->curTuple); heap_freetuple(node->curTuple);
pfree(node); pfree(node);
} }

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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; Buffer buffer;
tuple.t_datamcxt = NULL;
tuple.t_data = NULL;
tuple.t_self = indexRes->heap_iptr; tuple.t_self = indexRes->heap_iptr;
heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer); heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer);
pfree(indexRes); pfree(indexRes);

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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) if (isNull)
{ {
/* XXX strange!!! */ /* XXX strange!!! */
pfree(tuple); heap_freetuple(tuple);
elog(ERROR, "RemoveRewriteRule: internal error; null event target relation!"); elog(ERROR, "RemoveRewriteRule: internal error; null event target relation!");
} }
eventRelationOid = DatumGetObjectId(eventRelationOidDatum); eventRelationOid = DatumGetObjectId(eventRelationOidDatum);
@ -133,7 +133,7 @@ RemoveRewriteRule(char *ruleName)
*/ */
heap_delete(RewriteRelation, &tuple->t_self, NULL); heap_delete(RewriteRelation, &tuple->t_self, NULL);
pfree(tuple); heap_freetuple(tuple);
heap_close(RewriteRelation, RowExclusiveLock); heap_close(RewriteRelation, RowExclusiveLock);
} }

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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); CatalogIndexInsert(idescs, Num_pg_class_indices, relationRelation, tuple);
CatalogCloseIndices(Num_pg_class_indices, idescs); CatalogCloseIndices(Num_pg_class_indices, idescs);
pfree(tuple); heap_freetuple(tuple);
heap_close(relationRelation, RowExclusiveLock); heap_close(relationRelation, RowExclusiveLock);
} }

View File

@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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) if (res == (RetrieveIndexResult) NULL)
{ {
ItemPointerSetInvalid(&(obj_desc->htid)); ItemPointerSetInvalid(&(obj_desc->htid));
tuple->t_datamcxt = NULL;
tuple->t_data = NULL; tuple->t_data = NULL;
return; return;
} }
@ -797,7 +798,7 @@ inv_wrnew(LargeObjectDesc *obj_desc, char *buf, int nbytes)
ntup = inv_newtuple(obj_desc, buffer, page, buf, nwritten); ntup = inv_newtuple(obj_desc, buffer, page, buf, nwritten);
inv_indextup(obj_desc, ntup); inv_indextup(obj_desc, ntup);
pfree(ntup); heap_freetuple(ntup);
/* new tuple is inserted */ /* new tuple is inserted */
WriteBuffer(buffer); WriteBuffer(buffer);
@ -971,7 +972,7 @@ inv_wrold(LargeObjectDesc *obj_desc,
/* index the new tuple */ /* index the new tuple */
inv_indextup(obj_desc, ntup); inv_indextup(obj_desc, ntup);
pfree(ntup); heap_freetuple(ntup);
/* /*
* move the scandesc forward so we don't reread the newly inserted * 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_lower = lower;
ph->pd_upper = upper; ph->pd_upper = upper;
ntup->t_datamcxt = NULL;
ntup->t_data = (HeapTupleHeader) ((char *) page + upper); ntup->t_data = (HeapTupleHeader) ((char *) page + upper);
/* /*

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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); sd = index_beginscan(idesc, false, 1, skey);
while ((indexRes = index_getnext(sd, ForwardScanDirection))) while ((indexRes = index_getnext(sd, ForwardScanDirection)))
{ {
tuple.t_datamcxt = NULL;
tuple.t_data = NULL;
tuple.t_self = indexRes->heap_iptr; tuple.t_self = indexRes->heap_iptr;
heap_fetch(hdesc, SnapshotNow, heap_fetch(hdesc, SnapshotNow,
&tuple, &tuple,

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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", elog(ERROR, "SearchSelfReferences: %s not found in %s",
IndexRelidIndex, RelationRelationName); IndexRelidIndex, RelationRelationName);
indexSelfOid = ntp->t_data->t_oid; indexSelfOid = ntp->t_data->t_oid;
pfree(ntp); heap_freetuple(ntp);
heap_close(rel, AccessShareLock); heap_close(rel, AccessShareLock);
} }
/* Looking for something other than pg_index_indexrelid_index? */ /* Looking for something other than pg_index_indexrelid_index? */

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * and for lock data pointed to by pg_class_tuple
* ------------------- * -------------------
*/ */
pfree(pg_class_tuple); heap_freetuple(pg_class_tuple);
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
@ -1714,6 +1714,7 @@ AttrDefaultFetch(Relation relation)
adrel = heap_openr(AttrDefaultRelationName, AccessShareLock); adrel = heap_openr(AttrDefaultRelationName, AccessShareLock);
irel = index_openr(AttrDefaultIndex); irel = index_openr(AttrDefaultIndex);
sd = index_beginscan(irel, false, 1, &skey); sd = index_beginscan(irel, false, 1, &skey);
tuple.t_datamcxt = NULL;
tuple.t_data = NULL; tuple.t_data = NULL;
for (found = 0;;) for (found = 0;;)
@ -1793,6 +1794,7 @@ RelCheckFetch(Relation relation)
rcrel = heap_openr(RelCheckRelationName, AccessShareLock); rcrel = heap_openr(RelCheckRelationName, AccessShareLock);
irel = index_openr(RelCheckIndex); irel = index_openr(RelCheckIndex);
sd = index_beginscan(irel, false, 1, &skey); sd = index_beginscan(irel, false, 1, &skey);
tuple.t_datamcxt = NULL;
tuple.t_data = NULL; tuple.t_data = NULL;
for (found = 0;;) for (found = 0;;)

View File

@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 */ /* get a pointer to the tuple itself */
offset = (int) ph->pd_linp[i].lp_off; offset = (int) ph->pd_linp[i].lp_off;
tup.t_datamcxt = NULL;
tup.t_data = (HeapTupleHeader) (((char *) pg) + offset); tup.t_data = (HeapTupleHeader) (((char *) pg) + offset);
/* /*

View File

@ -77,7 +77,7 @@
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * 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)); (void*) &tuplen, sizeof(tuplen));
FREEMEM(state, HEAPTUPLESIZE + tuple->t_len); FREEMEM(state, HEAPTUPLESIZE + tuple->t_len);
pfree(tuple); heap_freetuple(tuple);
} }
static void * static void *
@ -1710,6 +1710,7 @@ readtup_heap(Tuplesortstate *state, int tapenum, unsigned int len)
/* reconstruct the HeapTupleData portion */ /* reconstruct the HeapTupleData portion */
tuple->t_len = len - sizeof(unsigned int); tuple->t_len = len - sizeof(unsigned int);
ItemPointerSetInvalid(&(tuple->t_self)); ItemPointerSetInvalid(&(tuple->t_self));
tuple->t_datamcxt = CurrentMemoryContext;
tuple->t_data = (HeapTupleHeader) (((char *) tuple) + HEAPTUPLESIZE); tuple->t_data = (HeapTupleHeader) (((char *) tuple) + HEAPTUPLESIZE);
/* read in the tuple proper */ /* read in the tuple proper */
if (LogicalTapeRead(state->tapeset, tapenum, (void *) tuple->t_data, if (LogicalTapeRead(state->tapeset, tapenum, (void *) tuple->t_data,

View File

@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * 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); Datum *value, char *nulls);
extern HeapTuple heap_modifytuple(HeapTuple tuple, extern HeapTuple heap_modifytuple(HeapTuple tuple,
Relation relation, Datum *replValue, char *replNull, char *repl); Relation relation, Datum *replValue, char *replNull, char *repl);
extern void heap_freetuple(HeapTuple tuple);
HeapTuple heap_addheader(uint32 natts, int structlen, char *structure); HeapTuple heap_addheader(uint32 natts, int structlen, char *structure);
/* in common/heap/stats.c */ /* in common/heap/stats.c */

View File

@ -6,7 +6,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * 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); * updated version of tuple (required by MVCC);
* 3. someday someone let tuple to cross block boundaries - * 3. someday someone let tuple to cross block boundaries -
* he have to add something below... * 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 typedef struct HeapTupleData
{ {
uint32 t_len; /* length of *t_data */ uint32 t_len; /* length of *t_data */
ItemPointerData t_self; /* SelfItemPointer */ ItemPointerData t_self; /* SelfItemPointer */
MemoryContext t_datamcxt; /* */
HeapTupleHeader t_data; /* */ HeapTupleHeader t_data; /* */
} HeapTupleData; } HeapTupleData;

View File

@ -93,5 +93,6 @@ extern char *SPI_getrelname(Relation rel);
extern void *SPI_palloc(Size size); extern void *SPI_palloc(Size size);
extern void *SPI_repalloc(void *pointer, Size size); extern void *SPI_repalloc(void *pointer, Size size);
extern void SPI_pfree(void *pointer); extern void SPI_pfree(void *pointer);
extern void SPI_freetuple(HeapTuple pointer);
#endif /* SPI_H */ #endif /* SPI_H */

View 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 */ #include <float.h> /* faked on sunos */
@ -608,7 +608,7 @@ ttdummy()
tmptuple = SPI_copytuple(trigtuple); tmptuple = SPI_copytuple(trigtuple);
rettuple = SPI_modifytuple(rel, tmptuple, 1, &(attnum[1]), &newoff, NULL); rettuple = SPI_modifytuple(rel, tmptuple, 1, &(attnum[1]), &newoff, NULL);
SPI_pfree(tmptuple); SPI_freetuple(tmptuple);
} }
else else
/* DELETE */ /* DELETE */