diff --git a/src/backend/Makefile b/src/backend/Makefile
index 453484286254d42be284c2265a6bd96bb90f813d..9410ab8ce37f064474fe4ff8aeafdc54db3dd2e2 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -34,7 +34,7 @@
 #
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.33 1998/04/27 04:04:05 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.34 1998/11/27 19:51:27 vadim Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -86,6 +86,9 @@ catalog/global1.description catalog/local1_template1.description:
 postgres.o: $(OBJS)
 	$(CC) -r -o postgres.o $(OBJS) $(LDFLAGS)
 
+fast:
+	$(CC) -r -o postgres.o $(OBJS) $(LDFLAGS)
+
 
 ############################################################################
 # The following targets are specified in make commands that appear in the
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c
index 1659484434b21d4dc614d9b9f0238310187ab72e..3d0b684306df0098e815dbaad60f9eb8e681a309 100644
--- a/src/backend/access/common/heaptuple.c
+++ b/src/backend/access/common/heaptuple.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.45 1998/10/08 18:29:10 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.46 1998/11/27 19:51:27 vadim Exp $
  *
  * NOTES
  *	  The old interface functions have been converted to macros
@@ -36,12 +36,12 @@
 /* Used by heap_getattr() macro, for speed */
 long		heap_sysoffset[] = {
 /* Only the first one is pass-by-ref, and is handled specially in the macro */
-	offsetof(HeapTupleData, t_ctid),
-	offsetof(HeapTupleData, t_oid),
-	offsetof(HeapTupleData, t_xmin),
-	offsetof(HeapTupleData, t_cmin),
-	offsetof(HeapTupleData, t_xmax),
-	offsetof(HeapTupleData, t_cmax)
+	offsetof(HeapTupleHeaderData, t_ctid),
+	offsetof(HeapTupleHeaderData, t_oid),
+	offsetof(HeapTupleHeaderData, t_xmin),
+	offsetof(HeapTupleHeaderData, t_cmin),
+	offsetof(HeapTupleHeaderData, t_xmax),
+	offsetof(HeapTupleHeaderData, t_cmax)
 };
 
 /* ----------------------------------------------------------------
@@ -167,14 +167,14 @@ DataFill(char *data,
 int
 heap_attisnull(HeapTuple tup, int attnum)
 {
-	if (attnum > (int) tup->t_natts)
+	if (attnum > (int) tup->t_data->t_natts)
 		return 1;
 
 	if (HeapTupleNoNulls(tup))
 		return 0;
 
 	if (attnum > 0)
-		return att_isnull(attnum - 1, tup->t_bits);
+		return att_isnull(attnum - 1, tup->t_data->t_bits);
 	else
 		switch (attnum)
 		{
@@ -210,7 +210,7 @@ heap_attisnull(HeapTuple tup, int attnum)
 int
 heap_sysattrlen(AttrNumber attno)
 {
-	HeapTupleData *f = NULL;
+	HeapTupleHeader	f = NULL;
 
 	switch (attno)
 	{
@@ -323,15 +323,16 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
  * ----------------
  */
 Datum
-nocachegetattr(HeapTuple tup,
+nocachegetattr(HeapTuple tuple,
 			   int attnum,
 			   TupleDesc tupleDesc,
 			   bool *isnull)
 {
-	char	   *tp;				/* ptr to att in tuple */
-	bits8	   *bp = tup->t_bits;		/* ptr to att in tuple */
-	int			slow;			/* do we have to walk nulls? */
-	Form_pg_attribute *att = tupleDesc->attrs;
+	char			   *tp;						/* ptr to att in tuple */
+	HeapTupleHeader		tup = tuple->t_data;
+	bits8			   *bp = tup->t_bits;		/* ptr to att in tuple */
+	int					slow;					/* do we have to walk nulls? */
+	Form_pg_attribute  *att = tupleDesc->attrs;
 
 
 #if IN_MACRO
@@ -351,7 +352,7 @@ nocachegetattr(HeapTuple tup,
 	 * ----------------
 	 */
 
-	if (HeapTupleNoNulls(tup))
+	if (HeapTupleNoNulls(tuple))
 	{
 		attnum--;
 
@@ -449,7 +450,7 @@ nocachegetattr(HeapTuple tup,
 		}
 		else if (attnum == 0)
 			return (Datum) fetchatt(&(att[0]), (char *) tp);
-		else if (!HeapTupleAllFixed(tup))
+		else if (!HeapTupleAllFixed(tuple))
 		{
 			int			j = 0;
 
@@ -491,8 +492,8 @@ nocachegetattr(HeapTuple tup,
 		/* Can we compute more?  We will probably need them */
 			 (j < tup->t_natts &&
 			  att[j]->attcacheoff == -1 &&
-			  (HeapTupleNoNulls(tup) || !att_isnull(j, bp)) &&
-			  (HeapTupleAllFixed(tup) ||
+			  (HeapTupleNoNulls(tuple) || !att_isnull(j, bp)) &&
+			  (HeapTupleAllFixed(tuple) ||
 			   att[j]->attlen > 0 || VARLENA_FIXED_SIZE(att[j]))); j++)
 		{
 
@@ -527,7 +528,7 @@ nocachegetattr(HeapTuple tup,
 
 		for (i = 0; i < attnum; i++)
 		{
-			if (!HeapTupleNoNulls(tup))
+			if (!HeapTupleNoNulls(tuple))
 			{
 				if (att_isnull(i, bp))
 				{
@@ -570,14 +571,41 @@ heap_copytuple(HeapTuple tuple)
 {
 	HeapTuple	newTuple;
 
-	if (!HeapTupleIsValid(tuple))
+	if (!HeapTupleIsValid(tuple) || tuple->t_data == NULL)
 		return NULL;
 
-	newTuple = (HeapTuple) palloc(tuple->t_len);
-	memmove((char *) newTuple, (char *) tuple, (int) tuple->t_len);
+	newTuple = (HeapTuple) palloc(HEAPTUPLESIZE + tuple->t_len);
+	newTuple->t_len = tuple->t_len;
+	newTuple->t_self = tuple->t_self;
+	newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE);
+	memmove((char *) newTuple->t_data, 
+			(char *) tuple->t_data, (int) tuple->t_len);
 	return newTuple;
 }
 
+/* ----------------
+ *		heap_copytuple_with_tuple
+ *
+ *		returns a copy of an tuple->t_data
+ * ----------------
+ */
+void
+heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
+{
+	if (!HeapTupleIsValid(src) || src->t_data == NULL)
+	{
+		dest->t_data = NULL;
+		return;
+	}
+	
+	dest->t_len = src->t_len;
+	dest->t_self = src->t_self;
+	dest->t_data = (HeapTupleHeader) palloc(src->t_len);
+	memmove((char *) dest->t_data, 
+			(char *) src->t_data, (int) src->t_len);
+	return;
+}
+
 #ifdef NOT_USED
 /* ----------------
  *		heap_deformtuple
@@ -637,16 +665,16 @@ heap_formtuple(TupleDesc tupleDescriptor,
 			   Datum *value,
 			   char *nulls)
 {
-	char	   *tp;				/* tuple pointer */
-	HeapTuple	tuple;			/* return tuple */
-	int			bitmaplen;
-	long		len;
-	int			hoff;
-	bool		hasnull = false;
-	int			i;
-	int			numberOfAttributes = tupleDescriptor->natts;
+	HeapTuple		tuple;			/* return tuple */
+	HeapTupleHeader	td;				/* tuple data */
+	int				bitmaplen;
+	long			len;
+	int				hoff;
+	bool			hasnull = false;
+	int				i;
+	int				numberOfAttributes = tupleDescriptor->natts;
 
-	len = offsetof(HeapTupleData, t_bits);
+	len = offsetof(HeapTupleHeaderData, t_bits);
 
 	for (i = 0; i < numberOfAttributes && !hasnull; i++)
 	{
@@ -668,23 +696,24 @@ heap_formtuple(TupleDesc tupleDescriptor,
 
 	len += ComputeDataSize(tupleDescriptor, value, nulls);
 
-	tp = (char *) palloc(len);
-	tuple = (HeapTuple) tp;
+	tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len);
+	td = tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);;
 
-	MemSet(tp, 0, (int) len);
+	MemSet((char *) td, 0, (int) len);
 
 	tuple->t_len = len;
-	tuple->t_natts = numberOfAttributes;
-	tuple->t_hoff = hoff;
+	ItemPointerSetInvalid(&(tuple->t_self));
+	td->t_natts = numberOfAttributes;
+	td->t_hoff = hoff;
 
-	DataFill((char *) tuple + tuple->t_hoff,
+	DataFill((char *) td + td->t_hoff,
 			 tupleDescriptor,
 			 value,
 			 nulls,
-			 &tuple->t_infomask,
-			 (hasnull ? tuple->t_bits : NULL));
+			 &td->t_infomask,
+			 (hasnull ? td->t_bits : NULL));
 
-	tuple->t_infomask |= HEAP_XMAX_INVALID;
+	td->t_infomask |= HEAP_XMAX_INVALID;
 
 	return tuple;
 }
@@ -767,13 +796,15 @@ heap_modifytuple(HeapTuple tuple,
 	 *	copy the header except for t_len, t_natts, t_hoff, t_bits, t_infomask
 	 * ----------------
 	 */
-	infomask = newTuple->t_infomask;
-	memmove((char *) &newTuple->t_oid,	/* XXX */
-			(char *) &tuple->t_oid,
-			((char *) &tuple->t_hoff - (char *) &tuple->t_oid));		/* XXX */
-	newTuple->t_infomask = infomask;
-	newTuple->t_natts = numberOfAttributes;		/* fix t_natts just in
-												 * case */
+	infomask = newTuple->t_data->t_infomask;
+	memmove((char *) &newTuple->t_data->t_oid,	/* XXX */
+			(char *) &tuple->t_data->t_oid,
+			((char *) &tuple->t_data->t_hoff - 
+				(char *) &tuple->t_data->t_oid));		/* XXX */
+	newTuple->t_data->t_infomask = infomask;
+	newTuple->t_data->t_natts = numberOfAttributes;
+	newTuple->t_self = tuple->t_self;
+	
 	return newTuple;
 }
 
@@ -787,28 +818,30 @@ heap_addheader(uint32 natts,	/* max domain index */
 			   int structlen,	/* its length */
 			   char *structure) /* pointer to the struct */
 {
-	char	   *tp;				/* tuple data pointer */
-	HeapTuple	tup;
-	long		len;
-	int			hoff;
+	HeapTuple		tuple;
+	HeapTupleHeader	td;				/* tuple data */
+	long			len;
+	int				hoff;
 
 	AssertArg(natts > 0);
 
-	len = offsetof(HeapTupleData, t_bits);
+	len = offsetof(HeapTupleHeaderData, t_bits);
 
 	hoff = len = DOUBLEALIGN(len);		/* be conservative */
 	len += structlen;
-	tp = (char *) palloc(len);
-	tup = (HeapTuple) tp;
-	MemSet((char *) tup, 0, len);
+	tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len);
+	td = tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
+
+	MemSet((char *) td, 0, (int) len);
 
-	tup->t_len = len;
-	tp += tup->t_hoff = hoff;
-	tup->t_natts = natts;
-	tup->t_infomask = 0;
-	tup->t_infomask |= HEAP_XMAX_INVALID;
+	tuple->t_len = len;
+	ItemPointerSetInvalid(&(tuple->t_self));
+	td->t_hoff = hoff;
+	td->t_natts = natts;
+	td->t_infomask = 0;
+	td->t_infomask |= HEAP_XMAX_INVALID;
 
-	memmove(tp, structure, structlen);
+	memmove((char *) td + hoff, structure, structlen);
 
-	return tup;
+	return tuple;
 }
diff --git a/src/backend/access/common/heapvalid.c b/src/backend/access/common/heapvalid.c
index cbdd4734781c9990cff588a5badf3f46961ba2f4..79208bb3a50102b11febf03d1a3793cd66d2466a 100644
--- a/src/backend/access/common/heapvalid.c
+++ b/src/backend/access/common/heapvalid.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.21 1997/09/22 03:58:32 vadim Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.22 1998/11/27 19:51:28 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -25,9 +25,9 @@
 bool
 TupleUpdatedByCurXactAndCmd(HeapTuple t)
 {
-	if (TransactionIdEquals(t->t_xmax,
+	if (TransactionIdEquals(t->t_data->t_xmax,
 							GetCurrentTransactionId()) &&
-		CommandIdGEScanCommandId(t->t_cmax))
+		CommandIdGEScanCommandId(t->t_data->t_cmax))
 		return true;
 
 	return false;
diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c
index 68459beb011e0b19633d9a4dc2ae4fd8434a191c..4e8592ef568b7ea5291c9f13948b3fa45167818f 100644
--- a/src/backend/access/common/printtup.c
+++ b/src/backend/access/common/printtup.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.35 1998/09/01 04:26:40 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.36 1998/11/27 19:51:28 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -100,7 +100,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
 	 */
 	j = 0;
 	k = 1 << 7;
-	for (i = 0; i < tuple->t_natts;)
+	for (i = 0; i < tuple->t_data->t_natts;)
 	{
 		i++;					/* heap_getattr is a macro, so no
 								 * increment */
@@ -122,7 +122,7 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
 	 *	send the attributes of this tuple
 	 * ----------------
 	 */
-	for (i = 0; i < tuple->t_natts; ++i)
+	for (i = 0; i < tuple->t_data->t_natts; ++i)
 	{
 		attr = heap_getattr(tuple, i + 1, typeinfo, &isnull);
 		if (isnull)
@@ -204,7 +204,7 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo)
 	bool		isnull;
 	Oid			typoutput;
 
-	for (i = 0; i < tuple->t_natts; ++i)
+	for (i = 0; i < tuple->t_data->t_natts; ++i)
 	{
 		attr = heap_getattr(tuple, i + 1, typeinfo, &isnull);
 		typoutput = typtoout((Oid) typeinfo->attrs[i]->atttypid);
@@ -251,7 +251,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
 	 */
 	j = 0;
 	k = 1 << 7;
-	for (i = 0; i < tuple->t_natts;)
+	for (i = 0; i < tuple->t_data->t_natts;)
 	{
 		i++;					/* heap_getattr is a macro, so no
 								 * increment */
@@ -274,9 +274,9 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
 	 * ----------------
 	 */
 #ifdef IPORTAL_DEBUG
-	fprintf(stderr, "sending tuple with %d atts\n", tuple->t_natts);
+	fprintf(stderr, "sending tuple with %d atts\n", tuple->t_data->t_natts);
 #endif
-	for (i = 0; i < tuple->t_natts; ++i)
+	for (i = 0; i < tuple->t_data->t_natts; ++i)
 	{
 		int32		len = typeinfo->attrs[i]->attlen;
 
diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index 4e33e362a1091891cea0047a605f6d6c5ba262df..5b6181fe57438d56af0e6ca7e02746d4f8b83853 100644
--- a/src/backend/access/common/tupdesc.c
+++ b/src/backend/access/common/tupdesc.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.44 1998/09/01 04:26:41 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.45 1998/11/27 19:51:28 vadim Exp $
  *
  * NOTES
  *	  some of the executor utility code such as "ExecTypeFromTL" should be
@@ -351,7 +351,7 @@ TupleDescInitEntry(TupleDesc desc,
 	 */
 	typeForm = (Form_pg_type) GETSTRUCT(tuple);
 
-	att->atttypid = tuple->t_oid;
+	att->atttypid = tuple->t_data->t_oid;
 	att->attalign = typeForm->typalign;
 
 	/* ------------------------
diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c
index cb5917b206bf3f38f0978d8e0564d343f64e168d..f57c0432b5e87e477d86031c7ae20536fdd80519 100644
--- a/src/backend/access/gist/gist.c
+++ b/src/backend/access/gist/gist.c
@@ -248,7 +248,7 @@ gistbuild(Relation heap,
 
 		/* form an index tuple and point it at the heap tuple */
 		itup = index_formtuple(id, &d[0], nulls);
-		itup->t_tid = htup->t_ctid;
+		itup->t_tid = htup->t_self;
 
 		/*
 		 * Since we already have the index relation locked, we call
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index e6ca98c7096b91a911a244568abeb550fd0062f4..07bc0feec9a38c6e9486605c3378dad92f6f764e 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.22 1998/09/01 04:26:48 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.23 1998/11/27 19:51:31 vadim Exp $
  *
  * NOTES
  *	  This file contains only the public interface routines.
@@ -216,7 +216,7 @@ hashbuild(Relation heap,
 			continue;
 		}
 
-		itup->t_tid = htup->t_ctid;
+		itup->t_tid = htup->t_self;
 		hitem = _hash_formitem(itup);
 		res = _hash_doinsert(index, hitem);
 		pfree(hitem);
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index c2b346e2f5abf15489f0355670526fa43a2083b0..76fcfaf2c8210d506e79beb7d9ed3bd6e782c2b7 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.37 1998/10/12 00:53:30 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.38 1998/11/27 19:51:36 vadim Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -120,7 +120,8 @@ initscan(HeapScanDesc scan,
 		 *	relation is empty
 		 * ----------------
 		 */
-		scan->rs_ntup = scan->rs_ctup = scan->rs_ptup = 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;
 	}
 	else if (atend)
@@ -129,9 +130,9 @@ initscan(HeapScanDesc scan,
 		 *	reverse scan
 		 * ----------------
 		 */
-		scan->rs_ntup = scan->rs_ctup = NULL;
+		scan->rs_ntup.t_data = scan->rs_ctup.t_data = NULL;
 		scan->rs_nbuf = scan->rs_cbuf = InvalidBuffer;
-		scan->rs_ptup = NULL;
+		scan->rs_ptup.t_data = NULL;
 		scan->rs_pbuf = UnknownBuffer;
 	}
 	else
@@ -140,9 +141,9 @@ initscan(HeapScanDesc scan,
 		 *	forward scan
 		 * ----------------
 		 */
-		scan->rs_ctup = scan->rs_ptup = NULL;
+		scan->rs_ctup.t_data = scan->rs_ptup.t_data = NULL;
 		scan->rs_cbuf = scan->rs_pbuf = InvalidBuffer;
-		scan->rs_ntup = NULL;
+		scan->rs_ntup.t_data = NULL;
 		scan->rs_nbuf = UnknownBuffer;
 	}							/* invalid too */
 
@@ -209,23 +210,24 @@ nextpage(int page, int dir)
  *		like pass it to another function.
  * ----------------
  */
-static HeapTuple
+static void
 heapgettup(Relation relation,
-		   ItemPointer tid,
+		   HeapTuple tuple,
 		   int dir,
 		   Buffer *buf,
 		   Snapshot snapshot,
 		   int nkeys,
 		   ScanKey key)
 {
-	ItemId		lpp;
-	Page		dp;
-	int			page;
-	int			pages;
-	int			lines;
-	HeapTuple	rtup;
-	OffsetNumber lineoff;
-	int			linesleft;
+	ItemId			lpp;
+	Page			dp;
+	int				page;
+	int				pages;
+	int				lines;
+	OffsetNumber	lineoff;
+	int				linesleft;
+	ItemPointer		tid = (tuple->t_data == NULL) ? 
+							(ItemPointer) NULL : &(tuple->t_self);
 
 	/* ----------------
 	 *	increment access statistics
@@ -268,7 +270,10 @@ heapgettup(Relation relation,
 	 * ----------------
 	 */
 	if (!(pages = relation->rd_nblocks))
-		return NULL;
+	{
+		tuple->t_data = NULL;
+		return;
+	}
 
 	/* ----------------
 	 *	calculate next starting lineoff, given scan direction
@@ -284,7 +289,8 @@ heapgettup(Relation relation,
 		if (ItemPointerIsValid(tid) == false)
 		{
 			*buf = InvalidBuffer;
-			return NULL;
+			tuple->t_data = NULL;
+			return;
 		}
 		*buf = RelationGetBufferWithBuffer(relation,
 										   ItemPointerGetBlockNumber(tid),
@@ -299,8 +305,9 @@ heapgettup(Relation relation,
 		lineoff = ItemPointerGetOffsetNumber(tid);
 		lpp = PageGetItemId(dp, lineoff);
 
-		rtup = (HeapTuple) PageGetItem((Page) dp, lpp);
-		return rtup;
+		tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
+		tuple->t_len = ItemIdGetLength(lpp);
+		return;
 
 	}
 	else if (dir < 0)
@@ -322,7 +329,8 @@ heapgettup(Relation relation,
 		if (page < 0)
 		{
 			*buf = InvalidBuffer;
-			return NULL;
+			tuple->t_data = NULL;
+			return;
 		}
 
 		*buf = RelationGetBufferWithBuffer(relation, page, *buf);
@@ -366,7 +374,8 @@ heapgettup(Relation relation,
 		if (page >= pages)
 		{
 			*buf = InvalidBuffer;
-			return NULL;
+			tuple->t_data = NULL;
+			return;
 		}
 		/* page and lineoff now reference the physically next tid */
 
@@ -402,26 +411,19 @@ heapgettup(Relation relation,
 	{
 		while (linesleft >= 0)
 		{
-			/* ----------------
-			 *	if current tuple qualifies, return it.
-			 * ----------------
-			 */
-			HeapTupleSatisfies(lpp, relation, *buf, (PageHeader) dp,
-							   snapshot, nkeys, key, rtup);
-			if (rtup != NULL)
+			if (ItemIdIsUsed(lpp))
 			{
-				ItemPointer iptr = &(rtup->t_ctid);
-
-				if (ItemPointerGetBlockNumber(iptr) != page)
-				{
-
-					/*
-					 * set block id to the correct page number --- this is
-					 * a hack to support the virtual fragment concept
-					 */
-					ItemPointerSetBlockNumber(iptr, page);
-				}
-				return rtup;
+				tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp);
+				tuple->t_len = ItemIdGetLength(lpp);
+				ItemPointerSet(&(tuple->t_self), page, lineoff);
+				/* ----------------
+				 *	if current tuple qualifies, return it.
+				 * ----------------
+				 */
+				HeapTupleSatisfies(tuple, relation, *buf, (PageHeader) dp,
+								   snapshot, nkeys, key);
+				if (tuple->t_data != NULL)
+					return;
 			}
 
 			/* ----------------
@@ -432,11 +434,12 @@ heapgettup(Relation relation,
 			if (dir < 0)
 			{
 				--lpp;			/* move back in this page's ItemId array */
+				--lineoff;
 			}
 			else
 			{
-				++lpp;			/* move forward in this page's ItemId
-								 * array */
+				++lpp;			/* move forward in this page's ItemId array */
+				++lineoff;
 			}
 		}
 
@@ -456,7 +459,8 @@ heapgettup(Relation relation,
 			if (BufferIsValid(*buf))
 				ReleaseBuffer(*buf);
 			*buf = InvalidBuffer;
-			return NULL;
+			tuple->t_data = NULL;
+			return;
 		}
 
 		*buf = ReleaseAndReadBuffer(*buf, relation, page);
@@ -466,12 +470,18 @@ heapgettup(Relation relation,
 			elog(ERROR, "heapgettup: failed ReadBuffer");
 #endif
 		dp = (Page) BufferGetPage(*buf);
-		lines = lineoff = PageGetMaxOffsetNumber((Page) dp);
+		lines = PageGetMaxOffsetNumber((Page) dp);
 		linesleft = lines - 1;
 		if (dir < 0)
-			lpp = PageGetItemId(dp, lineoff);
+		{
+			lineoff = lines;
+			lpp = PageGetItemId(dp, lines);
+		}
 		else
+		{
+			lineoff = FirstOffsetNumber;
 			lpp = PageGetItemId(dp, FirstOffsetNumber);
+		}
 	}
 }
 
@@ -786,7 +796,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 		 */
 		HEAPDEBUG_2;			/* heap_getnext called with backw */
 
-		if (scan->rs_ptup == scan->rs_ctup &&
+		if (scan->rs_ptup.t_data == scan->rs_ctup.t_data &&
 			BufferIsInvalid(scan->rs_pbuf))
 		{
 			if (BufferIsValid(scan->rs_nbuf))
@@ -808,7 +818,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 		scan->rs_ntup = scan->rs_ctup;
 		scan->rs_nbuf = scan->rs_cbuf;
 
-		if (scan->rs_ptup != NULL)
+		if (scan->rs_ptup.t_data != NULL)
 		{
 			if (scan->rs_cbuf != scan->rs_pbuf)
 			{
@@ -822,11 +832,6 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 		}
 		else
 		{						/* NONTUP */
-			ItemPointer iptr;
-
-			iptr = (scan->rs_ctup != NULL) ?
-				&(scan->rs_ctup->t_ctid) : (ItemPointer) NULL;
-
 			/*
 			 * Don't release scan->rs_cbuf at this point, because
 			 * heapgettup doesn't increase PrivateRefCount if it is
@@ -836,32 +841,31 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 			 * instance ctup is stored in a TupleTableSlot).  - 01/09/94
 			 */
 
-			scan->rs_ctup = (HeapTuple)
-				heapgettup(scan->rs_rd,
-						   iptr,
-						   -1,
-						   &(scan->rs_cbuf),
-						   scan->rs_snapshot,
-						   scan->rs_nkeys,
-						   scan->rs_key);
+			heapgettup(scan->rs_rd,
+					   &(scan->rs_ctup),
+					   -1,
+					   &(scan->rs_cbuf),
+					   scan->rs_snapshot,
+					   scan->rs_nkeys,
+					   scan->rs_key);
 		}
 
-		if (scan->rs_ctup == NULL && !BufferIsValid(scan->rs_cbuf))
+		if (scan->rs_ctup.t_data == NULL && !BufferIsValid(scan->rs_cbuf))
 		{
 			if (BufferIsValid(scan->rs_pbuf))
 				ReleaseBuffer(scan->rs_pbuf);
-			scan->rs_ptup = NULL;
+			scan->rs_ptup.t_data = NULL;
 			scan->rs_pbuf = InvalidBuffer;
 			if (BufferIsValid(scan->rs_nbuf))
 				ReleaseBuffer(scan->rs_nbuf);
-			scan->rs_ntup = NULL;
+			scan->rs_ntup.t_data = NULL;
 			scan->rs_nbuf = InvalidBuffer;
 			return NULL;
 		}
 
 		if (BufferIsValid(scan->rs_pbuf))
 			ReleaseBuffer(scan->rs_pbuf);
-		scan->rs_ptup = NULL;
+		scan->rs_ptup.t_data = NULL;
 		scan->rs_pbuf = UnknownBuffer;
 
 	}
@@ -871,7 +875,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 		 *	handle forward scan
 		 * ----------------
 		 */
-		if (scan->rs_ctup == scan->rs_ntup &&
+		if (scan->rs_ctup.t_data == scan->rs_ntup.t_data &&
 			BufferIsInvalid(scan->rs_nbuf))
 		{
 			if (BufferIsValid(scan->rs_pbuf))
@@ -894,7 +898,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 		scan->rs_ptup = scan->rs_ctup;
 		scan->rs_pbuf = scan->rs_cbuf;
 
-		if (scan->rs_ntup != NULL)
+		if (scan->rs_ntup.t_data != NULL)
 		{
 			if (scan->rs_cbuf != scan->rs_nbuf)
 			{
@@ -909,11 +913,6 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 		}
 		else
 		{						/* NONTUP */
-			ItemPointer iptr;
-
-			iptr = (scan->rs_ctup != NULL) ?
-				&scan->rs_ctup->t_ctid : (ItemPointer) NULL;
-
 			/*
 			 * Don't release scan->rs_cbuf at this point, because
 			 * heapgettup doesn't increase PrivateRefCount if it is
@@ -923,25 +922,24 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 			 * instance ctup is stored in a TupleTableSlot).  - 01/09/93
 			 */
 
-			scan->rs_ctup = (HeapTuple)
-				heapgettup(scan->rs_rd,
-						   iptr,
-						   1,
-						   &scan->rs_cbuf,
-						   scan->rs_snapshot,
-						   scan->rs_nkeys,
-						   scan->rs_key);
+			heapgettup(scan->rs_rd,
+					   &(scan->rs_ctup),
+					   1,
+					   &scan->rs_cbuf,
+					   scan->rs_snapshot,
+					   scan->rs_nkeys,
+					   scan->rs_key);
 		}
 
-		if (scan->rs_ctup == NULL && !BufferIsValid(scan->rs_cbuf))
+		if (scan->rs_ctup.t_data == NULL && !BufferIsValid(scan->rs_cbuf))
 		{
 			if (BufferIsValid(scan->rs_nbuf))
 				ReleaseBuffer(scan->rs_nbuf);
-			scan->rs_ntup = NULL;
+			scan->rs_ntup.t_data = NULL;
 			scan->rs_nbuf = InvalidBuffer;
 			if (BufferIsValid(scan->rs_pbuf))
 				ReleaseBuffer(scan->rs_pbuf);
-			scan->rs_ptup = NULL;
+			scan->rs_ptup.t_data = NULL;
 			scan->rs_pbuf = InvalidBuffer;
 			HEAPDEBUG_6;		/* heap_getnext returning EOS */
 			return NULL;
@@ -949,7 +947,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 
 		if (BufferIsValid(scan->rs_nbuf))
 			ReleaseBuffer(scan->rs_nbuf);
-		scan->rs_ntup = NULL;
+		scan->rs_ntup.t_data = NULL;
 		scan->rs_nbuf = UnknownBuffer;
 	}
 
@@ -961,7 +959,7 @@ heap_getnext(HeapScanDesc scandesc, int backw)
 
 	HEAPDEBUG_7;				/* heap_getnext returning tuple */
 
-	return scan->rs_ctup;
+	return ((scan->rs_ctup.t_data == NULL) ? NULL : &(scan->rs_ctup));
 }
 
 /* ----------------
@@ -972,23 +970,23 @@ heap_getnext(HeapScanDesc scandesc, int backw)
  *		Because this is not part of a scan, there is no way to
  *		automatically lock/unlock the shared buffers.
  *		For this reason, we require that the user retrieve the buffer
- *		value, and they are required to BuffferRelease() it when they
+ *		value, and they are required to BufferRelease() it when they
  *		are done.  If they want to make a copy of it before releasing it,
  *		they can call heap_copytyple().
 
  * ----------------
  */
-HeapTuple
+void
 heap_fetch(Relation relation,
 		   Snapshot snapshot,
-		   ItemPointer tid,
+		   HeapTuple tuple,
 		   Buffer *userbuf)
 {
-	ItemId		lp;
-	Buffer		buffer;
-	PageHeader	dp;
-	HeapTuple	tuple;
-	OffsetNumber offnum;
+	ItemId			lp;
+	Buffer			buffer;
+	PageHeader		dp;
+	ItemPointer		tid = &(tuple->t_self);
+	OffsetNumber	offnum;
 
 	AssertMacro(PointerIsValid(userbuf));		/* see comments above */
 
@@ -1038,18 +1036,21 @@ heap_fetch(Relation relation,
 
 	Assert(ItemIdIsUsed(lp));
 
+	tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
+	tuple->t_len = ItemIdGetLength(lp);
+
 	/* ----------------
 	 *	check time qualification of tid
 	 * ----------------
 	 */
 
-	HeapTupleSatisfies(lp, relation, buffer, dp,
-					   snapshot, 0, (ScanKey) NULL, tuple);
+	HeapTupleSatisfies(tuple, relation, buffer, dp,
+					   snapshot, 0, (ScanKey) NULL);
 
-	if (tuple == NULL)
+	if (tuple->t_data == NULL)
 	{
 		ReleaseBuffer(buffer);
-		return NULL;
+		return;
 	}
 
 	/* ----------------
@@ -1062,7 +1063,7 @@ heap_fetch(Relation relation,
 	*userbuf = buffer;			/* user is required to ReleaseBuffer()
 								 * this */
 
-	return tuple;
+	return;
 }
 
 /* ----------------
@@ -1107,19 +1108,19 @@ heap_insert(Relation relation, HeapTuple tup)
 	 *	another).
 	 * ----------------
 	 */
-	if (!OidIsValid(tup->t_oid))
+	if (!OidIsValid(tup->t_data->t_oid))
 	{
-		tup->t_oid = newoid();
-		LastOidProcessed = tup->t_oid;
+		tup->t_data->t_oid = newoid();
+		LastOidProcessed = tup->t_data->t_oid;
 	}
 	else
-		CheckMaxObjectId(tup->t_oid);
+		CheckMaxObjectId(tup->t_data->t_oid);
 
-	TransactionIdStore(GetCurrentTransactionId(), &(tup->t_xmin));
-	tup->t_cmin = GetCurrentCommandId();
-	StoreInvalidTransactionId(&(tup->t_xmax));
-	tup->t_infomask &= ~(HEAP_XACT_MASK);
-	tup->t_infomask |= HEAP_XMAX_INVALID;
+	TransactionIdStore(GetCurrentTransactionId(), &(tup->t_data->t_xmin));
+	tup->t_data->t_cmin = GetCurrentCommandId();
+	StoreInvalidTransactionId(&(tup->t_data->t_xmax));
+	tup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
+	tup->t_data->t_infomask |= HEAP_XMAX_INVALID;
 
 	doinsert(relation, tup);
 
@@ -1134,7 +1135,7 @@ heap_insert(Relation relation, HeapTuple tup)
 		RelationInvalidateHeapTuple(relation, tup);
 	}
 
-	return tup->t_oid;
+	return tup->t_data->t_oid;
 }
 
 /* ----------------
@@ -1146,10 +1147,10 @@ heap_insert(Relation relation, HeapTuple tup)
 int
 heap_delete(Relation relation, ItemPointer tid)
 {
-	ItemId		lp;
-	HeapTuple	tp;
-	PageHeader	dp;
-	Buffer		buf;
+	ItemId			lp;
+	HeapTupleData	tp;
+	PageHeader		dp;
+	Buffer			buf;
 
 	/* ----------------
 	 *	increment access statistics
@@ -1186,9 +1187,11 @@ heap_delete(Relation relation, ItemPointer tid)
 	 * Just like test against non-functional updates we try to catch
 	 * non-functional delete attempts.			- vadim 05/05/97
 	 */
-	tp = (HeapTuple) PageGetItem((Page) dp, lp);
-	Assert(HeapTupleIsValid(tp));
-	if (TupleUpdatedByCurXactAndCmd(tp))
+	tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
+	tp.t_len = ItemIdGetLength(lp);
+	tp.t_self = *tid;
+	
+	if (TupleUpdatedByCurXactAndCmd(&tp))
 	{
 
 		/*
@@ -1204,9 +1207,9 @@ heap_delete(Relation relation, ItemPointer tid)
 	 *	check that we're deleteing a valid item
 	 * ----------------
 	 */
-	HeapTupleSatisfies(lp, relation, buf, dp,
-					   false, 0, (ScanKey) NULL, tp);
-	if (!tp)
+	HeapTupleSatisfies((&tp), relation, buf, dp,
+					   false, 0, (ScanKey) NULL);
+	if (!(tp.t_data))
 	{
 
 		/* XXX call something else */
@@ -1225,15 +1228,15 @@ heap_delete(Relation relation, ItemPointer tid)
 	 *	store transaction information of xact deleting the tuple
 	 * ----------------
 	 */
-	TransactionIdStore(GetCurrentTransactionId(), &(tp->t_xmax));
-	tp->t_cmax = GetCurrentCommandId();
-	tp->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
+	TransactionIdStore(GetCurrentTransactionId(), &(tp.t_data->t_xmax));
+	tp.t_data->t_cmax = GetCurrentCommandId();
+	tp.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
 
 	/* ----------------
 	 *	invalidate caches
 	 * ----------------
 	 */
-	RelationInvalidateHeapTuple(relation, tp);
+	RelationInvalidateHeapTuple(relation, &tp);
 
 	WriteBuffer(buf);
 	if (IsSystemRelationName(RelationGetRelationName(relation)->data))
@@ -1257,13 +1260,12 @@ heap_delete(Relation relation, ItemPointer tid)
  * ----------------
  */
 int
-heap_replace(Relation relation, ItemPointer otid, HeapTuple replace_tuple)
+heap_replace(Relation relation, ItemPointer otid, HeapTuple newtup)
 {
-	ItemId		lp;
-	HeapTuple	old_tuple;
-	Page		dp;
-	Buffer		buffer;
-	HeapTuple	tuple;
+	ItemId			lp;
+	HeapTupleData	oldtup;
+	Page			dp;
+	Buffer			buffer;
 
 	/* ----------------
 	 *	increment access statistics
@@ -1286,13 +1288,8 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple replace_tuple)
 		RelationSetLockForWrite(relation);
 
 	buffer = ReadBuffer(relation, ItemPointerGetBlockNumber(otid));
-#ifndef NO_BUFFERISVALID
 	if (!BufferIsValid(buffer))
-	{
-		/* XXX L_SH better ??? */
 		elog(ERROR, "amreplace: failed ReadBuffer");
-	}
-#endif	 /* NO_BUFFERISVALID */
 
 	dp = (Page) BufferGetPage(buffer);
 	lp = PageGetItemId(dp, ItemPointerGetOffsetNumber(otid));
@@ -1302,8 +1299,9 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple replace_tuple)
 	 * ----------------
 	 */
 
-	old_tuple = (HeapTuple) PageGetItem(dp, lp);
-	Assert(HeapTupleIsValid(old_tuple));
+	oldtup.t_data = (HeapTupleHeader) PageGetItem(dp, lp);
+	oldtup.t_len = ItemIdGetLength(lp);
+	oldtup.t_self = *otid;
 
 	/* -----------------
 	 *	the following test should be able to catch all non-functional
@@ -1316,7 +1314,7 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple replace_tuple)
 	 * -----------------
 	 */
 
-	if (TupleUpdatedByCurXactAndCmd(old_tuple))
+	if (TupleUpdatedByCurXactAndCmd(&oldtup))
 	{
 		elog(NOTICE, "Non-functional update, only first update is performed");
 		if (IsSystemRelationName(RelationGetRelationName(relation)->data))
@@ -1335,34 +1333,33 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple replace_tuple)
 	 *		 xact, we only want to flag the 'non-functional' NOTICE. -mer
 	 * ----------------
 	 */
-	HeapTupleSatisfies(lp,
+	HeapTupleSatisfies((&oldtup),
 					   relation,
 					   buffer,
 					   (PageHeader) dp,
 					   false,
 					   0,
-					   (ScanKey) NULL,
-					   tuple);
-	if (!tuple)
+					   (ScanKey) NULL);
+	if (!(oldtup.t_data))
 	{
 		ReleaseBuffer(buffer);
 		elog(ERROR, "heap_replace: (am)invalid otid");
 	}
 
 	/* XXX order problems if not atomic assignment ??? */
-	replace_tuple->t_oid = old_tuple->t_oid;
-	TransactionIdStore(GetCurrentTransactionId(), &(replace_tuple->t_xmin));
-	replace_tuple->t_cmin = GetCurrentCommandId();
-	StoreInvalidTransactionId(&(replace_tuple->t_xmax));
-	replace_tuple->t_infomask &= ~(HEAP_XACT_MASK);
-	replace_tuple->t_infomask |= HEAP_XMAX_INVALID;
+	newtup->t_data->t_oid = oldtup.t_data->t_oid;
+	TransactionIdStore(GetCurrentTransactionId(), &(newtup->t_data->t_xmin));
+	newtup->t_data->t_cmin = GetCurrentCommandId();
+	StoreInvalidTransactionId(&(newtup->t_data->t_xmax));
+	newtup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
+	newtup->t_data->t_infomask |= HEAP_XMAX_INVALID;
 
 	/* ----------------
 	 *	insert new item
 	 * ----------------
 	 */
-	if ((unsigned) DOUBLEALIGN(replace_tuple->t_len) <= PageGetFreeSpace((Page) dp))
-		RelationPutHeapTuple(relation, BufferGetBlockNumber(buffer), replace_tuple);
+	if ((unsigned) DOUBLEALIGN(newtup->t_len) <= PageGetFreeSpace((Page) dp))
+		RelationPutHeapTuple(relation, BufferGetBlockNumber(buffer), newtup);
 	else
 	{
 		/* ----------------
@@ -1370,22 +1367,22 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple replace_tuple)
 		 *	for a new place to put it.
 		 * ----------------
 		 */
-		doinsert(relation, replace_tuple);
+		doinsert(relation, newtup);
 	}
 
 	/* ----------------
 	 *	new item in place, now record transaction information
 	 * ----------------
 	 */
-	TransactionIdStore(GetCurrentTransactionId(), &(old_tuple->t_xmax));
-	old_tuple->t_cmax = GetCurrentCommandId();
-	old_tuple->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
+	TransactionIdStore(GetCurrentTransactionId(), &(oldtup.t_data->t_xmax));
+	oldtup.t_data->t_cmax = GetCurrentCommandId();
+	oldtup.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
 
 	/* ----------------
 	 *	invalidate caches
 	 * ----------------
 	 */
-	RelationInvalidateHeapTuple(relation, old_tuple);
+	RelationInvalidateHeapTuple(relation, &oldtup);
 
 	WriteBuffer(buffer);
 
@@ -1423,48 +1420,46 @@ heap_markpos(HeapScanDesc scan)
 
 	/* Note: no locking manipulations needed */
 
-	if (scan->rs_ptup == NULL &&
+	if (scan->rs_ptup.t_data == NULL &&
 		BufferIsUnknown(scan->rs_pbuf))
 	{							/* == NONTUP */
-		scan->rs_ptup = (HeapTuple)
-			heapgettup(scan->rs_rd,
-					   (scan->rs_ctup == NULL) ?
-					   (ItemPointer) NULL : &scan->rs_ctup->t_ctid,
-					   -1,
-					   &scan->rs_pbuf,
-					   scan->rs_snapshot,
-					   scan->rs_nkeys,
-					   scan->rs_key);
+		scan->rs_ptup = scan->rs_ctup;
+		heapgettup(scan->rs_rd,
+				   &(scan->rs_ptup),
+				   -1,
+				   &scan->rs_pbuf,
+				   scan->rs_snapshot,
+				   scan->rs_nkeys,
+				   scan->rs_key);
 
 	}
-	else if (scan->rs_ntup == NULL &&
+	else if (scan->rs_ntup.t_data == NULL &&
 			 BufferIsUnknown(scan->rs_nbuf))
 	{							/* == NONTUP */
-		scan->rs_ntup = (HeapTuple)
-			heapgettup(scan->rs_rd,
-					   (scan->rs_ctup == NULL) ?
-					   (ItemPointer) NULL : &scan->rs_ctup->t_ctid,
-					   1,
-					   &scan->rs_nbuf,
-					   scan->rs_snapshot,
-					   scan->rs_nkeys,
-					   scan->rs_key);
+		scan->rs_ntup = scan->rs_ctup;
+		heapgettup(scan->rs_rd,
+				   &(scan->rs_ntup),
+				   1,
+				   &scan->rs_nbuf,
+				   scan->rs_snapshot,
+				   scan->rs_nkeys,
+				   scan->rs_key);
 	}
 
 	/* ----------------
 	 * Should not unpin the buffer pages.  They may still be in use.
 	 * ----------------
 	 */
-	if (scan->rs_ptup != NULL)
-		scan->rs_mptid = scan->rs_ptup->t_ctid;
+	if (scan->rs_ptup.t_data != NULL)
+		scan->rs_mptid = scan->rs_ptup.t_self;
 	else
 		ItemPointerSetInvalid(&scan->rs_mptid);
-	if (scan->rs_ctup != NULL)
-		scan->rs_mctid = scan->rs_ctup->t_ctid;
+	if (scan->rs_ctup.t_data != NULL)
+		scan->rs_mctid = scan->rs_ctup.t_self;
 	else
 		ItemPointerSetInvalid(&scan->rs_mctid);
-	if (scan->rs_ntup != NULL)
-		scan->rs_mntid = scan->rs_ntup->t_ctid;
+	if (scan->rs_ntup.t_data != NULL)
+		scan->rs_mntid = scan->rs_ntup.t_self;
 	else
 		ItemPointerSetInvalid(&scan->rs_mntid);
 }
@@ -1512,44 +1507,47 @@ heap_restrpos(HeapScanDesc scan)
 	scan->rs_nbuf = InvalidBuffer;
 
 	if (!ItemPointerIsValid(&scan->rs_mptid))
-		scan->rs_ptup = NULL;
+		scan->rs_ptup.t_data = NULL;
 	else
 	{
-		scan->rs_ptup = (HeapTuple)
-			heapgettup(scan->rs_rd,
-					   &scan->rs_mptid,
-					   0,
-					   &scan->rs_pbuf,
-					   false,
-					   0,
-					   (ScanKey) NULL);
+		scan->rs_ptup.t_self = scan->rs_mptid;
+		scan->rs_ptup.t_data = (HeapTupleHeader) 0x1;	/* for heapgettup */
+		heapgettup(scan->rs_rd,
+				   &(scan->rs_ptup),
+				   0,
+				   &(scan->rs_pbuf),
+				   false,
+				   0,
+				   (ScanKey) NULL);
 	}
 
 	if (!ItemPointerIsValid(&scan->rs_mctid))
-		scan->rs_ctup = NULL;
+		scan->rs_ctup.t_data = NULL;
 	else
 	{
-		scan->rs_ctup = (HeapTuple)
-			heapgettup(scan->rs_rd,
-					   &scan->rs_mctid,
-					   0,
-					   &scan->rs_cbuf,
-					   false,
-					   0,
-					   (ScanKey) NULL);
+		scan->rs_ctup.t_self = scan->rs_mctid;
+		scan->rs_ctup.t_data = (HeapTupleHeader) 0x1;	/* for heapgettup */
+		heapgettup(scan->rs_rd,
+				   &(scan->rs_ctup),
+				   0,
+				   &(scan->rs_cbuf),
+				   false,
+				   0,
+				   (ScanKey) NULL);
 	}
 
 	if (!ItemPointerIsValid(&scan->rs_mntid))
-		scan->rs_ntup = NULL;
+		scan->rs_ntup.t_data = NULL;
 	else
 	{
-		scan->rs_ntup = (HeapTuple)
-			heapgettup(scan->rs_rd,
-					   &scan->rs_mntid,
-					   0,
-					   &scan->rs_nbuf,
-					   false,
-					   0,
-					   (ScanKey) NULL);
+		scan->rs_ntup.t_self = scan->rs_mntid;
+		scan->rs_ntup.t_data = (HeapTupleHeader) 0x1;	/* for heapgettup */
+		heapgettup(scan->rs_rd,
+				   &(scan->rs_ntup),
+				   0,
+				   &scan->rs_nbuf,
+				   false,
+				   0,
+				   (ScanKey) NULL);
 	}
 }
diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c
index 0e1408e9594e49341a7e5f94cfd7cc4256ebcd2c..5c727145f6f0a725c10334ce144c2f5989f27bda 100644
--- a/src/backend/access/heap/hio.c
+++ b/src/backend/access/heap/hio.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Id: hio.c,v 1.13 1998/01/07 21:01:23 momjian Exp $
+ *	  $Id: hio.c,v 1.14 1998/11/27 19:51:36 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -69,17 +69,17 @@ RelationPutHeapTuple(Relation relation,
 	len = (unsigned) DOUBLEALIGN(tuple->t_len); /* be conservative */
 	Assert((int) len <= PageGetFreeSpace(pageHeader));
 
-	offnum = PageAddItem((Page) pageHeader, (Item) tuple,
+	offnum = PageAddItem((Page) pageHeader, (Item) tuple->t_data,
 						 tuple->t_len, InvalidOffsetNumber, LP_USED);
 
 	itemId = PageGetItemId((Page) pageHeader, offnum);
 	item = PageGetItem((Page) pageHeader, itemId);
 
-	ItemPointerSet(&((HeapTuple) item)->t_ctid, blockIndex, offnum);
+	ItemPointerSet(&((HeapTupleHeader) item)->t_ctid, blockIndex, offnum);
 
 	WriteBuffer(buffer);
 	/* return an accurate tuple */
-	ItemPointerSet(&tuple->t_ctid, blockIndex, offnum);
+	ItemPointerSet(&tuple->t_self, blockIndex, offnum);
 }
 
 /*
@@ -160,7 +160,7 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
 			elog(ERROR, "Tuple is too big: size %d", len);
 	}
 
-	offnum = PageAddItem((Page) pageHeader, (Item) tuple,
+	offnum = PageAddItem((Page) pageHeader, (Item) tuple->t_data,
 						 tuple->t_len, InvalidOffsetNumber, LP_USED);
 
 	itemId = PageGetItemId((Page) pageHeader, offnum);
@@ -168,10 +168,10 @@ RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple)
 
 	lastblock = BufferGetBlockNumber(buffer);
 
-	ItemPointerSet(&((HeapTuple) item)->t_ctid, lastblock, offnum);
+	ItemPointerSet(&((HeapTupleHeader) item)->t_ctid, lastblock, offnum);
 
 	/* return an accurate tuple */
-	ItemPointerSet(&tuple->t_ctid, lastblock, offnum);
+	ItemPointerSet(&tuple->t_self, lastblock, offnum);
 
 	WriteBuffer(buffer);
 }
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
index c2fa05eb227d096d25ba317c31b47ff192f1de1b..44349cfe3c7e847a228f2f31cf426112ad057d9c 100644
--- a/src/backend/access/nbtree/nbtinsert.c
+++ b/src/backend/access/nbtree/nbtinsert.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.30 1998/09/01 04:27:01 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.31 1998/11/27 19:51:40 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -96,13 +96,12 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
 		/* key on the page before trying to compare it */
 		if (!PageIsEmpty(page) && offset <= maxoff)
 		{
-			TupleDesc	itupdesc;
-			BTItem		btitem;
-			IndexTuple	itup;
-			HeapTuple	htup;
-			BTPageOpaque opaque;
-			Buffer		nbuf;
-			BlockNumber blkno;
+			TupleDesc		itupdesc;
+			BTItem			btitem;
+			HeapTupleData	htup;
+			BTPageOpaque 	opaque;
+			Buffer			nbuf;
+			BlockNumber 	blkno;
 
 			itupdesc = RelationGetDescr(rel);
 			nbuf = InvalidBuffer;
@@ -120,9 +119,9 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel
 			while (_bt_isequal(itupdesc, page, offset, natts, itup_scankey))
 			{					/* they're equal */
 				btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offset));
-				itup = &(btitem->bti_itup);
-				htup = heap_fetch(heapRel, SnapshotSelf, &(itup->t_tid), &buffer);
-				if (htup != (HeapTuple) NULL)
+				htup.t_self = btitem->bti_itup.t_tid;
+				heap_fetch(heapRel, SnapshotSelf, &htup, &buffer);
+				if (htup.t_data	!= NULL)
 				{				/* it is a duplicate */
 					elog(ERROR, "Cannot insert a duplicate key into a unique index");
 				}
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index f32502fbda62179c9ba053c553727b3b1f445290..7a3072395da3a485c996fc341bac2160e521c615 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.33 1998/09/07 05:35:33 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.34 1998/11/27 19:51:40 vadim Exp $
  *
  * NOTES
  *	  This file contains only the public interface routines.
@@ -256,7 +256,7 @@ btbuild(Relation heap,
 		 * if (itup->t_info & INDEX_NULL_MASK) { pfree(itup); continue; }
 		 */
 
-		itup->t_tid = htup->t_ctid;
+		itup->t_tid = htup->t_self;
 		btitem = _bt_formitem(itup);
 
 		/*
diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c
index a9b2eff6815ded3ebc9f009b8fcd193173234f22..3a8feda536daba1cb6b7bb7e04df7af2b3daa5f7 100644
--- a/src/backend/access/rtree/rtree.c
+++ b/src/backend/access/rtree/rtree.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.28 1998/09/01 04:27:10 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.29 1998/11/27 19:51:41 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -233,7 +233,7 @@ rtbuild(Relation heap,
 
 		/* form an index tuple and point it at the heap tuple */
 		itup = index_formtuple(id, &d[0], nulls);
-		itup->t_tid = htup->t_ctid;
+		itup->t_tid = htup->t_self;
 
 		/*
 		 * Since we already have the index relation locked, we call
diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c
index 2f8fd0531057914e729c65e82024d7c438b7b157..9eb4e740bcf5f8bce886caa1293e4fee08805655 100644
--- a/src/backend/bootstrap/bootstrap.c
+++ b/src/backend/bootstrap/bootstrap.c
@@ -7,7 +7,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.51 1998/09/01 04:27:21 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.52 1998/11/27 19:51:45 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -473,7 +473,7 @@ boot_openrel(char *relname)
 		app = Typ;
 		while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
 		{
-			(*app)->am_oid = tup->t_oid;
+			(*app)->am_oid = tup->t_data->t_oid;
 			memmove((char *) &(*app++)->am_typ,
 					(char *) GETSTRUCT(tup),
 					sizeof((*app)->am_typ));
@@ -634,7 +634,7 @@ InsertOneTuple(Oid objectid)
 	pfree(tupDesc);				/* just free's tupDesc, not the attrtypes */
 
 	if (objectid != (Oid) 0)
-		tuple->t_oid = objectid;
+		tuple->t_data->t_oid = objectid;
 	heap_insert(reldesc, tuple);
 	pfree(tuple);
 	if (DebugMode)
@@ -830,7 +830,7 @@ gettype(char *type)
 		app = Typ;
 		while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
 		{
-			(*app)->am_oid = tup->t_oid;
+			(*app)->am_oid = tup->t_data->t_oid;
 			memmove((char *) &(*app++)->am_typ,
 					(char *) GETSTRUCT(tup),
 					sizeof((*app)->am_typ));
diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c
index d432269a36e2d62bfeb19db057197ed3b3c34cfb..6c4fb244571bcf249def0efff7b8d62d55d01fd0 100644
--- a/src/backend/catalog/aclchk.c
+++ b/src/backend/catalog/aclchk.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.16 1998/09/01 04:27:27 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.17 1998/11/27 19:51:46 vadim Exp $
  *
  * NOTES
  *	  See acl.h.
@@ -162,7 +162,7 @@ ChangeAcl(char *relname,
 	tuple = heap_modifytuple(tuple, relation, values, nulls, replaces);
 	/* XXX handle index on pg_class? */
 	setheapoverride(true);
-	heap_replace(relation, &tuple->t_ctid, tuple);
+	heap_replace(relation, &tuple->t_self, tuple);
 	setheapoverride(false);
 
 	/* keep the catalog indices up to date */
diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c
index 7d9d8d26751e6a4ac13a785bda26e300f067b687..c1088a0bfc004aca679648976c1c0ce0e78b17c5 100644
--- a/src/backend/catalog/heap.c
+++ b/src/backend/catalog/heap.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.66 1998/11/17 14:26:39 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.67 1998/11/27 19:51:48 vadim Exp $
  *
  * INTERFACE ROUTINES
  *		heap_create()			- Create an uncataloged heap relation
@@ -663,7 +663,7 @@ AddPgRelationTuple(Relation pg_class_desc,
 	tup = heap_addheader(Natts_pg_class_fixed,
 						 CLASS_TUPLE_SIZE,
 						 (char *) new_rel_reltup);
-	tup->t_oid = new_rel_oid;
+	tup->t_data->t_oid = new_rel_oid;
 
 	/* ----------------
 	 *	finally insert the new tuple and free it.
@@ -929,7 +929,7 @@ RelationRemoveInheritance(Relation relation)
 
 	while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
 	{
-		heap_delete(catalogRelation, &tuple->t_ctid);
+		heap_delete(catalogRelation, &tuple->t_self);
 		found = true;
 	}
 
@@ -951,7 +951,7 @@ RelationRemoveInheritance(Relation relation)
 						  &entry);
 
 	while (HeapTupleIsValid(tuple = heap_getnext(scan, 0)))
-		heap_delete(catalogRelation, &tuple->t_ctid);
+		heap_delete(catalogRelation, &tuple->t_self);
 
 	heap_endscan(scan);
 	heap_close(catalogRelation);
@@ -1020,7 +1020,7 @@ DeletePgRelationTuple(Relation rel)
 	 *	delete the relation tuple from pg_class, and finish up.
 	 * ----------------
 	 */
-	heap_delete(pg_class_desc, &tup->t_ctid);
+	heap_delete(pg_class_desc, &tup->t_self);
 	pfree(tup);
 
 	heap_close(pg_class_desc);
@@ -1059,7 +1059,7 @@ DeletePgAttributeTuples(Relation rel)
 												   Int16GetDatum(attnum),
 														   0, 0)))
 		{
-			heap_delete(pg_attribute_desc, &tup->t_ctid);
+			heap_delete(pg_attribute_desc, &tup->t_self);
 			pfree(tup);
 		}
 	}
@@ -1138,7 +1138,7 @@ DeletePgTypeTuple(Relation rel)
 	 *	stonebraker about this.  -cim 6/19/90
 	 * ----------------
 	 */
-	typoid = tup->t_oid;
+	typoid = tup->t_data->t_oid;
 
 	pg_attribute_desc = heap_openr(AttributeRelationName);
 
@@ -1183,7 +1183,7 @@ DeletePgTypeTuple(Relation rel)
 	 *	we release the read lock on pg_type.  -mer 13 Aug 1991
 	 * ----------------
 	 */
-	heap_delete(pg_type_desc, &tup->t_ctid);
+	heap_delete(pg_type_desc, &tup->t_self);
 
 	heap_endscan(pg_type_scan);
 	heap_close(pg_type_desc);
@@ -1604,7 +1604,7 @@ RemoveAttrDefault(Relation rel)
 	adscan = heap_beginscan(adrel, 0, SnapshotNow, 1, &key);
 
 	while (HeapTupleIsValid(tup = heap_getnext(adscan, 0)))
-		heap_delete(adrel, &tup->t_ctid);
+		heap_delete(adrel, &tup->t_self);
 
 	heap_endscan(adscan);
 
@@ -1631,7 +1631,7 @@ RemoveRelCheck(Relation rel)
 	rcscan = heap_beginscan(rcrel, 0, SnapshotNow, 1, &key);
 
 	while (HeapTupleIsValid(tup = heap_getnext(rcscan, 0)))
-		heap_delete(rcrel, &tup->t_ctid);
+		heap_delete(rcrel, &tup->t_self);
 
 	heap_endscan(rcscan);
 
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index ce48422687b09f995fd2930c690d8da6a18e80bf..fd9c3c95d36b28447f18b613cb331d7d86a72db9 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.63 1998/09/10 15:32:16 vadim Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.64 1998/11/27 19:51:49 vadim Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -150,7 +150,7 @@ RelationNameGetObjectId(char *relationName,
 									0, 0, 0);
 
 		if (HeapTupleIsValid(tuple))
-			return tuple->t_oid;
+			return tuple->t_data->t_oid;
 		else
 			return InvalidOid;
 	}
@@ -176,7 +176,7 @@ RelationNameGetObjectId(char *relationName,
 	if (!HeapTupleIsValid(pg_class_tuple))
 		relationObjectId = InvalidOid;
 	else
-		relationObjectId = pg_class_tuple->t_oid;
+		relationObjectId = pg_class_tuple->t_data->t_oid;
 
 	/* ----------------
 	 *	cleanup and return results
@@ -412,7 +412,7 @@ ConstructTupleDescriptor(Oid heapoid,
 			if (!HeapTupleIsValid(tup))
 				elog(ERROR, "create index: type '%s' undefined",
 					 IndexKeyType->name);
-			((Form_pg_attribute) to)->atttypid = tup->t_oid;
+			((Form_pg_attribute) to)->atttypid = tup->t_data->t_oid;
 			((Form_pg_attribute) to)->attbyval =
 				((Form_pg_type) GETSTRUCT(tup))->typbyval;
 			((Form_pg_attribute) to)->attlen =
@@ -558,7 +558,7 @@ UpdateRelationRelation(Relation indexRelation)
 	 *	company.
 	 * ----------------
 	 */
-	tuple->t_oid = RelationGetRelid(indexRelation);
+	tuple->t_data->t_oid = RelationGetRelid(indexRelation);
 	heap_insert(pg_class, tuple);
 
 	/*
@@ -575,7 +575,7 @@ UpdateRelationRelation(Relation indexRelation)
 		CatalogCloseIndices(Num_pg_class_indices, idescs);
 	}
 
-	tupleOid = tuple->t_oid;
+	tupleOid = tuple->t_data->t_oid;
 	pfree(tuple);
 	heap_close(pg_class);
 
@@ -913,7 +913,7 @@ UpdateIndexPredicate(Oid indexoid, Node *oldPred, Node *predicate)
 
 	newtup = heap_modifytuple(tuple, pg_index, values, nulls, replace);
 
-	heap_replace(pg_index, &newtup->t_ctid, newtup);
+	heap_replace(pg_index, &newtup->t_self, newtup);
 
 	pfree(newtup);
 	heap_close(pg_index);
@@ -1104,7 +1104,7 @@ index_create(char *heapRelationName,
 			func_error("index_create", FIgetname(funcInfo),
 					 FIgetnArgs(funcInfo), FIgetArglist(funcInfo), NULL);
 		}
-		FIgetProcOid(funcInfo) = proc_tup->t_oid;
+		FIgetProcOid(funcInfo) = proc_tup->t_data->t_oid;
 	}
 
 	/* ----------------
@@ -1195,7 +1195,7 @@ index_destroy(Oid indexId)
 
 	AssertState(HeapTupleIsValid(tuple));
 
-	heap_delete(relationRelation, &tuple->t_ctid);
+	heap_delete(relationRelation, &tuple->t_self);
 	pfree(tuple);
 	heap_close(relationRelation);
 
@@ -1212,7 +1212,7 @@ index_destroy(Oid indexId)
 												   Int16GetDatum(attnum),
 															0, 0)))
 	{
-		heap_delete(attributeRelation, &tuple->t_ctid);
+		heap_delete(attributeRelation, &tuple->t_self);
 		pfree(tuple);
 		attnum++;
 	}
@@ -1232,7 +1232,7 @@ index_destroy(Oid indexId)
 
 	indexRelation = heap_openr(IndexRelationName);
 
-	heap_delete(indexRelation, &tuple->t_ctid);
+	heap_delete(indexRelation, &tuple->t_self);
 	pfree(tuple);
 	heap_close(indexRelation);
 
@@ -1424,7 +1424,7 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
 		values[Anum_pg_class_relhasindex - 1] = CharGetDatum(hasindex);
 
 		newtup = heap_modifytuple(tuple, pg_class, values, nulls, replace);
-		heap_replace(pg_class, &tuple->t_ctid, newtup);
+		heap_replace(pg_class, &tuple->t_self, newtup);
 		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);
@@ -1626,10 +1626,10 @@ DefaultBuild(Relation heapRelation,
 									 datum,
 									 nullv);
 
-		indexTuple->t_tid = heapTuple->t_ctid;
+		indexTuple->t_tid = heapTuple->t_self;
 
 		insertResult = index_insert(indexRelation, datum, nullv,
-									&(heapTuple->t_ctid), heapRelation);
+									&(heapTuple->t_self), heapRelation);
 
 		if (insertResult)
 			pfree(insertResult);
diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c
index ef80c648b7fe5f1eaa40c53b3461a3c216f932c7..a11e668e162222bf7a83db403eae0a7fc0f569ce 100644
--- a/src/backend/catalog/indexing.c
+++ b/src/backend/catalog/indexing.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.33 1998/10/02 05:10:10 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.34 1998/11/27 19:51:50 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -161,7 +161,7 @@ CatalogIndexInsert(Relation *idescs,
 					   finfoP);
 
 		indexRes = index_insert(idescs[i], datum, nulls,
-								&heapTuple->t_ctid, heapRelation);
+								&heapTuple->t_self, heapRelation);
 		if (indexRes)
 			pfree(indexRes);
 
@@ -228,30 +228,32 @@ CatalogIndexFetchTuple(Relation heapRelation,
 					   ScanKey skey,
 					   int16 num_keys)
 {
-	IndexScanDesc sd;
+	IndexScanDesc		sd;
 	RetrieveIndexResult indexRes;
-	HeapTuple	tuple = NULL;
-	Buffer		buffer;
+	HeapTupleData		tuple;
+	HeapTuple			result = NULL;
+	Buffer				buffer;
 
 	sd = index_beginscan(idesc, false, num_keys, skey);
+	tuple.t_data = NULL;
 	while ((indexRes = index_getnext(sd, ForwardScanDirection)))
 	{
-		tuple = heap_fetch(heapRelation, SnapshotNow, &indexRes->heap_iptr,
-							&buffer);
+		tuple.t_self = indexRes->heap_iptr;
+		heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer);
 		pfree(indexRes);
-		if (HeapTupleIsValid(tuple))
+		if (tuple.t_data != NULL)
 			break;
 	}
 
-	if (HeapTupleIsValid(tuple))
+	if (tuple.t_data != NULL)
 	{
-		tuple = heap_copytuple(tuple);
+		result = heap_copytuple(&tuple);
 		ReleaseBuffer(buffer);
 	}
 
 	index_endscan(sd);
 	pfree(sd);
-	return tuple;
+	return result;
 }
 
 
diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c
index 00b16c20f69f6c341b0a2753fc7e6f60aab6d9cb..4dba8740ee27b715bb152fce62c8006df3efd6d9 100644
--- a/src/backend/catalog/pg_aggregate.c
+++ b/src/backend/catalog/pg_aggregate.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.17 1998/09/01 04:27:34 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.18 1998/11/27 19:51:50 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -95,7 +95,7 @@ AggregateCreate(char *aggName,
 							  0, 0, 0);
 	if (!HeapTupleIsValid(tup))
 		elog(ERROR, "AggregateCreate: Type '%s' undefined", aggbasetypeName);
-	xbase = tup->t_oid;
+	xbase = tup->t_data->t_oid;
 
 	if (aggtransfn1Name)
 	{
@@ -105,7 +105,7 @@ AggregateCreate(char *aggName,
 		if (!HeapTupleIsValid(tup))
 			elog(ERROR, "AggregateCreate: Type '%s' undefined",
 				 aggtransfn1typeName);
-		xret1 = tup->t_oid;
+		xret1 = tup->t_data->t_oid;
 
 		fnArgs[0] = xret1;
 		fnArgs[1] = xbase;
@@ -121,7 +121,7 @@ AggregateCreate(char *aggName,
 			elog(ERROR, "AggregateCreate: return type of '%s' is not '%s'",
 				 aggtransfn1Name,
 				 aggtransfn1typeName);
-		xfn1 = tup->t_oid;
+		xfn1 = tup->t_data->t_oid;
 		if (!OidIsValid(xfn1) || !OidIsValid(xret1) ||
 			!OidIsValid(xbase))
 			elog(ERROR, "AggregateCreate: bogus function '%s'", aggfinalfnName);
@@ -135,7 +135,7 @@ AggregateCreate(char *aggName,
 		if (!HeapTupleIsValid(tup))
 			elog(ERROR, "AggregateCreate: Type '%s' undefined",
 				 aggtransfn2typeName);
-		xret2 = tup->t_oid;
+		xret2 = tup->t_data->t_oid;
 
 		fnArgs[0] = xret2;
 		fnArgs[1] = 0;
@@ -150,7 +150,7 @@ AggregateCreate(char *aggName,
 		if (((Form_pg_proc) GETSTRUCT(tup))->prorettype != xret2)
 			elog(ERROR, "AggregateCreate: return type of '%s' is not '%s'",
 				 aggtransfn2Name, aggtransfn2typeName);
-		xfn2 = tup->t_oid;
+		xfn2 = tup->t_data->t_oid;
 		if (!OidIsValid(xfn2) || !OidIsValid(xret2))
 			elog(ERROR, "AggregateCreate: bogus function '%s'", aggfinalfnName);
 	}
@@ -183,7 +183,7 @@ AggregateCreate(char *aggName,
 		if (!HeapTupleIsValid(tup))
 			elog(ERROR, "AggregateCreate: '%s'('%s','%s') does not exist",
 			   aggfinalfnName, aggtransfn1typeName, aggtransfn2typeName);
-		ffn = tup->t_oid;
+		ffn = tup->t_data->t_oid;
 		proc = (Form_pg_proc) GETSTRUCT(tup);
 		fret = proc->prorettype;
 		if (!OidIsValid(ffn) || !OidIsValid(fret))
diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c
index a296c9057c29ef4c26c68a80630b84b2ef3760ed..96fb9ae35f6909377e9c2da6a4d2fb93c9e6908d 100644
--- a/src/backend/catalog/pg_operator.c
+++ b/src/backend/catalog/pg_operator.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.29 1998/09/01 04:27:36 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.30 1998/11/27 19:51:50 vadim Exp $
  *
  * NOTES
  *	  these routines moved here from commands/define.c and somewhat cleaned up.
@@ -125,7 +125,7 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc,
 	 * ----------------
 	 */
 	tup = heap_getnext(pg_operator_scan, 0);
-	operatorObjectId = HeapTupleIsValid(tup) ? tup->t_oid : InvalidOid;
+	operatorObjectId = HeapTupleIsValid(tup) ? tup->t_data->t_oid : InvalidOid;
 
 	/* ----------------
 	 *	close the scan and return the oid.
@@ -279,7 +279,7 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc,
 	 * ----------------
 	 */
 	heap_insert(pg_operator_desc, tup);
-	operatorObjectId = tup->t_oid;
+	operatorObjectId = tup->t_data->t_oid;
 
 	/* ----------------
 	 *	free the tuple and return the operator oid
@@ -413,7 +413,7 @@ OperatorShellMake(char *operatorName,
  * if the operator shell is being filled in
  *	 access the catalog in order to get a valid buffer
  *	 create a tuple using ModifyHeapTuple
- *	 get the t_ctid from the modified tuple and call RelationReplaceHeapTuple
+ *	 get the t_self from the modified tuple and call RelationReplaceHeapTuple
  * else if a new operator is being created
  *	 create a tuple using heap_formtuple
  *	 call heap_insert
@@ -544,7 +544,7 @@ OperatorDef(char *operatorName,
 	if (!HeapTupleIsValid(tup))
 		func_error("OperatorDef", procedureName, nargs, typeId, NULL);
 
-	values[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(tup->t_oid);
+	values[Anum_pg_operator_oprcode - 1] = ObjectIdGetDatum(tup->t_data->t_oid);
 	values[Anum_pg_operator_oprresult - 1] =
 		ObjectIdGetDatum(((Form_pg_proc)
 						  GETSTRUCT(tup))->prorettype);
@@ -569,7 +569,7 @@ OperatorDef(char *operatorName,
 		if (!HeapTupleIsValid(tup))
 			func_error("OperatorDef", restrictionName, 5, typeId, NULL);
 
-		values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(tup->t_oid);
+		values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(tup->t_data->t_oid);
 	}
 	else
 		values[Anum_pg_operator_oprrest - 1] = ObjectIdGetDatum(InvalidOid);
@@ -595,7 +595,7 @@ OperatorDef(char *operatorName,
 		if (!HeapTupleIsValid(tup))
 			func_error("OperatorDef", joinName, 5, typeId, NULL);
 
-		values[Anum_pg_operator_oprjoin - 1] = ObjectIdGetDatum(tup->t_oid);
+		values[Anum_pg_operator_oprjoin - 1] = ObjectIdGetDatum(tup->t_data->t_oid);
 	}
 	else
 		values[Anum_pg_operator_oprjoin - 1] = ObjectIdGetDatum(InvalidOid);
@@ -685,7 +685,7 @@ OperatorDef(char *operatorName,
 	/* last three fields were filled in first */
 
 	/*
-	 * If we are adding to an operator shell, get its t_ctid
+	 * If we are adding to an operator shell, get its t_self
 	 */
 	pg_operator_desc = heap_openr(OperatorRelationName);
 
@@ -711,7 +711,7 @@ OperatorDef(char *operatorName,
 								   replaces);
 
 			setheapoverride(true);
-			heap_replace(pg_operator_desc, &tup->t_ctid, tup);
+			heap_replace(pg_operator_desc, &tup->t_self, tup);
 			setheapoverride(false);
 		}
 		else
@@ -725,7 +725,7 @@ OperatorDef(char *operatorName,
 		tup = heap_formtuple(tupDesc, values, nulls);
 
 		heap_insert(pg_operator_desc, tup);
-		operatorObjectId = tup->t_oid;
+		operatorObjectId = tup->t_data->t_oid;
 	}
 
 	heap_close(pg_operator_desc);
@@ -830,7 +830,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
 									   replaces);
 
 				setheapoverride(true);
-				heap_replace(pg_operator_desc, &tup->t_ctid, tup);
+				heap_replace(pg_operator_desc, &tup->t_self, tup);
 				setheapoverride(false);
 
 			}
@@ -855,7 +855,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
 							   replaces);
 
 		setheapoverride(true);
-		heap_replace(pg_operator_desc, &tup->t_ctid, tup);
+		heap_replace(pg_operator_desc, &tup->t_self, tup);
 		setheapoverride(false);
 
 		values[Anum_pg_operator_oprcom - 1] = (Datum) NULL;
@@ -884,7 +884,7 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId)
 							   replaces);
 
 		setheapoverride(true);
-		heap_replace(pg_operator_desc, &tup->t_ctid, tup);
+		heap_replace(pg_operator_desc, &tup->t_self, tup);
 		setheapoverride(false);
 	}
 
diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c
index 074bda3876790bde95842d06312a5b9a89fb02d1..78e56c028fd0ac0745e6f9b8fd55ca441fc7ec0e 100644
--- a/src/backend/catalog/pg_proc.c
+++ b/src/backend/catalog/pg_proc.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.23 1998/09/01 04:27:37 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.24 1998/11/27 19:51:51 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -144,7 +144,7 @@ ProcedureCreate(char *procedureName,
 									  0, 0, 0);
 			pfree(prosrctext);
 			if (HeapTupleIsValid(tup))
-				return tup->t_oid;
+				return tup->t_data->t_oid;
 		}
 	}
 
@@ -155,7 +155,7 @@ ProcedureCreate(char *procedureName,
 	if (!HeapTupleIsValid(tup))
 		elog(ERROR, "ProcedureCreate: no such language %s", languageName);
 
-	languageObjectId = tup->t_oid;
+	languageObjectId = tup->t_data->t_oid;
 
 	if (strcmp(returnTypeName, "opaque") == 0)
 	{
@@ -276,5 +276,5 @@ ProcedureCreate(char *procedureName,
 		CatalogCloseIndices(Num_pg_proc_indices, idescs);
 	}
 	heap_close(rel);
-	return tup->t_oid;
+	return tup->t_data->t_oid;
 }
diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c
index d9f9023f3165ced2613572d20759ead1b45c0f24..f46bb8f3a2abf2a139f2bfd4249e294b79ed0f43 100644
--- a/src/backend/catalog/pg_type.c
+++ b/src/backend/catalog/pg_type.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.30 1998/09/01 04:27:39 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.31 1998/11/27 19:51:51 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -99,7 +99,7 @@ TypeGetWithOpenRelation(Relation pg_type_desc,
 	heap_endscan(scan);
 	*defined = (bool) ((Form_pg_type) GETSTRUCT(tup))->typisdefined;
 
-	return tup->t_oid;
+	return tup->t_data->t_oid;
 }
 
 /* ----------------------------------------------------------------
@@ -212,7 +212,7 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName)
 	 * ----------------
 	 */
 	heap_insert(pg_type_desc, tup);
-	typoid = tup->t_oid;
+	typoid = tup->t_data->t_oid;
 
 	if (RelationGetForm(pg_type_desc)->relhasindex)
 	{
@@ -430,7 +430,7 @@ TypeCreate(char *typeName,
 				func_error("TypeCreate", procname, 1, argList, NULL);
 		}
 
-		values[i++] = (Datum) tup->t_oid;		/* 11 - 14 */
+		values[i++] = (Datum) tup->t_data->t_oid;		/* 11 - 14 */
 	}
 
 	/* ----------------
@@ -484,10 +484,10 @@ TypeCreate(char *typeName,
 							   replaces);
 
 		setheapoverride(true);
-		heap_replace(pg_type_desc, &tup->t_ctid, tup);
+		heap_replace(pg_type_desc, &tup->t_self, tup);
 		setheapoverride(false);
 
-		typeObjectId = tup->t_oid;
+		typeObjectId = tup->t_data->t_oid;
 	}
 	else
 	{
@@ -499,7 +499,7 @@ TypeCreate(char *typeName,
 
 		heap_insert(pg_type_desc, tup);
 
-		typeObjectId = tup->t_oid;
+		typeObjectId = tup->t_data->t_oid;
 	}
 
 	/* ----------------
@@ -561,7 +561,7 @@ TypeRename(char *oldTypeName, char *newTypeName)
 	namestrcpy(&(((Form_pg_type) GETSTRUCT(oldtup))->typname), newTypeName);
 
 	setheapoverride(true);
-	heap_replace(pg_type_desc, &oldtup->t_ctid, oldtup);
+	heap_replace(pg_type_desc, &oldtup->t_self, oldtup);
 	setheapoverride(false);
 
 	/* update the system catalog indices */
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c
index a8c447cb077b9cbfac6c8aa233f32a2585235fe3..50d4f13cc09c01dd7f3622096824476dd1ab9c2f 100644
--- a/src/backend/commands/async.c
+++ b/src/backend/commands/async.c
@@ -6,7 +6,7 @@
  * Copyright (c) 1994, Regents of the University of California
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.41 1998/10/06 02:39:59 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.42 1998/11/27 19:51:53 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -321,7 +321,7 @@ Async_Unlisten(char *relname, int pid)
 	{
 		lRel = heap_openr(ListenerRelationName);
 		RelationSetLockForWrite(lRel);
-		heap_delete(lRel, &lTuple->t_ctid);
+		heap_delete(lRel, &lTuple->t_self);
 		RelationUnsetLockForWrite(lRel);
 		heap_close(lRel);
 	}
@@ -369,7 +369,7 @@ Async_UnlistenAll()
 	sRel = heap_beginscan(lRel, 0, SnapshotNow, 1, key);
 
 	while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
-		heap_delete(lRel, &lTuple->t_ctid);
+		heap_delete(lRel, &lTuple->t_self);
 
 	heap_endscan(sRel);
 	RelationUnsetLockForWrite(lRel);
@@ -516,7 +516,7 @@ AtCommit_Notify()
 					 * but as far as I can see we should just do it for any
 					 * failure (certainly at least for EPERM too...)
 					 */
-					heap_delete(lRel, &lTuple->t_ctid);
+					heap_delete(lRel, &lTuple->t_self);
 				}
 				else
 #endif
@@ -527,7 +527,7 @@ AtCommit_Notify()
 					{
 						rTuple = heap_modifytuple(lTuple, lRel,
 												  value, nulls, repl);
-						heap_replace(lRel, &lTuple->t_ctid, rTuple);
+						heap_replace(lRel, &lTuple->t_self, rTuple);
 					}
 				}
 			}
@@ -772,7 +772,7 @@ ProcessIncomingNotify(void)
 			NotifyMyFrontEnd(relname, sourcePID);
 			/* Rewrite the tuple with 0 in notification column */
 			rTuple = heap_modifytuple(lTuple, lRel, value, nulls, repl);
-			heap_replace(lRel, &lTuple->t_ctid, rTuple);
+			heap_replace(lRel, &lTuple->t_self, rTuple);
 		}
 	}
 	heap_endscan(sRel);
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 3fba38a351a11661d7311346b1348b37724daaf1..c0be945d88a74778820e0a8b4dd98a5bffd067cd 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -14,7 +14,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.32 1998/09/23 04:22:01 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.33 1998/11/27 19:51:54 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -330,15 +330,14 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
 static void
 rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
 {
-	Relation	LocalNewHeap,
-				LocalOldHeap,
-				LocalOldIndex;
-	IndexScanDesc ScanDesc;
-	RetrieveIndexResult ScanResult;
-	ItemPointer HeapTid;
-	HeapTuple	LocalHeapTuple;
-	Buffer		LocalBuffer;
-	Oid			OIDNewHeapInsert;
+	Relation			LocalNewHeap,
+						LocalOldHeap,
+						LocalOldIndex;
+	IndexScanDesc		ScanDesc;
+	RetrieveIndexResult	ScanResult;
+	HeapTupleData		LocalHeapTuple;
+	Buffer				LocalBuffer;
+	Oid					OIDNewHeapInsert;
 
 	/*
 	 * Open the relations I need. Scan through the OldHeap on the OldIndex
@@ -353,10 +352,10 @@ rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
 	while ((ScanResult = index_getnext(ScanDesc, ForwardScanDirection)) != NULL)
 	{
 
-		HeapTid = &ScanResult->heap_iptr;
-		LocalHeapTuple = heap_fetch(LocalOldHeap, SnapshotNow, HeapTid, &LocalBuffer);
+		LocalHeapTuple.t_self = ScanResult->heap_iptr;
+		heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer);
 		OIDNewHeapInsert =
-			heap_insert(LocalNewHeap, LocalHeapTuple);
+			heap_insert(LocalNewHeap, &LocalHeapTuple);
 		pfree(ScanResult);
 		ReleaseBuffer(LocalBuffer);
 	}
diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c
index 47f6e8ae3ce7e22cc3ad7afa11c06596f2b90526..6cbf8b980cbe33842880953122e2a49c1821d77c 100644
--- a/src/backend/commands/command.c
+++ b/src/backend/commands/command.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.32 1998/09/01 04:27:46 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.33 1998/11/27 19:51:54 vadim Exp $
  *
  * NOTES
  *	  The PortalExecutorHeapMemory crap needs to be eliminated
@@ -405,7 +405,7 @@ PerformAddAttribute(char *relationName,
 	if (hasindex)
 		CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
 
-	attributeD.attrelid = reltup->t_oid;
+	attributeD.attrelid = reltup->t_data->t_oid;
 
 	attributeTuple = heap_addheader(Natts_pg_attribute,
 									sizeof attributeD,
@@ -422,7 +422,7 @@ PerformAddAttribute(char *relationName,
 		int			attnelems;
 
 		tup = SearchSysCacheTuple(ATTNAME,
-								  ObjectIdGetDatum(reltup->t_oid),
+								  ObjectIdGetDatum(reltup->t_data->t_oid),
 								  PointerGetDatum(colDef->colname),
 								  0, 0);
 
@@ -456,7 +456,7 @@ PerformAddAttribute(char *relationName,
 		if (!HeapTupleIsValid(typeTuple))
 			elog(ERROR, "Add: type \"%s\" nonexistent", typename);
 		namestrcpy(&(attribute->attname), colDef->colname);
-		attribute->atttypid = typeTuple->t_oid;
+		attribute->atttypid = typeTuple->t_data->t_oid;
 		attribute->attlen = form->typlen;
 		attributeD.attdisbursion = 0;
 		attribute->attcacheoff = -1;
@@ -482,7 +482,7 @@ PerformAddAttribute(char *relationName,
 	heap_close(attrdesc);
 
 	((Form_pg_class) GETSTRUCT(reltup))->relnatts = maxatts;
-	heap_replace(rel, &reltup->t_ctid, reltup);
+	heap_replace(rel, &reltup->t_self, reltup);
 
 	/* keep catalog indices current */
 	CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 51e91e7c8bef0e510f9c7ac8dfb32721fdaad147..419874e5d49d737b3b420a46567f7051037acebc 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -6,7 +6,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.63 1998/10/26 00:59:21 tgl Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.64 1998/11/27 19:51:54 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -277,7 +277,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
 
 		if (oids && !binary)
 		{
-			fputs(oidout(tuple->t_oid), fp);
+			fputs(oidout(tuple->t_data->t_oid), fp);
 			fputc(delim[0], fp);
 		}
 
@@ -331,10 +331,10 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
 					null_ct++;
 			}
 
-			length = tuple->t_len - tuple->t_hoff;
+			length = tuple->t_len - tuple->t_data->t_hoff;
 			fwrite(&length, sizeof(int32), 1, fp);
 			if (oids)
-				fwrite((char *) &tuple->t_oid, sizeof(int32), 1, fp);
+				fwrite((char *) &tuple->t_data->t_oid, sizeof(int32), 1, fp);
 
 			fwrite(&null_ct, sizeof(int32), 1, fp);
 			if (null_ct > 0)
@@ -348,7 +348,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
 					}
 				}
 			}
-			fwrite((char *) tuple + tuple->t_hoff, length, 1, fp);
+			fwrite((char *) tuple->t_data + tuple->t_data->t_hoff, 
+					length, 1, fp);
 		}
 	}
 
@@ -678,7 +679,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
 		 */
 		tuple = heap_formtuple(tupDesc, values, nulls);
 		if (oids)
-			tuple->t_oid = loaded_oid;
+			tuple->t_data->t_oid = loaded_oid;
 
 		skip_tuple = false;
 		/* BEFORE ROW INSERT Triggers */
@@ -706,17 +707,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
 			 */
 
 			if (rel->rd_att->constr)
-			{
-				HeapTuple	newtuple;
-
-				newtuple = ExecConstraints("CopyFrom", rel, tuple);
-
-				if (newtuple != tuple)
-				{
-					pfree(tuple);
-					tuple = newtuple;
-				}
-			}
+				ExecConstraints("CopyFrom", rel, tuple);
 
 			heap_insert(rel, tuple);
 
@@ -746,7 +737,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
 								   index_nulls,
 								   finfoP[i]);
 					indexRes = index_insert(index_rels[i], idatum, index_nulls,
-											&(tuple->t_ctid), rel);
+											&(tuple->t_self), rel);
 					if (indexRes)
 						pfree(indexRes);
 				}
diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c
index 8338be3039f0d4670033ad432fc23060ef947091..0617452f18cf7a80364fee4e14052b48842b6d1c 100644
--- a/src/backend/commands/creatinh.c
+++ b/src/backend/commands/creatinh.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.35 1998/10/01 22:45:29 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.36 1998/11/27 19:51:55 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -409,11 +409,11 @@ StoreCatalogInheritance(Oid relationId, List *supers)
 		/*
 		 * build idList for use below
 		 */
-		idList = lappendi(idList, tuple->t_oid);
+		idList = lappendi(idList, tuple->t_data->t_oid);
 
-		datum[0] = ObjectIdGetDatum(relationId);		/* inhrel */
-		datum[1] = ObjectIdGetDatum(tuple->t_oid);		/* inhparent */
-		datum[2] = Int16GetDatum(seqNumber);	/* inhseqno */
+		datum[0] = ObjectIdGetDatum(relationId);			/* inhrel */
+		datum[1] = ObjectIdGetDatum(tuple->t_data->t_oid);	/* inhparent */
+		datum[2] = Int16GetDatum(seqNumber);				/* inhseqno */
 
 		nullarr[0] = ' ';
 		nullarr[1] = ' ';
diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c
index 5823385fad09325ba11c15f2bc7eac860d0b6960..62474e0e3b7fc5f43fa6e01e837e96154eda6699 100644
--- a/src/backend/commands/dbcommands.c
+++ b/src/backend/commands/dbcommands.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.25 1998/10/05 02:49:36 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.26 1998/11/27 19:51:56 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -251,7 +251,7 @@ check_permissions(char *command,
 									  Anum_pg_database_datdba,
 									  RelationGetDescr(dbrel),
 									  (char *) NULL);
-		*dbIdP = dbtup->t_oid;
+		*dbIdP = dbtup->t_data->t_oid;
 		dbtext = (text *) heap_getattr(dbtup,
 									   Anum_pg_database_datpath,
 									   RelationGetDescr(dbrel),
diff --git a/src/backend/commands/defind.c b/src/backend/commands/defind.c
index f0d985d3a93a9aef909af4faaf86b31a48604138..c071c2d9fe829e07de9734d513f6a5e6c6731ff2 100644
--- a/src/backend/commands/defind.c
+++ b/src/backend/commands/defind.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.27 1998/09/23 04:22:03 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.28 1998/11/27 19:51:56 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -105,7 +105,7 @@ DefineIndex(char *heapRelationName,
 		elog(ERROR, "DefineIndex: %s relation not found",
 			 heapRelationName);
 	}
-	relationId = tuple->t_oid;
+	relationId = tuple->t_data->t_oid;
 
 	if (unique && strcmp(accessMethodName, "btree") != 0)
 		elog(ERROR, "DefineIndex: unique indices are only available with the btree access method");
@@ -124,7 +124,7 @@ DefineIndex(char *heapRelationName,
 		elog(ERROR, "DefineIndex: %s access method not found",
 			 accessMethodName);
 	}
-	accessMethodId = tuple->t_oid;
+	accessMethodId = tuple->t_data->t_oid;
 
 
 	/*
@@ -250,7 +250,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
 		elog(ERROR, "ExtendIndex: %s index not found",
 			 indexRelationName);
 	}
-	indexId = tuple->t_oid;
+	indexId = tuple->t_data->t_oid;
 	accessMethodId = ((Form_pg_class) GETSTRUCT(tuple))->relam;
 
 	/*
@@ -336,7 +336,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
 		namecpy(&(funcInfo->funcName),
 				&(((Form_pg_proc) GETSTRUCT(tuple))->proname));
 
-		FIsetProcOid(funcInfo, tuple->t_oid);
+		FIsetProcOid(funcInfo, tuple->t_data->t_oid);
 	}
 
 	heapRelation = heap_open(relationId);
@@ -429,7 +429,7 @@ FuncIndexArgs(IndexElem *funcIndex,
 		elog(ERROR, "DefineIndex: %s class not found",
 			 funcIndex->class);
 	}
-	*opOidP = tuple->t_oid;
+	*opOidP = tuple->t_data->t_oid;
 
 	MemSet(argTypes, 0, 8 * sizeof(Oid));
 
@@ -531,7 +531,7 @@ NormIndexAttrs(List *attList,	/* list of IndexElem's */
 			elog(ERROR, "DefineIndex: %s class not found",
 				 attribute->class);
 		}
-		*classOidP++ = tuple->t_oid;
+		*classOidP++ = tuple->t_data->t_oid;
 		pfree(atttuple);
 	}
 }
@@ -578,5 +578,5 @@ RemoveIndex(char *name)
 			 ((Form_pg_class) GETSTRUCT(tuple))->relkind);
 	}
 
-	index_destroy(tuple->t_oid);
+	index_destroy(tuple->t_data->t_oid);
 }
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index 86f24d967837d46522e8ddba8a828f19db67af2c..c8b4e836f021eb9e755d071cedfb5a6394a35344 100644
--- a/src/backend/commands/proclang.c
+++ b/src/backend/commands/proclang.c
@@ -118,7 +118,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
 	values[i++] = PointerGetDatum(languageName);
 	values[i++] = Int8GetDatum((bool) 1);
 	values[i++] = Int8GetDatum(stmt->pltrusted);
-	values[i++] = ObjectIdGetDatum(procTup->t_oid);
+	values[i++] = ObjectIdGetDatum(procTup->t_data->t_oid);
 	values[i++] = (Datum) fmgr(F_TEXTIN, stmt->plcompiler);
 
 	rel = heap_openr(LanguageRelationName);
@@ -174,7 +174,7 @@ DropProceduralLanguage(DropPLangStmt *stmt)
 	}
 
 	rel = heap_openr(LanguageRelationName);
-	heap_delete(rel, &langTup->t_ctid);
+	heap_delete(rel, &langTup->t_self);
 
 	pfree(langTup);
 	heap_close(rel);
diff --git a/src/backend/commands/remove.c b/src/backend/commands/remove.c
index cc68739f5352c12ebdacb52ad0412a4b43bf314c..e662e90ec56ad0f67c8b74d7ab2273935fc33df8 100644
--- a/src/backend/commands/remove.c
+++ b/src/backend/commands/remove.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.29 1998/09/01 04:27:57 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.30 1998/11/27 19:51:57 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -97,12 +97,12 @@ RemoveOperator(char *operatorName,		/* operator name */
 #ifndef NO_SECURITY
 		userName = GetPgUserName();
 		if (!pg_ownercheck(userName,
-						   (char *) ObjectIdGetDatum(tup->t_oid),
+						   (char *) ObjectIdGetDatum(tup->t_data->t_oid),
 						   OPROID))
 			elog(ERROR, "RemoveOperator: operator '%s': permission denied",
 				 operatorName);
 #endif
-		heap_delete(relation, &tup->t_ctid);
+		heap_delete(relation, &tup->t_self);
 	}
 	else
 	{
@@ -157,7 +157,7 @@ SingleOpOperatorRemove(Oid typeOid)
 		key[0].sk_attno = attnums[i];
 		scan = heap_beginscan(rel, 0, SnapshotNow, 1, key);
 		while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
-			heap_delete(rel, &tup->t_ctid);
+			heap_delete(rel, &tup->t_self);
 		heap_endscan(scan);
 	}
 	heap_close(rel);
@@ -267,8 +267,8 @@ RemoveType(char *typeName)		/* type name to be removed */
 	}
 
 	relation = heap_openr(TypeRelationName);
-	typeOid = tup->t_oid;
-	heap_delete(relation, &tup->t_ctid);
+	typeOid = tup->t_data->t_oid;
+	heap_delete(relation, &tup->t_self);
 
 	/* Now, Delete the "array of" that type */
 	shadow_type = makeArrayTypeName(typeName);
@@ -281,8 +281,8 @@ RemoveType(char *typeName)		/* type name to be removed */
 		elog(ERROR, "RemoveType: type '%s' does not exist", typeName);
 	}
 
-	typeOid = tup->t_oid;
-	heap_delete(relation, &tup->t_ctid);
+	typeOid = tup->t_data->t_oid;
+	heap_delete(relation, &tup->t_self);
 
 	heap_close(relation);
 }
@@ -325,7 +325,7 @@ RemoveFunction(char *functionName,		/* function name to be removed */
 
 			if (!HeapTupleIsValid(tup))
 				elog(ERROR, "RemoveFunction: type '%s' not found", typename);
-			argList[i] = tup->t_oid;
+			argList[i] = tup->t_data->t_oid;
 		}
 	}
 
@@ -357,7 +357,7 @@ RemoveFunction(char *functionName,		/* function name to be removed */
 		elog(ERROR, "RemoveFunction: function \"%s\" is built-in", functionName);
 	}
 
-	heap_delete(relation, &tup->t_ctid);
+	heap_delete(relation, &tup->t_self);
 
 	heap_close(relation);
 }
@@ -428,7 +428,7 @@ RemoveAggregate(char *aggName, char *aggType)
 				 aggName);
 		}
 	}
-	heap_delete(relation, &tup->t_ctid);
+	heap_delete(relation, &tup->t_self);
 
 	heap_close(relation);
 }
diff --git a/src/backend/commands/rename.c b/src/backend/commands/rename.c
index 31f193d05359815cbd42dc494a60e22aaaafa13e..c423da11963da24a977ca534402ff58a12a76b66 100644
--- a/src/backend/commands/rename.c
+++ b/src/backend/commands/rename.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.17 1998/09/01 04:27:59 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.18 1998/11/27 19:51:57 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -113,7 +113,7 @@ renameatt(char *relname,
 		if (!HeapTupleIsValid(reltup))
 			elog(ERROR, "renameatt: unknown relation: \"%s\"", relname);
 
-		myrelid = reltup->t_oid;
+		myrelid = reltup->t_data->t_oid;
 
 		/* this routine is actually in the planner */
 		children = find_all_inheritors(lconsi(myrelid, NIL), NIL);
@@ -153,7 +153,7 @@ renameatt(char *relname,
 	if (!HeapTupleIsValid(reltup))
 		elog(ERROR, "renameatt: relation \"%s\" nonexistent", relname);
 
-	relid = reltup->t_oid;
+	relid = reltup->t_data->t_oid;
 
 	oldatttup = SearchSysCacheTupleCopy(ATTNAME,
 										ObjectIdGetDatum(relid),
@@ -180,7 +180,7 @@ renameatt(char *relname,
 			newattname, NAMEDATALEN);
 
 	attrelation = heap_openr(AttributeRelationName);
-	heap_replace(attrelation, &oldatttup->t_ctid, oldatttup);
+	heap_replace(attrelation, &oldatttup->t_self, oldatttup);
 
 	/* keep system catalog indices current */
 	CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
@@ -248,7 +248,7 @@ renamerel(char *oldrelname, char *newrelname)
 
 	/* insert fixed rel tuple */
 	relrelation = heap_openr(RelationRelationName);
-	heap_replace(relrelation, &oldreltup->t_ctid, oldreltup);
+	heap_replace(relrelation, &oldreltup->t_self, oldreltup);
 
 	/* keep the system catalog indices current */
 	CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, irelations);
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 7d9bd1d660925d7106f48712bf71ca06159f43c7..9edec5a9dc65c48ef842ef1c9981c678d5de5efe 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -368,7 +368,7 @@ read_info(char *caller, SeqTable elm, Buffer *buf)
 	ItemPointerData iptr;
 	PageHeader	page;
 	ItemId		lp;
-	HeapTuple	tuple;
+	HeapTupleData	tuple;
 	sequence_magic *sm;
 	Form_pg_sequence seq;
 
@@ -391,9 +391,9 @@ read_info(char *caller, SeqTable elm, Buffer *buf)
 
 	lp = PageGetItemId(page, FirstOffsetNumber);
 	Assert(ItemIdIsUsed(lp));
-	tuple = (HeapTuple) PageGetItem((Page) page, lp);
+	tuple.t_data = (HeapTupleHeader) PageGetItem((Page) page, lp);
 
-	seq = (Form_pg_sequence) GETSTRUCT(tuple);
+	seq = (Form_pg_sequence) GETSTRUCT(&tuple);
 
 	elm->increment = seq->increment_by;
 
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c
index 9636466bffb59476911301de1b3a40875fb6178d..431a70a6ff9e9037fe1975589462fd588a395356 100644
--- a/src/backend/commands/trigger.c
+++ b/src/backend/commands/trigger.c
@@ -159,7 +159,7 @@ CreateTrigger(CreateTrigStmt *stmt)
 
 	values[Anum_pg_trigger_tgrelid - 1] = ObjectIdGetDatum(RelationGetRelid(rel));
 	values[Anum_pg_trigger_tgname - 1] = NameGetDatum(namein(stmt->trigname));
-	values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(tuple->t_oid);
+	values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(tuple->t_data->t_oid);
 	values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype);
 	if (stmt->args)
 	{
@@ -227,7 +227,7 @@ CreateTrigger(CreateTrigStmt *stmt)
 	pgrel = heap_openr(RelationRelationName);
 	((Form_pg_class) GETSTRUCT(tuple))->reltriggers = found + 1;
 	RelationInvalidateHeapTuple(pgrel, tuple);
-	heap_replace(pgrel, &tuple->t_ctid, tuple);
+	heap_replace(pgrel, &tuple->t_self, tuple);
 	CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
 	CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple);
 	CatalogCloseIndices(Num_pg_class_indices, ridescs);
@@ -280,7 +280,7 @@ DropTrigger(DropTrigStmt *stmt)
 
 		if (namestrcmp(&(pg_trigger->tgname), stmt->trigname) == 0)
 		{
-			heap_delete(tgrel, &tuple->t_ctid);
+			heap_delete(tgrel, &tuple->t_self);
 			tgfound++;
 		}
 		else
@@ -306,7 +306,7 @@ DropTrigger(DropTrigStmt *stmt)
 	pgrel = heap_openr(RelationRelationName);
 	((Form_pg_class) GETSTRUCT(tuple))->reltriggers = found;
 	RelationInvalidateHeapTuple(pgrel, tuple);
-	heap_replace(pgrel, &tuple->t_ctid, tuple);
+	heap_replace(pgrel, &tuple->t_self, tuple);
 	CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
 	CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple);
 	CatalogCloseIndices(Num_pg_class_indices, ridescs);
@@ -340,7 +340,7 @@ RelationRemoveTriggers(Relation rel)
 	tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
 
 	while (HeapTupleIsValid(tup = heap_getnext(tgscan, 0)))
-		heap_delete(tgrel, &tup->t_ctid);
+		heap_delete(tgrel, &tup->t_self);
 
 	heap_endscan(tgscan);
 	RelationUnsetLockForWrite(tgrel);
@@ -359,11 +359,10 @@ RelationBuildTriggers(Relation relation)
 	Form_pg_trigger pg_trigger;
 	Relation	irel;
 	ScanKeyData skey;
-	HeapTuple	tuple;
-	IndexScanDesc sd;
-	RetrieveIndexResult indexRes;
+	HeapTupleData	tuple;
+	IndexScanDesc	sd;
+	RetrieveIndexResult	indexRes;
 	Buffer		buffer;
-	ItemPointer iptr;
 	struct varlena *val;
 	bool		isnull;
 	int			found;
@@ -387,16 +386,16 @@ RelationBuildTriggers(Relation relation)
 		if (!indexRes)
 			break;
 
-		iptr = &indexRes->heap_iptr;
-		tuple = heap_fetch(tgrel, SnapshotNow, iptr, &buffer);
+		tuple.t_self = indexRes->heap_iptr;
+		heap_fetch(tgrel, SnapshotNow, &tuple, &buffer);
 		pfree(indexRes);
-		if (!HeapTupleIsValid(tuple))
+		if (!tuple.t_data)
 			continue;
 		if (found == ntrigs)
 			elog(ERROR, "RelationBuildTriggers: unexpected record found for rel %.*s",
 				 NAMEDATALEN, relation->rd_rel->relname.data);
 
-		pg_trigger = (Form_pg_trigger) GETSTRUCT(tuple);
+		pg_trigger = (Form_pg_trigger) GETSTRUCT(&tuple);
 
 		if (triggers == NULL)
 			triggers = (Trigger *) palloc(sizeof(Trigger));
@@ -410,7 +409,7 @@ RelationBuildTriggers(Relation relation)
 		build->tgtype = pg_trigger->tgtype;
 		build->tgnargs = pg_trigger->tgnargs;
 		memcpy(build->tgattr, &(pg_trigger->tgattr), 8 * sizeof(int16));
-		val = (struct varlena *) fastgetattr(tuple,
+		val = (struct varlena *) fastgetattr(&tuple,
 											 Anum_pg_trigger_tgargs,
 											 tgrel->rd_att, &isnull);
 		if (isnull)
@@ -421,7 +420,7 @@ RelationBuildTriggers(Relation relation)
 			char	   *p;
 			int			i;
 
-			val = (struct varlena *) fastgetattr(tuple,
+			val = (struct varlena *) fastgetattr(&tuple,
 												 Anum_pg_trigger_tgargs,
 												 tgrel->rd_att, &isnull);
 			if (isnull)
@@ -792,10 +791,11 @@ ExecARUpdateTriggers(Relation rel, ItemPointer tupleid, HeapTuple newtuple)
 static HeapTuple
 GetTupleForTrigger(Relation relation, ItemPointer tid, bool before)
 {
-	ItemId		lp;
-	HeapTuple	tuple;
-	PageHeader	dp;
-	Buffer		b;
+	ItemId			lp;
+	HeapTupleData	tuple;
+	HeapTuple		result;
+	PageHeader		dp;
+	Buffer			b;
 
 	b = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
 
@@ -807,28 +807,30 @@ GetTupleForTrigger(Relation relation, ItemPointer tid, bool before)
 
 	Assert(ItemIdIsUsed(lp));
 
-	tuple = (HeapTuple) PageGetItem((Page) dp, lp);
+	tuple.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
+	tuple.t_len = ItemIdGetLength(lp);
+	tuple.t_self = *tid;
 
 	if (before)
 	{
-		if (TupleUpdatedByCurXactAndCmd(tuple))
+		if (TupleUpdatedByCurXactAndCmd(&tuple))
 		{
 			elog(NOTICE, "GetTupleForTrigger: Non-functional delete/update");
 			ReleaseBuffer(b);
 			return NULL;
 		}
 
-		HeapTupleSatisfies(lp, relation, b, dp,
-						   false, 0, (ScanKey) NULL, tuple);
-		if (!tuple)
+		HeapTupleSatisfies(&tuple, relation, b, dp,
+						   false, 0, (ScanKey) NULL);
+		if (!tuple.t_data)
 		{
 			ReleaseBuffer(b);
 			elog(ERROR, "GetTupleForTrigger: (am)invalid tid");
 		}
 	}
 
-	tuple = heap_copytuple(tuple);
+	result = heap_copytuple(&tuple);
 	ReleaseBuffer(b);
 
-	return tuple;
+	return result;
 }
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 34ca9fa073a0f618438e833ae189ce4b2d03a6fb..f7bed005add47272b50079d88787afcc85deeb2d 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.90 1998/10/23 16:49:24 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.91 1998/11/27 19:51:58 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -327,7 +327,7 @@ vc_getrels(NameData *VacRelP)
 		}
 		MemoryContextSwitchTo(old);
 
-		cur->vrl_relid = tuple->t_oid;
+		cur->vrl_relid = tuple->t_data->t_oid;
 		cur->vrl_next = (VRelList) NULL;
 	}
 	if (found == false)
@@ -577,9 +577,8 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
 	int			nblocks,
 				blkno;
 	ItemId		itemid;
-	ItemPointer itemptr;
 	Buffer		buf;
-	HeapTuple	tuple;
+	HeapTupleData	tuple;
 	Page		page,
 				tempPage = NULL;
 	OffsetNumber offnum,
@@ -675,23 +674,25 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
 				continue;
 			}
 
-			tuple = (HeapTuple) PageGetItem(page, itemid);
+			tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
+			tuple.t_len = ItemIdGetLength(itemid);
+			ItemPointerSet(&(tuple.t_self), blkno, offnum);
 			tupgone = false;
 
-			if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
+			if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
 			{
-				if (tuple->t_infomask & HEAP_XMIN_INVALID)
+				if (tuple.t_data->t_infomask & HEAP_XMIN_INVALID)
 					tupgone = true;
 				else
 				{
-					if (TransactionIdDidAbort(tuple->t_xmin))
+					if (TransactionIdDidAbort(tuple.t_data->t_xmin))
 						tupgone = true;
-					else if (TransactionIdDidCommit(tuple->t_xmin))
+					else if (TransactionIdDidCommit(tuple.t_data->t_xmin))
 					{
-						tuple->t_infomask |= HEAP_XMIN_COMMITTED;
+						tuple.t_data->t_infomask |= HEAP_XMIN_COMMITTED;
 						pgchanged = true;
 					}
-					else if (!TransactionIdIsInProgress(tuple->t_xmin))
+					else if (!TransactionIdIsInProgress(tuple.t_data->t_xmin))
 					{
 
 						/*
@@ -704,7 +705,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
 					else
 					{
 						elog(NOTICE, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation",
-							 relname, blkno, offnum, tuple->t_xmin);
+							 relname, blkno, offnum, tuple.t_data->t_xmin);
 						do_shrinking = false;
 					}
 				}
@@ -714,60 +715,40 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
 			 * here we are concerned about tuples with xmin committed and
 			 * xmax unknown or committed
 			 */
-			if (tuple->t_infomask & HEAP_XMIN_COMMITTED &&
-				!(tuple->t_infomask & HEAP_XMAX_INVALID))
+			if (tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED &&
+				!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID))
 			{
-				if (tuple->t_infomask & HEAP_XMAX_COMMITTED)
+				if (tuple.t_data->t_infomask & HEAP_XMAX_COMMITTED)
 					tupgone = true;
-				else if (TransactionIdDidAbort(tuple->t_xmax))
+				else if (TransactionIdDidAbort(tuple.t_data->t_xmax))
 				{
-					tuple->t_infomask |= HEAP_XMAX_INVALID;
+					tuple.t_data->t_infomask |= HEAP_XMAX_INVALID;
 					pgchanged = true;
 				}
-				else if (TransactionIdDidCommit(tuple->t_xmax))
+				else if (TransactionIdDidCommit(tuple.t_data->t_xmax))
 					tupgone = true;
-				else if (!TransactionIdIsInProgress(tuple->t_xmax))
+				else if (!TransactionIdIsInProgress(tuple.t_data->t_xmax))
 				{
 
 					/*
 					 * Not Aborted, Not Committed, Not in Progress - so it
 					 * from crashed process. - vadim 06/02/97
 					 */
-					tuple->t_infomask |= HEAP_XMAX_INVALID;;
+					tuple.t_data->t_infomask |= HEAP_XMAX_INVALID;;
 					pgchanged = true;
 				}
 				else
 				{
 					elog(NOTICE, "Rel %s: TID %u/%u: DeleteTransactionInProgress %u - can't shrink relation",
-						 relname, blkno, offnum, tuple->t_xmax);
+						 relname, blkno, offnum, tuple.t_data->t_xmax);
 					do_shrinking = false;
 				}
 			}
 
-			/*
-			 * It's possibly! But from where it comes ? And should we fix
-			 * it ?  - vadim 11/28/96
-			 */
-			itemptr = &(tuple->t_ctid);
-			if (!ItemPointerIsValid(itemptr) ||
-				BlockIdGetBlockNumber(&(itemptr->ip_blkid)) != blkno)
-			{
-				elog(NOTICE, "Rel %s: TID %u/%u: TID IN TUPLEHEADER %u/%u IS NOT THE SAME. TUPGONE %d.",
-					 relname, blkno, offnum,
-					 BlockIdGetBlockNumber(&(itemptr->ip_blkid)),
-					 itemptr->ip_posid, tupgone);
-			}
-
 			/*
 			 * Other checks...
 			 */
-			if (tuple->t_len != itemid->lp_len)
-			{
-				elog(NOTICE, "Rel %s: TID %u/%u: TUPLE_LEN IN PAGEHEADER %u IS NOT THE SAME AS IN TUPLEHEADER %u. TUPGONE %d.",
-					 relname, blkno, offnum,
-					 itemid->lp_len, tuple->t_len, tupgone);
-			}
-			if (!OidIsValid(tuple->t_oid))
+			if (!OidIsValid(tuple.t_data->t_oid))
 			{
 				elog(NOTICE, "Rel %s: TID %u/%u: OID IS INVALID. TUPGONE %d.",
 					 relname, blkno, offnum, tupgone);
@@ -799,11 +780,11 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
 			{
 				num_tuples++;
 				notup = false;
-				if (tuple->t_len < min_tlen)
-					min_tlen = tuple->t_len;
-				if (tuple->t_len > max_tlen)
-					max_tlen = tuple->t_len;
-				vc_attrstats(onerel, vacrelstats, tuple);
+				if (tuple.t_len < min_tlen)
+					min_tlen = tuple.t_len;
+				if (tuple.t_len > max_tlen)
+					max_tlen = tuple.t_len;
+				vc_attrstats(onerel, vacrelstats, &tuple);
 			}
 		}
 
@@ -916,8 +897,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
 				max_offset;
 	ItemId		itemid,
 				newitemid;
-	HeapTuple	tuple,
-				newtup;
+	HeapTupleData	tuple,
+					newtup;
 	TupleDesc	tupdesc = NULL;
 	Datum	   *idatum = NULL;
 	char	   *inulls = NULL;
@@ -1034,8 +1015,9 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
 			if (!ItemIdIsUsed(itemid))
 				continue;
 
-			tuple = (HeapTuple) PageGetItem(page, itemid);
-			tuple_len = tuple->t_len;
+			tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
+			tuple_len = tuple.t_len = ItemIdGetLength(itemid);
+			ItemPointerSet(&(tuple.t_self), blkno, offnum);
 
 			/* try to find new page for this tuple */
 			if (cur_buffer == InvalidBuffer ||
@@ -1081,21 +1063,20 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
 			}
 
 			/* copy tuple */
-			newtup = (HeapTuple) palloc(tuple_len);
-			memmove((char *) newtup, (char *) tuple, tuple_len);
+			heap_copytuple_with_tuple(&tuple, &newtup);
 
-			RelationInvalidateHeapTuple(onerel, tuple);
+			RelationInvalidateHeapTuple(onerel, &tuple);
 
 			/* store transaction information */
-			TransactionIdStore(myXID, &(newtup->t_xmin));
-			newtup->t_cmin = myCID;
-			StoreInvalidTransactionId(&(newtup->t_xmax));
+			TransactionIdStore(myXID, &(newtup.t_data->t_xmin));
+			newtup.t_data->t_cmin = myCID;
+			StoreInvalidTransactionId(&(newtup.t_data->t_xmax));
 			/* set xmin to unknown and xmax to invalid */
-			newtup->t_infomask &= ~(HEAP_XACT_MASK);
-			newtup->t_infomask |= HEAP_XMAX_INVALID;
+			newtup.t_data->t_infomask &= ~(HEAP_XACT_MASK);
+			newtup.t_data->t_infomask |= HEAP_XMAX_INVALID;
 
 			/* add tuple to the page */
-			newoff = PageAddItem(ToPage, (Item) newtup, tuple_len,
+			newoff = PageAddItem(ToPage, (Item) newtup.t_data, tuple_len,
 								 InvalidOffsetNumber, LP_USED);
 			if (newoff == InvalidOffsetNumber)
 			{
@@ -1105,15 +1086,16 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
 				 cur_page->vpd_offsets_used, cur_page->vpd_offsets_free);
 			}
 			newitemid = PageGetItemId(ToPage, newoff);
-			pfree(newtup);
-			newtup = (HeapTuple) PageGetItem(ToPage, newitemid);
-			ItemPointerSet(&(newtup->t_ctid), cur_page->vpd_blkno, newoff);
+			pfree(newtup.t_data);
+			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;
 
 			/* now logically delete end-tuple */
-			TransactionIdStore(myXID, &(tuple->t_xmax));
-			tuple->t_cmax = myCID;
+			TransactionIdStore(myXID, &(tuple.t_data->t_xmax));
+			tuple.t_data->t_cmax = myCID;
 			/* set xmax to unknown */
-			tuple->t_infomask &= ~(HEAP_XMAX_INVALID | HEAP_XMAX_COMMITTED);
+			tuple.t_data->t_infomask &= ~(HEAP_XMAX_INVALID | HEAP_XMAX_COMMITTED);
 
 			cur_page->vpd_offsets_used++;
 			num_moved++;
@@ -1127,7 +1109,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
 				{
 					FormIndexDatum(idcur->natts,
 							   (AttrNumber *) &(idcur->tform->indkey[0]),
-								   newtup,
+								   &newtup,
 								   tupdesc,
 								   idatum,
 								   inulls,
@@ -1135,7 +1117,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
 					iresult = index_insert(Irel[i],
 										   idatum,
 										   inulls,
-										   &newtup->t_ctid,
+										   &newtup.t_self,
 										   onerel);
 					if (iresult)
 						pfree(iresult);
@@ -1213,10 +1195,10 @@ 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 = (HeapTuple) PageGetItem(page, itemid);
-				if (TransactionIdEquals((TransactionId) tuple->t_xmin, myXID))
+				tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
+				if (TransactionIdEquals((TransactionId) tuple.t_data->t_xmin, myXID))
 				{
-					tuple->t_infomask |= HEAP_XMIN_COMMITTED;
+					tuple.t_data->t_infomask |= HEAP_XMIN_COMMITTED;
 					num_tuples++;
 				}
 			}
@@ -1276,8 +1258,8 @@ Elapsed %u/%u sec.",
 				itemid = PageGetItemId(page, offnum);
 				if (!ItemIdIsUsed(itemid))
 					continue;
-				tuple = (HeapTuple) PageGetItem(page, itemid);
-				Assert(TransactionIdEquals((TransactionId) tuple->t_xmax, myXID));
+				tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
+				Assert(TransactionIdEquals((TransactionId) tuple.t_data->t_xmax, myXID));
 				itemid->lp_flags &= ~LP_USED;
 				num_tuples++;
 			}
@@ -1718,18 +1700,18 @@ vc_bucketcpy(Form_pg_attribute attr, Datum value, Datum *bucket, int16 *bucket_l
 static void
 vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats)
 {
-	Relation	rd,
-				ad,
-				sd;
-	HeapScanDesc scan;
-	HeapTuple	rtup,
-				ctup,
-				atup,
-				stup;
-	Form_pg_class pgcform;
-	ScanKeyData askey;
-	Form_pg_attribute attp;
-	Buffer		buffer;
+	Relation			rd,
+						ad,
+						sd;
+	HeapScanDesc 		scan;
+	HeapTupleData		rtup;
+	HeapTuple			ctup,
+						atup,
+						stup;
+	Form_pg_class	 	pgcform;
+	ScanKeyData 		askey;
+	Form_pg_attribute	attp;
+	Buffer				buffer;
 
 	/*
 	 * update number of tuples and number of pages in pg_class
@@ -1744,12 +1726,13 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
 	rd = heap_openr(RelationRelationName);
 
 	/* get the buffer cache tuple */
-	rtup = heap_fetch(rd, SnapshotNow, &ctup->t_ctid, &buffer);
+	rtup.t_self = ctup->t_self;
+	heap_fetch(rd, SnapshotNow, &rtup, &buffer);
 	pfree(ctup);
 	
 	/* overwrite the existing statistics in the tuple */
-	vc_setpagelock(rd, ItemPointerGetBlockNumber(&rtup->t_ctid));
-	pgcform = (Form_pg_class) GETSTRUCT(rtup);
+	vc_setpagelock(rd, ItemPointerGetBlockNumber(&(rtup.t_self)));
+	pgcform = (Form_pg_class) GETSTRUCT(&rtup);
 	pgcform->reltuples = num_tuples;
 	pgcform->relpages = num_pages;
 	pgcform->relhasindex = hasindex;
@@ -1792,15 +1775,9 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
 			/* overwrite the existing statistics in the tuple */
 			if (VacAttrStatsEqValid(stats))
 			{
-				Buffer		abuffer;
+				Buffer		abuffer = scan->rs_cbuf;
 
-				/*
-				 * We manipulate the heap tuple in the
-				 * buffer, so we fetch it to get the
-				 * buffer number
-				 */
-				atup = heap_fetch(ad, SnapshotNow, &atup->t_ctid, &abuffer);
-				vc_setpagelock(ad, ItemPointerGetBlockNumber(&atup->t_ctid));
+				vc_setpagelock(ad, ItemPointerGetBlockNumber(&atup->t_self));
 				attp = (Form_pg_attribute) GETSTRUCT(atup);
 
 				if (stats->nonnull_cnt + stats->null_cnt == 0 ||
@@ -1837,7 +1814,6 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
 				 */
 				RelationInvalidateHeapTuple(ad, atup);
 				WriteNoReleaseBuffer(abuffer);
-				ReleaseBuffer(abuffer);
 
 				/* DO PG_STATISTIC INSERTS */
 
@@ -1894,7 +1870,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
 	 * Invalidate the cached pg_class tuple and
 	 * write the buffer
 	 */
-	RelationInvalidateHeapTuple(rd, rtup);
+	RelationInvalidateHeapTuple(rd, &rtup);
 
 	WriteNoReleaseBuffer(buffer);
 
@@ -1942,7 +1918,7 @@ vc_delhilowstats(Oid relid, int attcnt, int *attnums)
 			if (i >= attcnt)
 				continue;		/* don't delete it */
 		}
-		heap_delete(pgstatistic, &tuple->t_ctid);
+		heap_delete(pgstatistic, &tuple->t_self);
 	}
 
 	heap_endscan(scan);
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index a7a7cb93cc8b729c6b9e1ab4b7e1b60bd06186c4..45be159ae17c5a5166b2dcaaaf6dce2326f7d5dd 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -26,7 +26,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.58 1998/10/14 05:10:00 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.59 1998/11/27 19:51:59 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -963,16 +963,7 @@ ExecAppend(TupleTableSlot *slot,
 
 	if (resultRelationDesc->rd_att->constr)
 	{
-		HeapTuple	newtuple;
-
-		newtuple = ExecConstraints("ExecAppend", resultRelationDesc, tuple);
-
-		if (newtuple != tuple)	/* modified by DEFAULT */
-		{
-			Assert(slot->ttc_shouldFree);
-			pfree(tuple);
-			slot->val = tuple = newtuple;
-		}
+		ExecConstraints("ExecAppend", resultRelationDesc, tuple);
 	}
 
 	/******************
@@ -993,7 +984,7 @@ ExecAppend(TupleTableSlot *slot,
 	 */
 	numIndices = resultRelationInfo->ri_NumIndices;
 	if (numIndices > 0)
-		ExecInsertIndexTuples(slot, &(tuple->t_ctid), estate, false);
+		ExecInsertIndexTuples(slot, &(tuple->t_self), estate, false);
 	(estate->es_processed)++;
 	estate->es_lastoid = newId;
 
@@ -1146,16 +1137,7 @@ ExecReplace(TupleTableSlot *slot,
 
 	if (resultRelationDesc->rd_att->constr)
 	{
-		HeapTuple	newtuple;
-
-		newtuple = ExecConstraints("ExecReplace", resultRelationDesc, tuple);
-
-		if (newtuple != tuple)	/* modified by DEFAULT */
-		{
-			Assert(slot->ttc_shouldFree);
-			pfree(tuple);
-			slot->val = tuple = newtuple;
-		}
+		ExecConstraints("ExecReplace", resultRelationDesc, tuple);
 	}
 
 	/******************
@@ -1200,7 +1182,7 @@ ExecReplace(TupleTableSlot *slot,
 
 	numIndices = resultRelationInfo->ri_NumIndices;
 	if (numIndices > 0)
-		ExecInsertIndexTuples(slot, &(tuple->t_ctid), estate, true);
+		ExecInsertIndexTuples(slot, &(tuple->t_self), estate, true);
 
 	/* AFTER ROW UPDATE Triggers */
 	if (resultRelationDesc->trigdesc &&
@@ -1334,18 +1316,12 @@ ExecRelCheck(Relation rel, HeapTuple tuple)
 
 }
 
-HeapTuple
+void
 ExecConstraints(char *caller, Relation rel, HeapTuple tuple)
 {
-	HeapTuple	newtuple = tuple;
 
 	Assert(rel->rd_att->constr);
 
-#if 0
-	if (rel->rd_att->constr->num_defval > 0)
-		newtuple = tuple = ExecAttrDefault(rel, tuple);
-#endif
-
 	if (rel->rd_att->constr->has_not_null)
 	{
 		int			attrChk;
@@ -1366,5 +1342,5 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple)
 			elog(ERROR, "%s: rejected due to CHECK constraint %s", caller, failed);
 	}
 
-	return newtuple;
+	return;
 }
diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c
index 680bf9939ed85d90a2c8b6d8f01fa5cb88308aed..6f9148b56d4259c6a1b4dd7f28cd9761762c712d 100644
--- a/src/backend/executor/execQual.c
+++ b/src/backend/executor/execQual.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.37 1998/09/25 13:38:31 thomas Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.38 1998/11/27 19:52:00 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -274,7 +274,7 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
 	 * the entire tuple, we give back a whole slot so that callers know
 	 * what the tuple looks like.
 	 */
-		if (attnum == InvalidAttrNumber)
+	if (attnum == InvalidAttrNumber)
 	{
 		TupleTableSlot *tempSlot;
 		TupleDesc	td;
@@ -287,7 +287,7 @@ ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull)
 			tempSlot->ttc_buffer = InvalidBuffer;
 		tempSlot->ttc_whichplan = -1;
 
-		tup = heap_copytuple(slot->val);
+		tup = heap_copytuple(heapTuple);
 		td = CreateTupleDescCopy(slot->ttc_tupleDescriptor);
 
 		ExecSetSlotDescriptor(tempSlot, td);
@@ -549,7 +549,6 @@ GetAttributeByName(TupleTableSlot *slot, char *attname, bool *isNull)
 {
 	AttrNumber	attrno;
 	TupleDesc	tupdesc;
-	HeapTuple	tuple;
 	Datum		retval;
 	int			natts;
 	int			i;
@@ -567,9 +566,7 @@ GetAttributeByName(TupleTableSlot *slot, char *attname, bool *isNull)
 	}
 
 	tupdesc = slot->ttc_tupleDescriptor;
-	tuple = slot->val;
-
-	natts = tuple->t_natts;
+	natts = slot->val->t_data->t_natts;
 
 	attrno = InvalidAttrNumber;
 	for (i = 0; i < tupdesc->natts; i++)
diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c
index 3f9e82902de5f974919777778bc8f41f0c4fa44f..1af4fcbc88a354faaf7f0d2e361f7b4c7f3bde11 100644
--- a/src/backend/executor/execUtils.c
+++ b/src/backend/executor/execUtils.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.39 1998/09/23 04:22:06 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.40 1998/11/27 19:52:01 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -1138,7 +1138,7 @@ ExecInsertIndexTuples(TupleTableSlot *slot,
 		result = index_insert(relationDescs[i], /* index relation */
 							  datum,	/* array of heaptuple Datums */
 							  nulls,	/* info on nulls */
-							  &(heapTuple->t_ctid),		/* oid of heap tuple */
+							  &(heapTuple->t_self),	/* tid of heap tuple */
 							  heapRelation);
 
 		/* ----------------
diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c
index fd095e7864ab50f39b139b1f1e95c91b9e6120f1..34fe23e0baf1d985537062a668f82ab543584a90 100644
--- a/src/backend/executor/functions.c
+++ b/src/backend/executor/functions.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.20 1998/09/01 04:28:23 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.21 1998/11/27 19:52:01 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -270,7 +270,7 @@ copy_function_result(FunctionCachePtr fcache,
 		int			i = 0;
 		TupleDesc	funcTd = funcSlot->ttc_tupleDescriptor;
 
-		while (i < oldTuple->t_natts)
+		while (i < oldTuple->t_data->t_natts)
 		{
 			funcTd->attrs[i] =
 				(Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE);
@@ -341,13 +341,11 @@ postquel_execute(execution_state *es,
 		resSlot = copy_function_result(fcache, slot);
 		if (fTlist != NIL)
 		{
-			HeapTuple	tup;
 			TargetEntry *tle = lfirst(fTlist);
 
-			tup = resSlot->val;
 			value = ProjectAttribute(resSlot->ttc_tupleDescriptor,
 									 tle,
-									 tup,
+									 resSlot->val,
 									 isNull);
 		}
 		else
diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c
index c7e69d1a72f2f1f702c5be3dc7b1a07ed9855e75..0eed756319a1889d53d88a6fbeae6b17149a889a 100644
--- a/src/backend/executor/nodeAgg.c
+++ b/src/backend/executor/nodeAgg.c
@@ -248,16 +248,12 @@ ExecAgg(Agg *node)
 		 */
 		for (;;)
 		{
-			HeapTuple	outerTuple = NULL;
 			TupleTableSlot *outerslot;
 
 			isNull = isNull1 = isNull2 = 0;
 			outerslot = ExecProcNode(outerPlan, (Plan *) node);
-			if (outerslot)
-				outerTuple = outerslot->val;
-			if (!HeapTupleIsValid(outerTuple))
+			if (TupIsNull(outerslot))
 			{
-
 				/*
 				 * when the outerplan doesn't return a single tuple,
 				 * create a dummy heaptuple anyway because we still need
@@ -666,7 +662,7 @@ aggGetAttr(TupleTableSlot *slot,
 			tempSlot->ttc_buffer = InvalidBuffer;
 		tempSlot->ttc_whichplan = -1;
 
-		tup = heap_copytuple(slot->val);
+		tup = heap_copytuple(heapTuple);
 		td = CreateTupleDescCopy(slot->ttc_tupleDescriptor);
 
 		ExecSetSlotDescriptor(tempSlot, td);
diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c
index 1fdf6bedc32115dba38375f97eaef4a353da5daa..54cf97ca3e1c47624b6dd13bf4f77bc51bbe4505 100644
--- a/src/backend/executor/nodeGroup.c
+++ b/src/backend/executor/nodeGroup.c
@@ -13,7 +13,7 @@
  *	  columns. (ie. tuples from the same group are consecutive)
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.22 1998/09/01 04:28:28 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.23 1998/11/27 19:52:01 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -102,13 +102,12 @@ ExecGroupEveryTuple(Group *node)
 	else
 	{
 		outerslot = ExecProcNode(outerPlan(node), (Plan *) node);
-		if (outerslot)
-			outerTuple = outerslot->val;
-		if (!HeapTupleIsValid(outerTuple))
+		if (TupIsNull(outerslot))
 		{
 			grpstate->grp_done = TRUE;
 			return NULL;
 		}
+		outerTuple = outerslot->val;
 
 		firsttuple = grpstate->grp_firstTuple;
 		/* this should occur on the first call only */
@@ -121,7 +120,7 @@ ExecGroupEveryTuple(Group *node)
 			 * Compare with first tuple and see if this tuple is of the
 			 * same group.
 			 */
-			if (!sameGroup(firsttuple, outerslot->val,
+			if (!sameGroup(firsttuple, outerTuple,
 						   node->numCols, node->grpColIdx,
 						   ExecGetScanType(&grpstate->csstate)))
 			{
@@ -189,14 +188,13 @@ ExecGroupOneTuple(Group *node)
 	if (firsttuple == NULL)
 	{
 		outerslot = ExecProcNode(outerPlan(node), (Plan *) node);
-		if (outerslot)
-			outerTuple = outerslot->val;
-		if (!HeapTupleIsValid(outerTuple))
+		if (TupIsNull(outerslot))
 		{
 			grpstate->grp_done = TRUE;
 			return NULL;
 		}
-		grpstate->grp_firstTuple = firsttuple = heap_copytuple(outerTuple);
+		grpstate->grp_firstTuple = firsttuple = 
+						heap_copytuple(outerslot->val);
 	}
 
 	/*
@@ -205,19 +203,20 @@ ExecGroupOneTuple(Group *node)
 	for (;;)
 	{
 		outerslot = ExecProcNode(outerPlan(node), (Plan *) node);
-		outerTuple = (outerslot) ? outerslot->val : NULL;
-		if (!HeapTupleIsValid(outerTuple))
+		if (TupIsNull(outerslot))
 		{
 			grpstate->grp_done = TRUE;
+			outerTuple = NULL;
 			break;
 		}
+		outerTuple = outerslot->val;
 
 		/* ----------------
 		 *	Compare with first tuple and see if this tuple is of
 		 *	the same group.
 		 * ----------------
 		 */
-		if ((!sameGroup(firsttuple, outerslot->val,
+		if ((!sameGroup(firsttuple, outerTuple,
 						node->numCols, node->grpColIdx,
 						ExecGetScanType(&grpstate->csstate))))
 			break;
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c
index 634411a7c644e8d2b876001dd81edf646fd70846..63a9a83bcac2c5f63c1b988d5d981426a8c43373 100644
--- a/src/backend/executor/nodeHash.c
+++ b/src/backend/executor/nodeHash.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.23 1998/09/01 04:28:29 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.24 1998/11/27 19:52:02 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -489,16 +489,19 @@ ExecHashTableInsert(HashJoinTable hashtable,
 		 */
 		bucket = (HashBucket)
 			(ABSADDR(hashtable->top) + bucketno * hashtable->bucketsize);
-		if ((char *) LONGALIGN(ABSADDR(bucket->bottom))
-			- (char *) bucket + heapTuple->t_len > hashtable->bucketsize)
+		if ((char *) LONGALIGN(ABSADDR(bucket->bottom)) - (char *) bucket 
+				+ heapTuple->t_len + HEAPTUPLESIZE > hashtable->bucketsize)
 			ExecHashOverflowInsert(hashtable, bucket, heapTuple);
 		else
 		{
 			memmove((char *) LONGALIGN(ABSADDR(bucket->bottom)),
 					heapTuple,
+					HEAPTUPLESIZE);
+			memmove((char *) LONGALIGN(ABSADDR(bucket->bottom)) + HEAPTUPLESIZE,
+					heapTuple->t_data,
 					heapTuple->t_len);
-			bucket->bottom =
-				((RelativeAddr) LONGALIGN(bucket->bottom) + heapTuple->t_len);
+			bucket->bottom = ((RelativeAddr) LONGALIGN(bucket->bottom) + 
+					heapTuple->t_len + HEAPTUPLESIZE);
 		}
 	}
 	else
@@ -611,7 +614,7 @@ ExecHashOverflowInsert(HashJoinTable hashtable,
 	 * ----------------
 	 */
 	newend = (RelativeAddr) LONGALIGN(hashtable->overflownext + sizeof(*otuple)
-									  + heapTuple->t_len);
+									  + heapTuple->t_len + HEAPTUPLESIZE);
 	if (newend > hashtable->bottom)
 	{
 #if 0
@@ -664,6 +667,9 @@ ExecHashOverflowInsert(HashJoinTable hashtable,
 	otuple->tuple = RELADDR(LONGALIGN(((char *) otuple + sizeof(*otuple))));
 	memmove(ABSADDR(otuple->tuple),
 			heapTuple,
+			HEAPTUPLESIZE);
+	memmove(ABSADDR(otuple->tuple) + HEAPTUPLESIZE,
+			heapTuple->t_data,
 			heapTuple->t_len);
 }
 
@@ -704,7 +710,10 @@ ExecScanHashBucket(HashJoinState *hjstate,
 				LONGALIGN(ABSADDR(bucket->top));
 		else
 			heapTuple = (HeapTuple)
-				LONGALIGN(((char *) curtuple + curtuple->t_len));
+				LONGALIGN(((char *) curtuple + curtuple->t_len + HEAPTUPLESIZE));
+		
+		heapTuple->t_data = (HeapTupleHeader) 
+							((char *) heapTuple + HEAPTUPLESIZE);
 
 		while (heapTuple < (HeapTuple) ABSADDR(bucket->bottom))
 		{
@@ -721,7 +730,9 @@ ExecScanHashBucket(HashJoinState *hjstate,
 				return heapTuple;
 
 			heapTuple = (HeapTuple)
-				LONGALIGN(((char *) heapTuple + heapTuple->t_len));
+				LONGALIGN(((char *) heapTuple + heapTuple->t_len + HEAPTUPLESIZE));
+			heapTuple->t_data = (HeapTupleHeader) 
+								((char *) heapTuple + HEAPTUPLESIZE);
 		}
 
 		if (firstotuple == NULL)
@@ -742,6 +753,8 @@ ExecScanHashBucket(HashJoinState *hjstate,
 	while (otuple != NULL)
 	{
 		heapTuple = (HeapTuple) ABSADDR(otuple->tuple);
+		heapTuple->t_data = (HeapTupleHeader) 
+							((char *) heapTuple + HEAPTUPLESIZE);
 
 		inntuple = ExecStoreTuple(heapTuple,	/* tuple to store */
 								  hjstate->hj_HashTupleSlot,	/* slot */
diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c
index deef8895224ca477027c5f940beb0dab13a2e6c4..4673d92ce31e1e5dc1708764370f99abbae3d8fc 100644
--- a/src/backend/executor/nodeHashjoin.c
+++ b/src/backend/executor/nodeHashjoin.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.13 1998/09/01 04:28:31 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.14 1998/11/27 19:52:02 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -646,7 +646,10 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate,
 			(*position) = bufstart;
 	}
 	heapTuple = (HeapTuple) (*position);
-	(*position) = (char *) LONGALIGN(*position + heapTuple->t_len);
+	heapTuple->t_data = (HeapTupleHeader) 
+						((char *) heapTuple + HEAPTUPLESIZE);
+	(*position) = (char *) LONGALIGN(*position + 
+									 heapTuple->t_len + HEAPTUPLESIZE);
 
 	return ExecStoreTuple(heapTuple, tupleSlot, InvalidBuffer, false);
 }
@@ -824,7 +827,7 @@ ExecHashJoinSaveTuple(HeapTuple heapTuple,
 	if (position == NULL)
 		position = pagestart;
 
-	if (position + heapTuple->t_len >= pagebound)
+	if (position + heapTuple->t_len + HEAPTUPLESIZE >= pagebound)
 	{
 		cc = FileSeek(file, 0L, SEEK_END);
 		if (cc < 0)
@@ -836,8 +839,9 @@ ExecHashJoinSaveTuple(HeapTuple heapTuple,
 		position = pagestart;
 		*pageend = 0;
 	}
-	memmove(position, heapTuple, heapTuple->t_len);
-	position = (char *) LONGALIGN(position + heapTuple->t_len);
+	memmove(position, heapTuple, HEAPTUPLESIZE);
+	memmove(position + HEAPTUPLESIZE, heapTuple->t_data, heapTuple->t_len);
+	position = (char *) LONGALIGN(position + heapTuple->t_len + HEAPTUPLESIZE);
 	*pageend = position - buffer;
 
 	return position;
diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c
index 7a087f44140380c0dfc0b193011e584e336b1d33..b4a610b7f88e7bdee901ad2d1f0fac7ceca9f23b 100644
--- a/src/backend/executor/nodeIndexscan.c
+++ b/src/backend/executor/nodeIndexscan.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.28 1998/11/22 10:48:36 vadim Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.29 1998/11/27 19:52:03 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -91,7 +91,7 @@ IndexNext(IndexScan *node)
 	IndexScanDesc scandesc;
 	Relation	heapRelation;
 	RetrieveIndexResult result;
-	HeapTuple	tuple;
+	HeapTuple		tuple;
 	TupleTableSlot *slot;
 	Buffer		buffer = InvalidBuffer;
 	int			numIndices;
@@ -109,6 +109,7 @@ IndexNext(IndexScan *node)
 	heapRelation = scanstate->css_currentRelation;
 	numIndices = indexstate->iss_NumIndices;
 	slot = scanstate->css_ScanTupleSlot;
+	tuple = &(indexstate->iss_htup);
 
 	/* ----------------
 	 *	ok, now that we have what we need, fetch an index tuple.
@@ -121,11 +122,11 @@ IndexNext(IndexScan *node)
 		scandesc = scanDescs[indexstate->iss_IndexPtr];
 		while ((result = index_getnext(scandesc, direction)) != NULL)
 		{
-			tuple = heap_fetch(heapRelation, snapshot,
-							   &result->heap_iptr, &buffer);
+			tuple->t_self = result->heap_iptr;
+			heap_fetch(heapRelation, snapshot, tuple, &buffer);
 			pfree(result);
 
-			if (tuple != NULL)
+			if (tuple->t_data != NULL)
 			{
 				bool		prev_matches = false;
 				int			prev_index;
diff --git a/src/backend/executor/nodeMaterial.c b/src/backend/executor/nodeMaterial.c
index 95c8a6f56f32fa41a3b359c641d0f1dcf8d67198..485b962a895f80663c3bb144be2f8cd50e7c71c3 100644
--- a/src/backend/executor/nodeMaterial.c
+++ b/src/backend/executor/nodeMaterial.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.17 1998/09/01 04:28:34 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.18 1998/11/27 19:52:03 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -114,13 +114,22 @@ ExecMaterial(Material *node)
 		{
 			slot = ExecProcNode(outerNode, (Plan *) node);
 
-			heapTuple = slot->val;
-			if (heapTuple == NULL)
+			if (TupIsNull(slot))
 				break;
-
-			heap_insert(tempRelation,	/* relation desc */
-						heapTuple);		/* heap tuple to insert */
-
+			
+			/*
+			 * heap_insert changes something...
+			 */
+			if (slot->ttc_buffer != InvalidBuffer)
+				heapTuple = heap_copytuple(slot->val);
+			else
+				heapTuple = slot->val;
+			
+			heap_insert(tempRelation, heapTuple);
+
+			if (slot->ttc_buffer != InvalidBuffer)
+				pfree(heapTuple);
+			
 			ExecClearTuple(slot);
 		}
 		currentRelation = tempRelation;
diff --git a/src/backend/executor/nodeTee.c b/src/backend/executor/nodeTee.c
index 623a43b9e0cc0994c9c9f1a19249a1809fabe8f8..7b0f7f1755e685668c413a97942f630c5e420ed5 100644
--- a/src/backend/executor/nodeTee.c
+++ b/src/backend/executor/nodeTee.c
@@ -15,7 +15,7 @@
  *		ExecEndTee
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.24 1998/10/08 18:29:27 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.25 1998/11/27 19:52:03 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -342,11 +342,20 @@ ExecTee(Tee *node, Plan *parent)
 		slot = ExecProcNode(childNode, (Plan *) node);
 		if (!TupIsNull(slot))
 		{
-			heapTuple = slot->val;
+			/*
+			 * heap_insert changes something...
+			 */
+			if (slot->ttc_buffer != InvalidBuffer)
+				heapTuple = heap_copytuple(slot->val);
+			else
+				heapTuple = slot->val;
 
 			/* insert into temporary relation */
 			heap_insert(bufferRel, heapTuple);
 
+			if (slot->ttc_buffer != InvalidBuffer)
+				pfree(heapTuple);
+
 			/*
 			 * once there is data in the temporary relation, ensure that
 			 * the left and right scandescs are initialized
diff --git a/src/backend/executor/nodeUnique.c b/src/backend/executor/nodeUnique.c
index 66b11a66600ad426b4c2d299755b9b28104c6f72..c04c44fa0d1b60ff131ae50bde043d556c7eb3fb 100644
--- a/src/backend/executor/nodeUnique.c
+++ b/src/backend/executor/nodeUnique.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.17 1998/02/26 04:31:34 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.18 1998/11/27 19:52:03 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -76,7 +76,7 @@ ExecIdenticalTuples(TupleTableSlot *t1, TupleTableSlot *t2)
 	 *	THE t_len FIELDS CAN BE THE SAME IN THIS CASE!!
 	 * ----------------
 	 */
-	if (h1->t_hoff != h2->t_hoff)
+	if (h1->t_data->t_hoff != h2->t_data->t_hoff)
 		return false;
 
 	/* ----------------
@@ -86,7 +86,7 @@ ExecIdenticalTuples(TupleTableSlot *t1, TupleTableSlot *t2)
 	 */
 	d1 = (char *) GETSTRUCT(h1);
 	d2 = (char *) GETSTRUCT(h2);
-	len = (int) h1->t_len - (int) h1->t_hoff;
+	len = (int) h1->t_len - (int) h1->t_data->t_hoff;
 
 	/* ----------------
 	 *	byte compare the data areas and return the result.
diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c
index f034dd064de71ac303acc951c142b25254d4f8bd..0d3022dce7094b7fb6771dfb2417931c52591f8a 100644
--- a/src/backend/executor/spi.c
+++ b/src/backend/executor/spi.c
@@ -356,11 +356,12 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum,
 	if (i == natts)				/* no errors in *attnum */
 	{
 		mtuple = heap_formtuple(rel->rd_att, v, n);
-		infomask = mtuple->t_infomask;
-		memmove(&(mtuple->t_ctid), &(tuple->t_ctid),
-				((char *) &(tuple->t_hoff) - (char *) &(tuple->t_ctid)));
-		mtuple->t_infomask = infomask;
-		mtuple->t_natts = numberOfAttributes;
+		infomask = mtuple->t_data->t_infomask;
+		memmove(&(mtuple->t_data->t_oid), &(tuple->t_data->t_oid),
+				((char *) &(tuple->t_data->t_hoff) - 
+					(char *) &(tuple->t_data->t_oid)));
+		mtuple->t_data->t_infomask = infomask;
+		mtuple->t_data->t_natts = numberOfAttributes;
 	}
 	else
 	{
@@ -413,7 +414,7 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
 	Oid			foutoid;
 
 	SPI_result = 0;
-	if (tuple->t_natts < fnumber || fnumber <= 0)
+	if (tuple->t_data->t_natts < fnumber || fnumber <= 0)
 	{
 		SPI_result = SPI_ERROR_NOATTRIBUTE;
 		return NULL;
@@ -441,7 +442,7 @@ SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
 
 	*isnull = true;
 	SPI_result = 0;
-	if (tuple->t_natts < fnumber || fnumber <= 0)
+	if (tuple->t_data->t_natts < fnumber || fnumber <= 0)
 	{
 		SPI_result = SPI_ERROR_NOATTRIBUTE;
 		return (Datum) NULL;
diff --git a/src/backend/libpq/be-dumpdata.c b/src/backend/libpq/be-dumpdata.c
index 76bff775f0cfbd99a7907a95c782c006513e9d9d..8ea0e53cc0263187c1572cd006f656dd4b669f53 100644
--- a/src/backend/libpq/be-dumpdata.c
+++ b/src/backend/libpq/be-dumpdata.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.17 1998/09/01 03:22:43 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.18 1998/11/27 19:52:05 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -276,8 +276,8 @@ be_printtup(HeapTuple tuple, TupleDesc typeinfo)
 	 *	Allocate space for a tuple.
 	 * ----------------
 	 */
-	tuples->values[tuples->tuple_index] = pbuf_addTuple(tuple->t_natts);
-	tuples->lengths[tuples->tuple_index] = pbuf_addTupleValueLengths(tuple->t_natts);
+	tuples->values[tuples->tuple_index] = pbuf_addTuple(tuple->t_data->t_natts);
+	tuples->lengths[tuples->tuple_index] = pbuf_addTupleValueLengths(tuple->t_data->t_natts);
 	/* ----------------
 	 *	copy printable representations of the tuple's attributes
 	 *	to the portal.
@@ -297,7 +297,7 @@ be_printtup(HeapTuple tuple, TupleDesc typeinfo)
 	values = tuples->values[tuples->tuple_index];
 	lengths = tuples->lengths[tuples->tuple_index];
 
-	for (i = 0; i < tuple->t_natts; i++)
+	for (i = 0; i < tuple->t_data->t_natts; i++)
 	{
 		attr = heap_getattr(tuple, i + 1, typeinfo, &isnull);
 		typoutput = typtoout((Oid) typeinfo->attrs[i]->atttypid);
diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c
index 19bd3ce98e1312068b96fe7a6534220ad69c7460..892a2d45c35004d5777362d76bd9273e09aea26b 100644
--- a/src/backend/optimizer/util/clauses.c
+++ b/src/backend/optimizer/util/clauses.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.24 1998/09/01 04:30:02 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.25 1998/11/27 19:52:07 vadim Exp $
  *
  * HISTORY
  *	  AUTHOR			DATE			MAJOR EVENT
@@ -773,7 +773,7 @@ CommuteClause(Node *clause)
 
 	commuTup = (Form_pg_operator) GETSTRUCT(heapTup);
 
-	commu = makeOper(heapTup->t_oid,
+	commu = makeOper(heapTup->t_data->t_oid,
 					 InvalidOid,
 					 commuTup->oprresult,
 					 ((Oper *) ((Expr *) clause)->oper)->opsize,
diff --git a/src/backend/parser/gram.c b/src/backend/parser/gram.c
index 997c65e808cb9e49bf9fadc4b7d856c701bdbefe..efea1dc074dc37dd3416100c38170c8970656202 100644
--- a/src/backend/parser/gram.c
+++ b/src/backend/parser/gram.c
@@ -229,7 +229,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.49 1998/11/22 10:48:45 vadim Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/Attic/gram.c,v 2.50 1998/11/27 19:52:09 vadim Exp $
  *
  * HISTORY
  *	  AUTHOR			DATE			MAJOR EVENT
diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c
index dc533d1dbd32827d2f40d93818d86c9700cb12ad..81b887e8a5fd2329801813427070264aca44dabc 100644
--- a/src/backend/parser/parse_func.c
+++ b/src/backend/parser/parse_func.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.30 1998/10/08 18:29:45 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.31 1998/11/27 19:52:13 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -516,7 +516,7 @@ func_get_candidates(char *funcname, int nargs)
 	Relation	heapRelation;
 	Relation	idesc;
 	ScanKeyData skey;
-	HeapTuple	tuple;
+	HeapTupleData	tuple;
 	IndexScanDesc sd;
 	RetrieveIndexResult indexRes;
 	Form_pg_proc pgProcP;
@@ -537,20 +537,17 @@ func_get_candidates(char *funcname, int nargs)
 
 	do
 	{
-		tuple = (HeapTuple) NULL;
-
 		indexRes = index_getnext(sd, ForwardScanDirection);
 		if (indexRes)
 		{
-			ItemPointer iptr;
 			Buffer		buffer;
 
-			iptr = &indexRes->heap_iptr;
-			tuple = heap_fetch(heapRelation, SnapshotNow, iptr, &buffer);
+			tuple.t_self = indexRes->heap_iptr;
+			heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer);
 			pfree(indexRes);
-			if (HeapTupleIsValid(tuple))
+			if (tuple.t_data != NULL)
 			{
-				pgProcP = (Form_pg_proc) GETSTRUCT(tuple);
+				pgProcP = (Form_pg_proc) GETSTRUCT(&tuple);
 				if (pgProcP->pronargs == nargs)
 				{
 					current_candidate = (CandidateList)
@@ -884,7 +881,7 @@ func_get_detail(char *funcname,
 	else
 	{
 		pform = (Form_pg_proc) GETSTRUCT(ftup);
-		*funcid = ftup->t_oid;
+		*funcid = ftup->t_data->t_oid;
 		*rettype = pform->prorettype;
 		*retset = pform->proretset;
 
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index 7719e517ac14b89e6b4bc1127308d1f689c41c4c..f9e13f160421965bd89af64febb2227de647def9 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.20 1998/10/08 18:29:46 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.21 1998/11/27 19:52:14 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -61,7 +61,7 @@ any_ordering_op(int restype)
 Oid
 oprid(Operator op)
 {
-	return op->t_oid;
+	return op->t_data->t_oid;
 }
 
 
@@ -426,7 +426,7 @@ oper_exact(char *op, Oid arg1, Oid arg2, Node **ltree, Node **rtree, bool noWarn
 			Form_pg_operator opform;
 
 			opform = (Form_pg_operator) GETSTRUCT(tup);
-			if (opform->oprcom == tup->t_oid)
+			if (opform->oprcom == tup->t_data->t_oid)
 			{
 				if ((ltree != NULL) && (rtree != NULL))
 				{
diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c
index 4f0494318f4f9eff70b3fab97cdccc63e0485fd0..c9034557662309dc491ded5b72ea046fd8241293 100644
--- a/src/backend/parser/parse_type.c
+++ b/src/backend/parser/parse_type.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.17 1998/10/08 18:29:48 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.18 1998/11/27 19:52:14 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -96,7 +96,7 @@ typeTypeId(Type tp)
 {
 	if (tp == NULL)
 		elog(ERROR, "typeTypeId() called with NULL type struct");
-	return tp->t_oid;
+	return tp->t_data->t_oid;
 }
 
 /* given type (as type struct), return the length of type */
diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c
index 244d9b181d0d21016999583852770a8e72f3af33..17aa34be07b8f47f51c3b820872f5ab1d726b8f2 100644
--- a/src/backend/rewrite/rewriteRemove.c
+++ b/src/backend/rewrite/rewriteRemove.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.18 1998/09/01 04:31:36 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.19 1998/11/27 19:52:17 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -101,7 +101,7 @@ RemoveRewriteRule(char *ruleName)
 	 * Store the OID of the rule (i.e. the tuple's OID) and the event
 	 * relation's OID
 	 */
-	ruleId = tuple->t_oid;
+	ruleId = tuple->t_data->t_oid;
 	eventRelationOidDatum = heap_getattr(tuple,
 										 Anum_pg_rewrite_ev_class,
 									   RelationGetDescr(RewriteRelation),
@@ -125,7 +125,7 @@ RemoveRewriteRule(char *ruleName)
 	/*
 	 * Now delete the tuple...
 	 */
-	heap_delete(RewriteRelation, &tuple->t_ctid);
+	heap_delete(RewriteRelation, &tuple->t_self);
 
 	pfree(tuple);
 	heap_close(RewriteRelation);
@@ -162,7 +162,7 @@ RelationRemoveRules(Oid relid)
 							  0, SnapshotNow, 1, &scanKeyData);
 
 	while (HeapTupleIsValid(tuple = heap_getnext(scanDesc, 0)))
-		heap_delete(RewriteRelation, &tuple->t_ctid);
+		heap_delete(RewriteRelation, &tuple->t_self);
 
 	heap_endscan(scanDesc);
 	heap_close(RewriteRelation);
diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c
index 59d81172839973a7406cb7e6c33f623068ea13e8..2b57e2771165e228c3b0a9e524a32711260931f6 100644
--- a/src/backend/rewrite/rewriteSupport.c
+++ b/src/backend/rewrite/rewriteSupport.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.28 1998/09/01 04:31:37 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.29 1998/11/27 19:52:18 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -128,7 +128,7 @@ setRelhasrulesInRelation(Oid relationId, bool relhasrules)
 
 	relationRelation = heap_openr(RelationRelationName);
 	((Form_pg_class) GETSTRUCT(tuple))->relhasrules = relhasrules;
-	heap_replace(relationRelation, &tuple->t_ctid, tuple);
+	heap_replace(relationRelation, &tuple->t_self, tuple);
 
 	/* keep the catalog indices up to date */
 	CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, idescs);
diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c
index 277db2e2ab176112898b2499469ed3150de5775c..65ce0aba635f3d139c9272aeffe0acc4206cb75b 100644
--- a/src/backend/storage/large_object/inv_api.c
+++ b/src/backend/storage/large_object/inv_api.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.41 1998/10/06 03:55:43 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.42 1998/11/27 19:52:19 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -80,7 +80,7 @@
 /* non-export function prototypes */
 static HeapTuple inv_newtuple(LargeObjectDesc *obj_desc, Buffer buffer,
 			 Page page, char *dbuf, int nwrite);
-static HeapTuple inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer);
+static void inv_fetchtup(LargeObjectDesc *obj_desc, HeapTuple tuple, Buffer *buffer);
 static int	inv_wrnew(LargeObjectDesc *obj_desc, char *buf, int nbytes);
 static int inv_wrold(LargeObjectDesc *obj_desc, char *dbuf, int nbytes,
 		  HeapTuple tuple, Buffer buffer);
@@ -440,13 +440,13 @@ inv_tell(LargeObjectDesc *obj_desc)
 int
 inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 {
-	HeapTuple	tuple;
-	int			nread;
-	int			off;
-	int			ncopy;
-	Datum		d;
+	HeapTupleData	tuple;
+	int				nread;
+	int				off;
+	int				ncopy;
+	Datum			d;
 	struct varlena *fsblock;
-	bool		isNull;
+	bool			isNull;
 
 	Assert(PointerIsValid(obj_desc));
 	Assert(buf != NULL);
@@ -470,16 +470,16 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 		Buffer		buffer;
 
 		/* fetch an inversion file system block */
-		tuple = inv_fetchtup(obj_desc, &buffer);
+		inv_fetchtup(obj_desc, &tuple, &buffer);
 
-		if (!HeapTupleIsValid(tuple))
+		if (tuple.t_data == NULL)
 		{
 			obj_desc->flags |= IFS_ATEOF;
 			break;
 		}
 
 		/* copy the data from this block into the buffer */
-		d = heap_getattr(tuple, 2, obj_desc->hdesc, &isNull);
+		d = heap_getattr(&tuple, 2, obj_desc->hdesc, &isNull);
 		ReleaseBuffer(buffer);
 
 		fsblock = (struct varlena *) DatumGetPointer(d);
@@ -502,9 +502,9 @@ inv_read(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 int
 inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 {
-	HeapTuple	tuple;
-	int			nwritten;
-	int			tuplen;
+	HeapTupleData	tuple;
+	int				nwritten;
+	int				tuplen;
 
 	Assert(PointerIsValid(obj_desc));
 	Assert(buf != NULL);
@@ -536,19 +536,19 @@ inv_write(LargeObjectDesc *obj_desc, char *buf, int nbytes)
 
 		if ((obj_desc->flags & IFS_ATEOF)
 			|| obj_desc->heap_r->rd_nblocks == 0)
-			tuple = (HeapTuple) NULL;
+			tuple.t_data = NULL;
 		else
-			tuple = inv_fetchtup(obj_desc, &buffer);
+			inv_fetchtup(obj_desc, &tuple, &buffer);
 
 		/* either append or replace a block, as required */
-		if (!HeapTupleIsValid(tuple))
+		if (tuple.t_data == NULL)
 			tuplen = inv_wrnew(obj_desc, buf, nbytes - nwritten);
 		else
 		{
 			if (obj_desc->offset > obj_desc->highbyte)
 				tuplen = inv_wrnew(obj_desc, buf, nbytes - nwritten);
 			else
-				tuplen = inv_wrold(obj_desc, buf, nbytes - nwritten, tuple, buffer);
+				tuplen = inv_wrold(obj_desc, buf, nbytes - nwritten, &tuple, buffer);
 		}
 		ReleaseBuffer(buffer);
 
@@ -602,10 +602,9 @@ inv_cleanindex(LargeObjectDesc *obj_desc)
  *				A heap tuple containing the desired block, or NULL if no
  *				such tuple exists.
  */
-static HeapTuple
-inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer)
+static void
+inv_fetchtup(LargeObjectDesc *obj_desc, HeapTuple tuple, Buffer *buffer)
 {
-	HeapTuple	tuple;
 	RetrieveIndexResult res;
 	Datum		d;
 	int			firstbyte,
@@ -650,7 +649,8 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer)
 			if (res == (RetrieveIndexResult) NULL)
 			{
 				ItemPointerSetInvalid(&(obj_desc->htid));
-				return (HeapTuple) NULL;
+				tuple->t_data = NULL;
+				return;
 			}
 
 			/*
@@ -662,19 +662,18 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer)
 			 * way...	- vadim 07/28/98
 			 *
 			 */
-
-			tuple = heap_fetch(obj_desc->heap_r, SnapshotNow,
-							   &res->heap_iptr, buffer);
+			tuple->t_self = res->heap_iptr;
+			heap_fetch(obj_desc->heap_r, SnapshotNow, tuple, buffer);
 			pfree(res);
-		} while (tuple == (HeapTuple) NULL);
+		} while (tuple->t_data == NULL);
 
 		/* remember this tid -- we may need it for later reads/writes */
- 		ItemPointerCopy(&tuple->t_ctid, &obj_desc->htid);
+ 		ItemPointerCopy(&(tuple->t_self), &obj_desc->htid);
 	}
 	else
 	{
-		tuple = heap_fetch(obj_desc->heap_r, SnapshotNow,
-						   &(obj_desc->htid), buffer);
+		tuple->t_self = obj_desc->htid;
+		heap_fetch(obj_desc->heap_r, SnapshotNow, tuple, buffer);
 	}
 
 	/*
@@ -697,7 +696,7 @@ inv_fetchtup(LargeObjectDesc *obj_desc, Buffer *buffer)
 	obj_desc->lowbyte = firstbyte;
 	obj_desc->highbyte = lastbyte;
 
-	return tuple;
+	return;
 }
 
 /*
@@ -786,6 +785,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);
 
 	/* new tuple is inserted */
 	WriteBuffer(buffer);
@@ -822,9 +822,9 @@ inv_wrold(LargeObjectDesc *obj_desc,
 	 * abstraction.
 	 */
 
-	TransactionIdStore(GetCurrentTransactionId(), &(tuple->t_xmax));
-	tuple->t_cmax = GetCurrentCommandId();
-	tuple->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
+	TransactionIdStore(GetCurrentTransactionId(), &(tuple->t_data->t_xmax));
+	tuple->t_data->t_cmax = GetCurrentCommandId();
+	tuple->t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED | HEAP_XMAX_INVALID);
 
 	/*
 	 * If we're overwriting the entire block, we're lucky.	All we need to
@@ -953,6 +953,7 @@ inv_wrold(LargeObjectDesc *obj_desc,
 
 	/* index the new tuple */
 	inv_indextup(obj_desc, ntup);
+	pfree (ntup);
 
 	/*
 	 * move the scandesc forward so we don't reread the newly inserted
@@ -985,7 +986,7 @@ inv_newtuple(LargeObjectDesc *obj_desc,
 			 char *dbuf,
 			 int nwrite)
 {
-	HeapTuple	ntup;
+	HeapTuple	ntup = (HeapTuple) palloc (sizeof(HeapTupleData));
 	PageHeader	ph;
 	int			tupsize;
 	int			hoff;
@@ -997,7 +998,7 @@ inv_newtuple(LargeObjectDesc *obj_desc,
 	char	   *attptr;
 
 	/* compute tuple size -- no nulls */
-	hoff = offsetof(HeapTupleData, t_bits);
+	hoff = offsetof(HeapTupleHeaderData, t_bits);
 
 	/* add in olastbyte, varlena.vl_len, varlena.vl_dat */
 	tupsize = hoff + (2 * sizeof(int32)) + nwrite;
@@ -1036,7 +1037,7 @@ inv_newtuple(LargeObjectDesc *obj_desc,
 	ph->pd_lower = lower;
 	ph->pd_upper = upper;
 
-	ntup = (HeapTuple) ((char *) page + upper);
+	ntup->t_data = (HeapTupleHeader) ((char *) page + upper);
 
 	/*
 	 * Tuple is now allocated on the page.	Next, fill in the tuple
@@ -1044,15 +1045,15 @@ inv_newtuple(LargeObjectDesc *obj_desc,
 	 */
 
 	ntup->t_len = tupsize;
-	ItemPointerSet(&ntup->t_ctid, BufferGetBlockNumber(buffer), off);
-	LastOidProcessed = ntup->t_oid = newoid();
-	TransactionIdStore(GetCurrentTransactionId(), &(ntup->t_xmin));
-	ntup->t_cmin = GetCurrentCommandId();
-	StoreInvalidTransactionId(&(ntup->t_xmax));
-	ntup->t_cmax = 0;
-	ntup->t_infomask = HEAP_XMAX_INVALID;
-	ntup->t_natts = 2;
-	ntup->t_hoff = hoff;
+	ItemPointerSet(&ntup->t_self, BufferGetBlockNumber(buffer), off);
+	LastOidProcessed = ntup->t_data->t_oid = newoid();
+	TransactionIdStore(GetCurrentTransactionId(), &(ntup->t_data->t_xmin));
+	ntup->t_data->t_cmin = GetCurrentCommandId();
+	StoreInvalidTransactionId(&(ntup->t_data->t_xmax));
+	ntup->t_data->t_cmax = 0;
+	ntup->t_data->t_infomask = HEAP_XMAX_INVALID;
+	ntup->t_data->t_natts = 2;
+	ntup->t_data->t_hoff = hoff;
 
 	/* if a NULL is passed in, avoid the calculations below */
 	if (dbuf == NULL)
@@ -1063,7 +1064,7 @@ inv_newtuple(LargeObjectDesc *obj_desc,
 	 * the tuple and class abstractions.
 	 */
 
-	attptr = ((char *) ntup) + hoff;
+	attptr = ((char *) ntup->t_data) + hoff;
 	*((int32 *) attptr) = obj_desc->offset + nwrite - 1;
 	attptr += sizeof(int32);
 
@@ -1106,7 +1107,7 @@ inv_indextup(LargeObjectDesc *obj_desc, HeapTuple tuple)
 	n[0] = ' ';
 	v[0] = Int32GetDatum(obj_desc->highbyte);
 	res = index_insert(obj_desc->index_r, &v[0], &n[0],
-					   &(tuple->t_ctid), obj_desc->heap_r);
+					   &(tuple->t_self), obj_desc->heap_r);
 
 	if (res)
 		pfree(res);
@@ -1209,7 +1210,7 @@ _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln)
 {
 	IndexScanDesc iscan;
 	RetrieveIndexResult res;
-	HeapTuple	tuple;
+	HeapTupleData	tuple;
 	Datum		d;
 	long		size;
 	bool		isNull;
@@ -1239,16 +1240,17 @@ _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln)
 		 * rather that NowTimeQual.  We currently have no way to pass a
 		 * time qual in.
 		 */
-		tuple = heap_fetch(hreln, SnapshotNow, &res->heap_iptr, &buffer);
+		tuple.t_self = res->heap_iptr;
+		heap_fetch(hreln, SnapshotNow, &tuple, &buffer);
 		pfree(res);
-	} while (!HeapTupleIsValid(tuple));
+	} while (tuple.t_data == NULL);
 
 	/* don't need the index scan anymore */
 	index_endscan(iscan);
 	pfree(iscan);
 
 	/* get olastbyte attribute */
-	d = heap_getattr(tuple, 1, hdesc, &isNull);
+	d = heap_getattr(&tuple, 1, hdesc, &isNull);
 	size = DatumGetInt32(d) + 1;
 	ReleaseBuffer(buffer);
 
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 7103fbc7959977ed64ac4f16327707a393ac61fe..b6b237d51fa6b93a7fe4144059de0f4312d3f06a 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.32 1998/10/02 05:31:28 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.33 1998/11/27 19:52:22 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -41,8 +41,9 @@
 int32
 regprocin(char *pro_name_or_oid)
 {
-	HeapTuple	 proctup = NULL;
-	RegProcedure result = InvalidOid;
+	HeapTuple	 	proctup = NULL;
+	HeapTupleData	tuple;
+	RegProcedure	result = InvalidOid;
 
 	if (pro_name_or_oid == NULL)
 		return InvalidOid;
@@ -60,7 +61,7 @@ regprocin(char *pro_name_or_oid)
 								ObjectIdGetDatum(oidin(pro_name_or_oid)),
 										  0, 0, 0);
 			if (HeapTupleIsValid(proctup))
-				result = (RegProcedure) proctup->t_oid;
+				result = (RegProcedure) proctup->t_data->t_oid;
 			else
 				elog(ERROR, "No procedure with oid %s", pro_name_or_oid);
 		}
@@ -86,13 +87,14 @@ regprocin(char *pro_name_or_oid)
 			sd = index_beginscan(idesc, false, 1, skey);
 			while ((indexRes = index_getnext(sd, ForwardScanDirection)))
 			{
-				proctup = heap_fetch(hdesc, SnapshotNow,
-									&indexRes->heap_iptr,
+				tuple.t_self = indexRes->heap_iptr;
+				heap_fetch(hdesc, SnapshotNow,
+									&tuple,
 									&buffer);
 				pfree(indexRes);
-				if (HeapTupleIsValid(proctup))
+				if (tuple.t_data != NULL)
 				{
-					result = (RegProcedure) proctup->t_oid;
+					result = (RegProcedure) tuple.t_data->t_oid;
 					ReleaseBuffer(buffer);
 
 					if (++matches > 1)
diff --git a/src/backend/utils/adt/sets.c b/src/backend/utils/adt/sets.c
index 54aadc407c5076790168fc6587aad83757d6064b..a9c669bc3aa51d5731e765c8968116e8b8edee6e 100644
--- a/src/backend/utils/adt/sets.c
+++ b/src/backend/utils/adt/sets.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.18 1998/09/01 04:32:51 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.19 1998/11/27 19:52:23 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -123,10 +123,10 @@ SetDefine(char *querystr, char *typename)
 									  repl);
 
 			setheapoverride(true);
-			heap_replace(procrel, &tup->t_ctid, newtup);
+			heap_replace(procrel, &tup->t_self, newtup);
 			setheapoverride(false);
 
-			setoid = newtup->t_oid;
+			setoid = newtup->t_data->t_oid;
 		}
 		else
 			elog(ERROR, "setin: could not find new set oid tuple");
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index 97accc93db04345dd9a9f396f672aa28fb87d5e1..bb87291fdc08b97484bca52c6719d5aab5dfd8ef 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.35 1998/10/12 00:53:33 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.36 1998/11/27 19:52:26 vadim Exp $
  *
  * Notes:
  *		XXX This needs to use exception.h to handle recovery when
@@ -386,7 +386,7 @@ CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
 		case 4:
 			cacheInOutP->cc_skey[3].sk_argument =
 				(cacheInOutP->cc_key[3] == ObjectIdAttributeNumber)
-				? (Datum) tuple->t_oid
+				? (Datum) tuple->t_data->t_oid
 				: fastgetattr(tuple,
 							  cacheInOutP->cc_key[3],
 							  RelationGetDescr(relation),
@@ -396,7 +396,7 @@ CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
 		case 3:
 			cacheInOutP->cc_skey[2].sk_argument =
 				(cacheInOutP->cc_key[2] == ObjectIdAttributeNumber)
-				? (Datum) tuple->t_oid
+				? (Datum) tuple->t_data->t_oid
 				: fastgetattr(tuple,
 							  cacheInOutP->cc_key[2],
 							  RelationGetDescr(relation),
@@ -406,7 +406,7 @@ CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
 		case 2:
 			cacheInOutP->cc_skey[1].sk_argument =
 				(cacheInOutP->cc_key[1] == ObjectIdAttributeNumber)
-				? (Datum) tuple->t_oid
+				? (Datum) tuple->t_data->t_oid
 				: fastgetattr(tuple,
 							  cacheInOutP->cc_key[1],
 							  RelationGetDescr(relation),
@@ -416,7 +416,7 @@ CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP,
 		case 1:
 			cacheInOutP->cc_skey[0].sk_argument =
 				(cacheInOutP->cc_key[0] == ObjectIdAttributeNumber)
-				? (Datum) tuple->t_oid
+				? (Datum) tuple->t_data->t_oid
 				: fastgetattr(tuple,
 							  cacheInOutP->cc_key[0],
 							  RelationGetDescr(relation),
@@ -513,7 +513,7 @@ CatalogCacheIdInvalidate(int cacheId,	/* XXX */
 			 elt = DLGetSucc(elt))
 		{
 			ct = (CatCTup *) DLE_VAL(elt);
-			if (ItemPointerEquals(pointer, &ct->ct_tup->t_ctid))
+			if (ItemPointerEquals(pointer, &ct->ct_tup->t_self))
 				break;
 		}
 
@@ -1141,7 +1141,7 @@ RelationInvalidateCatalogCacheTuple(Relation relation,
 
 		(*function) (ccp->id,
 				 CatalogCacheComputeTupleHashIndex(ccp, relation, tuple),
-					 &tuple->t_ctid);
+					 &tuple->t_self);
 
 		heap_close(relation);
 	}
diff --git a/src/backend/utils/cache/fcache.c b/src/backend/utils/cache/fcache.c
index 8ebef95a2d8d67e56097809f10a9fc045499ebb5..08db2221969640bbfd2effc613ce2cde8b82763b 100644
--- a/src/backend/utils/cache/fcache.c
+++ b/src/backend/utils/cache/fcache.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.18 1998/09/01 04:32:58 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.19 1998/11/27 19:52:27 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -74,7 +74,7 @@ GetDynamicFuncArgType(Var *arg, ExprContext *econtext)
 		elog(ERROR, "Lookup failed on type tuple for class %s",
 			 relname);
 
-	return tup->t_oid;
+	return tup->t_data->t_oid;
 }
 
 static FunctionCachePtr
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index 0517e1a0cda1ef029a780120afd3f064b6a4e3c0..dc53399b5d1e108f2e98e840c44519d28cd75abc 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.17 1998/10/12 00:53:34 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.18 1998/11/27 19:52:28 vadim Exp $
  *
  * Note - this code is real crufty...
  *
@@ -250,25 +250,25 @@ getmyrelids()
 								PointerGetDatum(RelationRelationName),
 								0, 0, 0);
 	Assert(HeapTupleIsValid(tuple));
-	MyRelationRelationId = tuple->t_oid;
+	MyRelationRelationId = tuple->t_data->t_oid;
 
 	tuple = SearchSysCacheTuple(RELNAME,
 								PointerGetDatum(AttributeRelationName),
 								0, 0, 0);
 	Assert(HeapTupleIsValid(tuple));
-	MyAttributeRelationId = tuple->t_oid;
+	MyAttributeRelationId = tuple->t_data->t_oid;
 
 	tuple = SearchSysCacheTuple(RELNAME,
 								PointerGetDatum(AccessMethodRelationName),
 								0, 0, 0);
 	Assert(HeapTupleIsValid(tuple));
-	MyAMRelationId = tuple->t_oid;
+	MyAMRelationId = tuple->t_data->t_oid;
 
 	tuple = SearchSysCacheTuple(RELNAME,
 					   PointerGetDatum(AccessMethodOperatorRelationName),
 								0, 0, 0);
 	Assert(HeapTupleIsValid(tuple));
-	MyAMOPRelationId = tuple->t_oid;
+	MyAMOPRelationId = tuple->t_data->t_oid;
 }
 
 /* --------------------------------
@@ -481,11 +481,11 @@ RelationInvalidateRelationCache(Relation relation,
 	 * ----------------
 	 */
 	if (relationId == MyRelationRelationId)
-		objectId = tuple->t_oid;
+		objectId = tuple->t_data->t_oid;
 	else if (relationId == MyAttributeRelationId)
 		objectId = ((Form_pg_attribute) GETSTRUCT(tuple))->attrelid;
 	else if (relationId == MyAMRelationId)
-		objectId = tuple->t_oid;
+		objectId = tuple->t_data->t_oid;
 	else if (relationId == MyAMOPRelationId)
 	{
 		;						/* objectId is unused */
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index ba4acc9fa23018772d0f10a8269646fdcd810f24..492eba6f6596a53b5f2092a819a58aef4a1a965c 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.50 1998/09/01 04:33:02 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.51 1998/11/27 19:52:28 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -383,10 +383,7 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo)
 		 *	this bug is discovered and killed by wei on 9/27/91.
 		 * -------------------
 		 */
-		return_tuple = (HeapTuple) palloc((Size) pg_class_tuple->t_len);
-		memmove((char *) return_tuple,
-				(char *) pg_class_tuple,
-				(int) pg_class_tuple->t_len);
+		return_tuple = heap_copytuple(pg_class_tuple);
 	}
 
 	/* all done */
@@ -718,7 +715,7 @@ RelationBuildRuleLock(Relation relation)
 
 		rule = (RewriteRule *) palloc(sizeof(RewriteRule));
 
-		rule->ruleId = pg_rewrite_tuple->t_oid;
+		rule->ruleId = pg_rewrite_tuple->t_data->t_oid;
 
 		rule->event =
 			(int) heap_getattr(pg_rewrite_tuple,
@@ -838,7 +835,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo)
 	 *	get information from the pg_class_tuple
 	 * ----------------
 	 */
-	relid = pg_class_tuple->t_oid;
+	relid = pg_class_tuple->t_data->t_oid;
 	relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
 	natts = relp->relnatts;
 
@@ -1661,11 +1658,10 @@ AttrDefaultFetch(Relation relation)
 	Relation	adrel;
 	Relation	irel;
 	ScanKeyData skey;
-	HeapTuple	tuple;
+	HeapTupleData	tuple;
 	Form_pg_attrdef adform;
 	IndexScanDesc sd;
 	RetrieveIndexResult indexRes;
-	ItemPointer iptr;
 	struct varlena *val;
 	bool		isnull;
 	int			found;
@@ -1680,7 +1676,7 @@ AttrDefaultFetch(Relation relation)
 	adrel = heap_openr(AttrDefaultRelationName);
 	irel = index_openr(AttrDefaultIndex);
 	sd = index_beginscan(irel, false, 1, &skey);
-	tuple = (HeapTuple) NULL;
+	tuple.t_data = NULL;
 
 	for (found = 0;;)
 	{
@@ -1690,13 +1686,13 @@ AttrDefaultFetch(Relation relation)
 		if (!indexRes)
 			break;
 
-		iptr = &indexRes->heap_iptr;
-		tuple = heap_fetch(adrel, SnapshotNow, iptr, &buffer);
+		tuple.t_self = indexRes->heap_iptr;
+		heap_fetch(adrel, SnapshotNow, &tuple, &buffer);
 		pfree(indexRes);
-		if (!HeapTupleIsValid(tuple))
+		if (tuple.t_data == NULL)
 			continue;
 		found++;
-		adform = (Form_pg_attrdef) GETSTRUCT(tuple);
+		adform = (Form_pg_attrdef) GETSTRUCT(&tuple);
 		for (i = 0; i < ndef; i++)
 		{
 			if (adform->adnum != attrdef[i].adnum)
@@ -1706,7 +1702,7 @@ AttrDefaultFetch(Relation relation)
 				relation->rd_att->attrs[adform->adnum - 1]->attname.data,
 					 relation->rd_rel->relname.data);
 
-			val = (struct varlena *) fastgetattr(tuple,
+			val = (struct varlena *) fastgetattr(&tuple,
 												 Anum_pg_attrdef_adbin,
 												 adrel->rd_att, &isnull);
 			if (isnull)
@@ -1714,7 +1710,7 @@ AttrDefaultFetch(Relation relation)
 				relation->rd_att->attrs[adform->adnum - 1]->attname.data,
 					 relation->rd_rel->relname.data);
 			attrdef[i].adbin = textout(val);
-			val = (struct varlena *) fastgetattr(tuple,
+			val = (struct varlena *) fastgetattr(&tuple,
 												 Anum_pg_attrdef_adsrc,
 												 adrel->rd_att, &isnull);
 			if (isnull)
@@ -1750,10 +1746,9 @@ RelCheckFetch(Relation relation)
 	Relation	rcrel;
 	Relation	irel;
 	ScanKeyData skey;
-	HeapTuple	tuple;
+	HeapTupleData	tuple;
 	IndexScanDesc sd;
 	RetrieveIndexResult indexRes;
-	ItemPointer iptr;
 	Name		rcname;
 	struct varlena *val;
 	bool		isnull;
@@ -1768,7 +1763,7 @@ RelCheckFetch(Relation relation)
 	rcrel = heap_openr(RelCheckRelationName);
 	irel = index_openr(RelCheckIndex);
 	sd = index_beginscan(irel, false, 1, &skey);
-	tuple = (HeapTuple) NULL;
+	tuple.t_data = NULL;
 
 	for (found = 0;;)
 	{
@@ -1778,30 +1773,30 @@ RelCheckFetch(Relation relation)
 		if (!indexRes)
 			break;
 
-		iptr = &indexRes->heap_iptr;
-		tuple = heap_fetch(rcrel, SnapshotNow, iptr, &buffer);
+		tuple.t_self = indexRes->heap_iptr;
+		heap_fetch(rcrel, SnapshotNow, &tuple, &buffer);
 		pfree(indexRes);
-		if (!HeapTupleIsValid(tuple))
+		if (tuple.t_data == NULL)
 			continue;
 		if (found == ncheck)
 			elog(ERROR, "RelCheckFetch: unexpected record found for rel %s",
 				 relation->rd_rel->relname.data);
 
-		rcname = (Name) fastgetattr(tuple,
+		rcname = (Name) fastgetattr(&tuple,
 									Anum_pg_relcheck_rcname,
 									rcrel->rd_att, &isnull);
 		if (isnull)
 			elog(ERROR, "RelCheckFetch: rcname IS NULL for rel %s",
 				 relation->rd_rel->relname.data);
 		check[found].ccname = nameout(rcname);
-		val = (struct varlena *) fastgetattr(tuple,
+		val = (struct varlena *) fastgetattr(&tuple,
 											 Anum_pg_relcheck_rcbin,
 											 rcrel->rd_att, &isnull);
 		if (isnull)
 			elog(ERROR, "RelCheckFetch: rcbin IS NULL for rel %s",
 				 relation->rd_rel->relname.data);
 		check[found].ccbin = textout(val);
-		val = (struct varlena *) fastgetattr(tuple,
+		val = (struct varlena *) fastgetattr(&tuple,
 											 Anum_pg_relcheck_rcsrc,
 											 rcrel->rd_att, &isnull);
 		if (isnull)
diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c
index 6ea7b0c9ca20920832fee173c120f6260ada70ee..60f6499872e86efc2571af7a6cc3b3b1befd3871 100644
--- a/src/backend/utils/misc/database.c
+++ b/src/backend/utils/misc/database.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.20 1998/09/03 02:32:41 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.21 1998/11/27 19:52:29 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -188,7 +188,7 @@ GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path, int *encodin
 	int			nbytes;
 	int			max,
 				i;
-	HeapTuple	tup;
+	HeapTupleData	tup;
 	Page		pg;
 	PageHeader	ph;
 	char	   *dbfname;
@@ -238,7 +238,7 @@ GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path, int *encodin
 
 			/* get a pointer to the tuple itself */
 			offset = (int) ph->pd_linp[i].lp_off;
-			tup = (HeapTuple) (((char *) pg) + offset);
+			tup.t_data = (HeapTupleHeader) (((char *) pg) + offset);
 
 			/*
 			 * if the tuple has been deleted (the database was destroyed),
@@ -253,7 +253,7 @@ GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path, int *encodin
 			 * if data is ever moved and no longer the first field this
 			 * will be broken!! -mer 11 Nov 1991.
 			 */
-			if (TransactionIdIsValid((TransactionId) tup->t_xmax))
+			if (TransactionIdIsValid((TransactionId) tup.t_data->t_xmax))
 				continue;
 
 			/*
@@ -267,7 +267,7 @@ GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path, int *encodin
 			 * you exactly how big the header actually is. use the PC
 			 * means of getting at sys cat attrs.
 			 */
-			tup_db = (Form_pg_database) GETSTRUCT(tup);
+			tup_db = (Form_pg_database) GETSTRUCT(&tup);
 #ifdef MULTIBYTE
 
 			/*
@@ -279,7 +279,7 @@ GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path, int *encodin
 #endif
 			if (strcmp(name, tup_db->datname.data) == 0)
 			{
-				*db_id = tup->t_oid;
+				*db_id = tup.t_data->t_oid;
 				strncpy(path, VARDATA(&(tup_db->datpath)),
 						(VARSIZE(&(tup_db->datpath)) - VARHDRSZ));
 				*(path + VARSIZE(&(tup_db->datpath)) - VARHDRSZ) = '\0';
diff --git a/src/backend/utils/sort/psort.c b/src/backend/utils/sort/psort.c
index 9a1271ea5096ae3d4a50bb7ccd405690cd140238..0c4efabf5fd49b8861dd2a00c12f0015b19293e2 100644
--- a/src/backend/utils/sort/psort.c
+++ b/src/backend/utils/sort/psort.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.42 1998/09/01 03:27:13 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.43 1998/11/27 19:52:32 vadim Exp $
  *
  * NOTES
  *		Sorts the first relation into the second relation.
@@ -66,7 +66,6 @@ static void initialrun(Sort *node);
 static void inittapes(Sort *node);
 static void merge(Sort *node, struct tape * dest);
 static FILE *mergeruns(Sort *node);
-static HeapTuple tuplecopy(HeapTuple tup);
 static int	_psort_cmp(HeapTuple *ltup, HeapTuple *rtup);
 
 
@@ -224,9 +223,11 @@ inittapes(Sort *node)
 
 #define PUTTUP(NODE, TUP, FP) \
 ( \
+	(TUP)->t_len += HEAPTUPLESIZE, \
 	((Psortstate *)NODE->psortstate)->BytesWritten += (TUP)->t_len, \
 	fwrite((char *)TUP, (TUP)->t_len, 1, FP), \
-	fwrite((char *)&((TUP)->t_len), sizeof (tlendummy), 1, FP) \
+	fwrite((char *)&((TUP)->t_len), sizeof (tlendummy), 1, FP), \
+	(TUP)->t_len -= HEAPTUPLESIZE \
 )
 
 #define ENDRUN(FP)		fwrite((char *)&tlenzero, sizeof (tlenzero), 1, FP)
@@ -237,10 +238,11 @@ inittapes(Sort *node)
 	IncrProcessed(), \
 	((Psortstate *)NODE->psortstate)->BytesRead += (LEN) - sizeof (tlenzero), \
 	fread((char *)(TUP) + sizeof (tlenzero), (LEN) - sizeof (tlenzero), 1, FP), \
+	(TUP)->t_data = (HeapTupleHeader) ((char *)(TUP) + HEAPTUPLESIZE), \
 	fread((char *)&tlendummy, sizeof (tlendummy), 1, FP) \
 )
 
-#define SETTUPLEN(TUP, LEN)		(TUP)->t_len = LEN
+#define SETTUPLEN(TUP, LEN)		(TUP)->t_len = LEN - HEAPTUPLESIZE
 
  /*
   * USEMEM			- record use of memory FREEMEM		   - record
@@ -407,7 +409,7 @@ createfirstrun(Sort *node)
 			break;
 		}
 
-		tup = tuplecopy(cr_slot->val);
+		tup = heap_copytuple(cr_slot->val);
 		ExecClearTuple(cr_slot);
 
 		IncrProcessed();
@@ -524,7 +526,7 @@ createrun(Sort *node, FILE *file)
 		}
 		else
 		{
-			tup = tuplecopy(cr_slot->val);
+			tup = heap_copytuple(cr_slot->val);
 			ExecClearTuple(cr_slot);
 			PS(node)->tupcount++;
 		}
@@ -577,26 +579,6 @@ createrun(Sort *node, FILE *file)
 	return !foundeor;
 }
 
-/*
- *		tuplecopy		- see also tuple.c:palloctup()
- *
- *		This should eventually go there under that name?  And this will
- *		then use palloc directly (see version -r1.2).
- */
-static HeapTuple
-tuplecopy(HeapTuple tup)
-{
-	HeapTuple	rettup;
-
-	if (!HeapTupleIsValid(tup))
-	{
-		return NULL;			/* just in case */
-	}
-	rettup = (HeapTuple) palloc(tup->t_len);
-	memmove((char *) rettup, (char *) tup, tup->t_len); /* XXX */
-	return rettup;
-}
-
 /*
  *		mergeruns		- merges all runs from input tapes
  *						  (polyphase merge Alg.D(D6)--Knuth, Vol.3, p271)
@@ -792,7 +774,7 @@ psort_grabtuple(Sort *node, bool *should_free)
 				return NULL;
 			if (GETLEN(tuplen, PS(node)->psort_grab_file) && tuplen != 0)
 			{
-				tup = (HeapTuple) palloc((unsigned) tuplen);
+				tup = ALLOCTUP(tuplen);
 				SETTUPLEN(tup, tuplen);
 				GETTUP(node, tup, tuplen, PS(node)->psort_grab_file);
 
@@ -864,7 +846,7 @@ psort_grabtuple(Sort *node, bool *should_free)
 		 */
 		fseek(PS(node)->psort_grab_file,
 			  PS(node)->psort_current - tuplen, SEEK_SET);
-		tup = (HeapTuple) palloc((unsigned) tuplen);
+		tup = ALLOCTUP(tuplen);
 		SETTUPLEN(tup, tuplen);
 		GETTUP(node, tup, tuplen, PS(node)->psort_grab_file);
 		return tup;				/* file position is equal to psort_current */
diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c
index dba296727daf064662eb722adc56dfb050852127..c88646151a7bd925f582191b6c0ce4dbb546bb3e 100644
--- a/src/backend/utils/time/tqual.c
+++ b/src/backend/utils/time/tqual.c
@@ -7,7 +7,7 @@
  *
  *
  * IDENTIFICATION
- *	  $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.19 1998/09/01 04:33:41 momjian Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.20 1998/11/27 19:52:36 vadim Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -75,7 +75,7 @@ setheapoverride(bool on)
  *			 Xmax is not committed)))			that has not been committed
  */
 bool
-HeapTupleSatisfiesItself(HeapTuple tuple)
+HeapTupleSatisfiesItself(HeapTupleHeader tuple)
 {
 
 	if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
@@ -171,7 +171,7 @@ HeapTupleSatisfiesItself(HeapTuple tuple)
  *		that do catalog accesses.  this is unfortunate, but not critical.
  */
 bool
-HeapTupleSatisfiesNow(HeapTuple tuple)
+HeapTupleSatisfiesNow(HeapTupleHeader tuple)
 {
 	if (AMI_OVERRIDE)
 		return true;