diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c
index bdea2ee0ffd27106e7d1eeee495d23b57cbc4cb3..e71532b220e8acdda77d4be7088b8556a9b04d7e 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.58 1999/12/20 10:40:38 wieck Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.59 1999/12/21 00:06:39 wieck Exp $
  *
  * NOTES
  *	  some of the executor utility code such as "ExecTypeFromTL" should be
@@ -378,8 +378,12 @@ TupleDescInitEntry(TupleDesc desc,
  * relations for automatic move off into "secondary" relation.
  * Jan
  */
-#ifdef LONG_ATTRIBUTES_NOW_IMPLEMENTED_FOR_ALL_VARLENA_DATA_TYPES
-		att->attcanlong = (att->attlen == -1) ? 'e' : 'p';
+#ifdef TUPLE_TOASTER_ACTIVE
+#ifdef TUPLE_TOASTER_ALL_TYPES
+		att->attstorage = (att->attlen == -1) ? 'e' : 'p';
+#else
+		att->attstorage = 'p';
+#endif
 #else
 		att->attstorage = 'p';
 #endif
diff --git a/src/backend/access/heap/Makefile b/src/backend/access/heap/Makefile
index 7748bd55e2d0fae4095a6d2605bcd19cf6a245f2..2671e52f538aa5f6d991ed11e3f5089ea79dfbc0 100644
--- a/src/backend/access/heap/Makefile
+++ b/src/backend/access/heap/Makefile
@@ -4,7 +4,7 @@
 #    Makefile for access/heap
 #
 # IDENTIFICATION
-#    $Header: /cvsroot/pgsql/src/backend/access/heap/Makefile,v 1.8 1999/12/13 22:32:24 momjian Exp $
+#    $Header: /cvsroot/pgsql/src/backend/access/heap/Makefile,v 1.9 1999/12/21 00:06:40 wieck Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -13,7 +13,7 @@ include ../../../Makefile.global
 
 CFLAGS += -I../.. 
 
-OBJS = heapam.o hio.o stats.o
+OBJS = heapam.o hio.o stats.o tuptoaster.o
 
 all: SUBSYS.o
 
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index 7b03545bf1c985454bc27ea458a9d04b81fb7ad8..9ff1525b88cf9da390476ff721102e60e2f684fe 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.61 1999/12/16 22:19:36 wieck Exp $
+ *	  $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.62 1999/12/21 00:06:40 wieck Exp $
  *
  *
  * INTERFACE ROUTINES
@@ -78,6 +78,7 @@
 #include "access/heapam.h"
 #include "access/hio.h"
 #include "access/valid.h"
+#include "access/tuptoaster.h"
 #include "catalog/catalog.h"
 #include "miscadmin.h"
 #include "storage/smgr.h"
diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c
new file mode 100644
index 0000000000000000000000000000000000000000..c351c4cc1775284500ea2c94acdc451d6be2838e
--- /dev/null
+++ b/src/backend/access/heap/tuptoaster.c
@@ -0,0 +1,46 @@
+/*-------------------------------------------------------------------------
+ *
+ * tuptoaster.c
+ *	  Support routines for external and compressed storage of
+ *    variable size attributes.
+ *
+ * Copyright (c) 2000, PostgreSQL Development Team
+ *
+ *
+ * IDENTIFICATION
+ *	  $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.1 1999/12/21 00:06:40 wieck Exp $
+ *
+ *
+ * INTERFACE ROUTINES
+ *		heap_tuple_toast_attrs -
+ *			Try to make a given tuple fit into one page by compressing
+ *			or moving off attributes
+ *
+ *-------------------------------------------------------------------------
+ */
+
+#include "postgres.h"
+
+#include "access/heapam.h"
+#include "access/tuptoaster.h"
+#include "catalog/catalog.h"
+#include "utils/rel.h"
+
+
+#ifdef TUPLE_TOASTER_ACTIVE
+
+void
+heap_tuple_toast_attrs (Relation rel, HeapTuple newtup, HeapTuple oldtup)
+{
+	return;
+}
+
+
+varattrib *
+heap_tuple_untoast_attr (varattrib *attr)
+{
+	elog(ERROR, "heap_tuple_untoast_attr() called");
+}
+
+
+#endif /* TUPLE_TOASTER_ACTIVE */
diff --git a/src/include/access/htup.h b/src/include/access/htup.h
index c81dcfd6a8823b83b2105e259f0c56cd1e8fe6c1..862ce86e22d1f77cedecba6d81dd70fad5e8ee06 100644
--- a/src/include/access/htup.h
+++ b/src/include/access/htup.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: htup.h,v 1.26 1999/12/16 22:19:58 wieck Exp $
+ * $Id: htup.h,v 1.27 1999/12/21 00:06:42 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -125,6 +125,11 @@ typedef HeapTupleData *HeapTuple;
 #define HEAP_HASNULL			0x0001	/* has null attribute(s) */
 #define HEAP_HASVARLENA			0x0002	/* has variable length
 										 * attribute(s) */
+#define HEAP_HASEXTERNAL		0x0004	/* has external stored */
+										/* attribute(s) */
+#define HEAP_HASCOMPRESSED		0x0008	/* has compressed stored */
+										/* attribute(s) */
+#define HEAP_HASEXTENDED		0x000C	/* the two above combined */
 #define HEAP_XMIN_COMMITTED		0x0100	/* t_xmin committed */
 #define HEAP_XMIN_INVALID		0x0200	/* t_xmin invalid/aborted */
 #define HEAP_XMAX_COMMITTED		0x0400	/* t_xmax committed */
@@ -144,4 +149,13 @@ typedef HeapTupleData *HeapTuple;
 #define HeapTupleAllFixed(tuple) \
 		(!(((HeapTuple) (tuple))->t_data->t_infomask & HEAP_HASVARLENA))
 
+#define HeapTupleHasExternal(tuple) \
+		((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASEXTERNAL) != 0)
+
+#define HeapTupleHasCompressed(tuple) \
+		((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASCOMPRESSED) != 0)
+
+#define HeapTupleHasExtended(tuple) \
+		((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASEXTENDED) != 0)
+
 #endif	 /* HTUP_H */
diff --git a/src/include/access/tupmacs.h b/src/include/access/tupmacs.h
index baaf4bd0ac05504adb5e02c5578f367374adb41d..177b68c5ecfca7a8edead015e752101adce0b170 100644
--- a/src/include/access/tupmacs.h
+++ b/src/include/access/tupmacs.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1994, Regents of the University of California
  *
- * $Id: tupmacs.h,v 1.11 1999/07/15 15:20:56 momjian Exp $
+ * $Id: tupmacs.h,v 1.12 1999/12/21 00:06:42 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -88,7 +88,7 @@
 	) \
 	: \
 	( \
-		(cur_offset) + VARSIZE(DatumGetPointer(attval)) \
+		(cur_offset) + VARATT_SIZE(DatumGetPointer(attval)) \
 	) \
 )
 
diff --git a/src/include/access/tuptoaster.h b/src/include/access/tuptoaster.h
new file mode 100644
index 0000000000000000000000000000000000000000..dedc770db2290c7b0ca6c9253befb0f7387d8e0b
--- /dev/null
+++ b/src/include/access/tuptoaster.h
@@ -0,0 +1,33 @@
+/*-------------------------------------------------------------------------
+ *
+ * tuptoaster.h
+ *	  POSTGRES definitions for external and compressed storage
+ *    of variable size attributes.
+ *
+ * Copyright (c) 2000, PostgreSQL Development Team
+ *
+ * $Id: tuptoaster.h,v 1.1 1999/12/21 00:06:42 wieck Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#ifndef TUPTOASTER_H
+#define TUPTOASTER_H
+
+#ifdef TUPLE_TOASTER_ACTIVE
+
+#include "postgres.h"
+#include "access/heapam.h"
+#include "access/htup.h"
+#include "access/tupmacs.h"
+#include "utils/rel.h"
+
+
+extern void heap_tuple_toast_attrs(Relation rel, 
+				HeapTuple newtup, HeapTuple oldtup);
+
+extern varattrib *heap_tuple_untoast_attr(varattrib *attr);
+
+#endif /* TUPLE_TOASTER_ACTIVE */
+
+
+#endif	 /* TUPTOASTER_H */
diff --git a/src/include/postgres.h b/src/include/postgres.h
index 396c3c262bf2328a543d06b3f667dc7c84737574..e03922ceda458b9cc24d62303d2da65cf8a5952b 100644
--- a/src/include/postgres.h
+++ b/src/include/postgres.h
@@ -6,7 +6,7 @@
  *
  * Copyright (c) 1995, Regents of the University of California
  *
- * $Id: postgres.h,v 1.30 1999/11/07 23:08:32 momjian Exp $
+ * $Id: postgres.h,v 1.31 1999/12/21 00:06:41 wieck Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -104,6 +104,79 @@ typedef struct varlena text;
 typedef int2 int28[8];
 typedef Oid oid8[8];
 
+
+/*
+ * Proposed new layout for variable length attributes
+ * DO NOT USE YET - Jan
+ */
+#undef TUPLE_TOASTER_ACTIVE
+#undef TUPLE_TOASTER_ALL_TYPES
+
+#ifdef TUPLE_TOASTER_ACTIVE
+typedef struct varattrib
+{
+	int32				va_header;			/* External/compressed storage */
+											/* flags and item size */
+	union
+	{
+		struct
+		{
+			int32		va_rawsize;			/* Plain data size */
+		}				va_compressed;		/* Compressed stored attribute */
+
+		struct
+		{
+			int32		va_rawsize;			/* Plain data size */
+			Oid			va_valueid;			/* Unique identifier of value */
+			Oid			va_longrelid;		/* RelID where to find chunks */
+			Oid			va_rowid;			/* Main tables row Oid */
+			int16		va_attno;			/* Main tables attno */
+		}				va_external;		/* External stored attribute */
+
+		char			va_data[1];			/* Plain stored attribute */
+	}					va_content;
+} varattrib;
+
+#define VARATT_FLAG_EXTERNAL	0x8000
+#define VARATT_FLAG_COMPRESSED	0x4000
+#define VARATT_MASK_FLAGS		0xc000
+#define VARATT_MASK_SIZE		0x3fff
+
+#define VARATT_SIZEP(_PTR)	(((varattrib *)(_PTR))->va_header)
+#define VARATT_SIZE(PTR)	(VARATT_SIZEP(PTR) & VARATT_MASK_SIZE) 
+#define VARATT_DATA(PTR)	(((varattrib *)(PTR))->va_content.va_data)
+
+#define VARATT_IS_EXTENDED(PTR)		\
+				((VARATT_SIZEP(PTR) & VARATT_MASK_FLAGS) != 0)
+#define VARATT_IS_EXTERNAL(PTR)		\
+				((VARATT_SIZEP(PTR) & VARATT_FLAG_EXTERNAL) != 0)
+#define VARATT_IS_COMPRESSED(PTR)	\
+				((VARATT_SIZEP(PTR) & VARATT_FLAG_COMPRESSED) != 0)
+
+/* ----------
+ * This is regularly declared in access/tuptoaster.h,
+ * but we don't want to include that into every source,
+ * so we (evil evil evil) declare it here once more.
+ * ----------
+ */
+extern varattrib *heap_tuple_untoast_attr(varattrib *attr);
+
+#define VARATT_GETPLAIN(_ARG,_VAR) {								\
+				if (VARATTR_IS_EXTENDED(_ARG))						\
+					(_VAR) = (void *)heap_tuple_untoast_attr(_ARG);	\
+				else												\
+					(_VAR) = (_ARG);								\
+			}
+#define VARATT_FREE(_ARG,VAR) {										\
+				if ((void *)(_VAR) != (void *)(_ARG))				\
+					pfree((void *)(_VAR));							\
+			}
+#else /* TUPLE_TOASTER_ACTIVE */
+#define VARATT_SIZE(__PTR) VARSIZE(__PTR)
+#define VARATT_SIZEP(__PTR) VARSIZE(__PTR)
+#endif /* TUPLE_TOASTER_ACTIVE */
+
+
 /* We want NameData to have length NAMEDATALEN and int alignment,
  * because that's how the data type 'name' is defined in pg_type.
  * Use a union to make sure the compiler agrees.
diff --git a/src/test/regress/expected/opr_sanity.out b/src/test/regress/expected/opr_sanity.out
index 96253c77511d4ef38382ba20d48f57ba904dea52..305b67e42d6517ff080ff5a46b2c58112df00b35 100644
--- a/src/test/regress/expected/opr_sanity.out
+++ b/src/test/regress/expected/opr_sanity.out
@@ -3,7 +3,8 @@ FROM pg_proc as p1
 WHERE (p1.prolang = 0 OR p1.prorettype = 0 OR
     p1.pronargs < 0 OR p1.pronargs > 9)
 	AND p1.proname !~ '^pl[^_]+_call_handler$'
-	AND p1.proname !~ '^RI_FKey_';
+	AND p1.proname !~ '^RI_FKey_'
+	AND p1.proname != 'update_pg_pwd';
 oid|proname
 ---+-------
 (0 rows)
diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out
index 5938458a88e762a7acff9f858e5922f5bfc6e72d..ccf5ffd4333fdf656513d03f737fc58c690bee16 100644
--- a/src/test/regress/expected/rules.out
+++ b/src/test/regress/expected/rules.out
@@ -128,11 +128,11 @@ a| b
 2|13
 (3 rows)
 
-QUERY: delete from rtest_v1 where b = 12;
-QUERY: select * from rtest_v1;
 ** Remember the delete rule on rtest_v1: It says
 ** DO INSTEAD DELETE FROM rtest_t1 WHERE a = old.a
 ** So this time both rows with a = 2 must get deleted
+QUERY: delete from rtest_v1 where b = 12;
+QUERY: select * from rtest_v1;
 a| b
 -+--
 1|11
diff --git a/src/test/regress/sql/opr_sanity.sql b/src/test/regress/sql/opr_sanity.sql
index 8cfc8505d8689818e56b54154968b67e274464e6..a465d26a06994f1f4893279162cff02022605037 100644
--- a/src/test/regress/sql/opr_sanity.sql
+++ b/src/test/regress/sql/opr_sanity.sql
@@ -28,7 +28,8 @@ FROM pg_proc as p1
 WHERE (p1.prolang = 0 OR p1.prorettype = 0 OR
     p1.pronargs < 0 OR p1.pronargs > 9)
 	AND p1.proname !~ '^pl[^_]+_call_handler$'
-	AND p1.proname !~ '^RI_FKey_';
+	AND p1.proname !~ '^RI_FKey_'
+	AND p1.proname != 'update_pg_pwd';
 
 -- Look for conflicting proc definitions (same names and input datatypes).