Index: src/backend/access/common/printtup.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/access/common/printtup.c,v
retrieving revision 1.78
diff -c -r1.78 printtup.c
*** src/backend/access/common/printtup.c	6 Aug 2003 17:46:45 -0000	1.78
--- src/backend/access/common/printtup.c	24 Nov 2003 17:08:27 -0000
***************
*** 237,246 ****
   * Get the lookup info that printtup() needs
   */
  static void
! printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo, int numAttrs)
  {
  	int16	   *formats = myState->portal->formats;
  	int			i;
  
  	if (myState->myinfo)
  		pfree(myState->myinfo); /* get rid of any old data */
--- 237,247 ----
   * Get the lookup info that printtup() needs
   */
  static void
! printtup_prepare_info(DR_printtup *myState, TupleDesc typeinfo)
  {
  	int16	   *formats = myState->portal->formats;
  	int			i;
+ 	int			numAttrs = typeinfo->natts;
  
  	if (myState->myinfo)
  		pfree(myState->myinfo); /* get rid of any old data */
***************
*** 294,300 ****
  
  	/* Set or update my derived attribute info, if needed */
  	if (myState->attrinfo != typeinfo || myState->nattrs != natts)
! 		printtup_prepare_info(myState, typeinfo, natts);
  
  	/*
  	 * Prepare a DataRow message
--- 295,301 ----
  
  	/* Set or update my derived attribute info, if needed */
  	if (myState->attrinfo != typeinfo || myState->nattrs != natts)
! 		printtup_prepare_info(myState, typeinfo);
  
  	/*
  	 * Prepare a DataRow message
***************
*** 380,386 ****
  
  	/* Set or update my derived attribute info, if needed */
  	if (myState->attrinfo != typeinfo || myState->nattrs != natts)
! 		printtup_prepare_info(myState, typeinfo, natts);
  
  	/*
  	 * tell the frontend to expect new tuple data (in ASCII style)
--- 381,387 ----
  
  	/* Set or update my derived attribute info, if needed */
  	if (myState->attrinfo != typeinfo || myState->nattrs != natts)
! 		printtup_prepare_info(myState, typeinfo);
  
  	/*
  	 * tell the frontend to expect new tuple data (in ASCII style)
***************
*** 584,590 ****
  
  	/* Set or update my derived attribute info, if needed */
  	if (myState->attrinfo != typeinfo || myState->nattrs != natts)
! 		printtup_prepare_info(myState, typeinfo, natts);
  
  	/*
  	 * tell the frontend to expect new tuple data (in binary style)
--- 585,591 ----
  
  	/* Set or update my derived attribute info, if needed */
  	if (myState->attrinfo != typeinfo || myState->nattrs != natts)
! 		printtup_prepare_info(myState, typeinfo);
  
  	/*
  	 * tell the frontend to expect new tuple data (in binary style)
Index: src/backend/access/common/tupdesc.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/access/common/tupdesc.c,v
retrieving revision 1.100
diff -c -r1.100 tupdesc.c
*** src/backend/access/common/tupdesc.c	25 Sep 2003 06:57:56 -0000	1.100
--- src/backend/access/common/tupdesc.c	25 Nov 2003 03:59:43 -0000
***************
*** 55,71 ****
  
  	desc->natts = natts;
  	desc->tdhasoid = hasoid;
  
  	if (natts > 0)
  	{
  		uint32		size = natts * sizeof(Form_pg_attribute);
  
! 		desc->attrs = (Form_pg_attribute *) palloc0(size);
  	}
  	else
  		desc->attrs = NULL;
- 	desc->constr = NULL;
  
  	return desc;
  }
  
--- 55,73 ----
  
  	desc->natts = natts;
  	desc->tdhasoid = hasoid;
+ 	desc->mcxt = CurrentMemoryContext;
  
  	if (natts > 0)
  	{
  		uint32		size = natts * sizeof(Form_pg_attribute);
  
! 		desc->attrs = palloc0(size);
  	}
  	else
  		desc->attrs = NULL;
  
+ 	desc->attrs_by_pos = NULL;
+ 	desc->constr = NULL;
  	return desc;
  }
  
***************
*** 89,204 ****
  	desc = (TupleDesc) palloc(sizeof(struct tupleDesc));
  	desc->attrs = attrs;
  	desc->natts = natts;
- 	desc->constr = NULL;
  	desc->tdhasoid = hasoid;
  
- 	return desc;
- }
- 
- /* ----------------------------------------------------------------
-  *		CreateTupleDescCopy
-  *
-  *		This function creates a new TupleDesc by copying from an existing
-  *		TupleDesc
-  *
-  *		!!! Constraints are not copied !!!
-  * ----------------------------------------------------------------
-  */
- TupleDesc
- CreateTupleDescCopy(TupleDesc tupdesc)
- {
- 	TupleDesc	desc;
- 	int			i,
- 				size;
- 
- 	desc = (TupleDesc) palloc(sizeof(struct tupleDesc));
- 	desc->natts = tupdesc->natts;
- 	if (desc->natts > 0)
- 	{
- 		size = desc->natts * sizeof(Form_pg_attribute);
- 		desc->attrs = (Form_pg_attribute *) palloc(size);
- 		for (i = 0; i < desc->natts; i++)
- 		{
- 			desc->attrs[i] = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE);
- 			memcpy(desc->attrs[i], tupdesc->attrs[i], ATTRIBUTE_TUPLE_SIZE);
- 			desc->attrs[i]->attnotnull = false;
- 			desc->attrs[i]->atthasdef = false;
- 		}
- 	}
- 	else
- 		desc->attrs = NULL;
  	desc->constr = NULL;
! 	desc->tdhasoid = tupdesc->tdhasoid;
  
  	return desc;
  }
  
  /* ----------------------------------------------------------------
!  *		CreateTupleDescCopyConstr
   *
!  *		This function creates a new TupleDesc by copying from an existing
!  *		TupleDesc (with Constraints)
   * ----------------------------------------------------------------
   */
  TupleDesc
! CreateTupleDescCopyConstr(TupleDesc tupdesc)
  {
! 	TupleDesc	desc;
! 	TupleConstr *constr = tupdesc->constr;
! 	int			i,
! 				size;
  
! 	desc = (TupleDesc) palloc(sizeof(struct tupleDesc));
! 	desc->natts = tupdesc->natts;
! 	if (desc->natts > 0)
! 	{
! 		size = desc->natts * sizeof(Form_pg_attribute);
! 		desc->attrs = (Form_pg_attribute *) palloc(size);
! 		for (i = 0; i < desc->natts; i++)
  		{
! 			desc->attrs[i] = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE);
! 			memcpy(desc->attrs[i], tupdesc->attrs[i], ATTRIBUTE_TUPLE_SIZE);
  		}
  	}
  	else
! 		desc->attrs = NULL;
! 	if (constr)
  	{
! 		TupleConstr *cpy = (TupleConstr *) palloc(sizeof(TupleConstr));
  
! 		cpy->has_not_null = constr->has_not_null;
  
! 		if ((cpy->num_defval = constr->num_defval) > 0)
  		{
! 			cpy->defval = (AttrDefault *) palloc(cpy->num_defval * sizeof(AttrDefault));
! 			memcpy(cpy->defval, constr->defval, cpy->num_defval * sizeof(AttrDefault));
! 			for (i = cpy->num_defval - 1; i >= 0; i--)
  			{
  				if (constr->defval[i].adbin)
! 					cpy->defval[i].adbin = pstrdup(constr->defval[i].adbin);
  			}
  		}
  
! 		if ((cpy->num_check = constr->num_check) > 0)
  		{
! 			cpy->check = (ConstrCheck *) palloc(cpy->num_check * sizeof(ConstrCheck));
! 			memcpy(cpy->check, constr->check, cpy->num_check * sizeof(ConstrCheck));
! 			for (i = cpy->num_check - 1; i >= 0; i--)
  			{
  				if (constr->check[i].ccname)
! 					cpy->check[i].ccname = pstrdup(constr->check[i].ccname);
  				if (constr->check[i].ccbin)
! 					cpy->check[i].ccbin = pstrdup(constr->check[i].ccbin);
  			}
  		}
  
! 		desc->constr = cpy;
  	}
- 	else
- 		desc->constr = NULL;
  
! 	desc->tdhasoid = tupdesc->tdhasoid;
! 	return desc;
  }
  
  void
--- 91,190 ----
  	desc = (TupleDesc) palloc(sizeof(struct tupleDesc));
  	desc->attrs = attrs;
  	desc->natts = natts;
  	desc->tdhasoid = hasoid;
+ 	desc->mcxt = CurrentMemoryContext;
  
  	desc->constr = NULL;
! 	desc->attrs_by_pos = NULL;
  
  	return desc;
  }
  
  /* ----------------------------------------------------------------
!  *		CopyTupleDesc
   *
!  *		This function creates a new TupleDesc by copying from an
!  *		existing TupleDesc. Iff 'copyConstr' is true, the constraints
!  *		on the input TupleDesc are also copied.
   * ----------------------------------------------------------------
   */
  TupleDesc
! CopyTupleDesc(TupleDesc tupDesc, bool copyConstr)
  {
! 	TupleDesc	result;
! 	int			i;
  
! 	result = (TupleDesc) palloc(sizeof(*result));
! 	result->natts = tupDesc->natts;
! 	result->tdhasoid = tupDesc->tdhasoid;
! 	result->constr = NULL;
! 	result->attrs_by_pos = NULL;
! 	result->mcxt = CurrentMemoryContext;
! 
! 	if (result->natts > 0)
! 	{
! 		int size;
! 
! 		size = result->natts * sizeof(Form_pg_attribute);
! 		result->attrs = (Form_pg_attribute *) palloc(size);
! 		for (i = 0; i < result->natts; i++)
  		{
! 			result->attrs[i] = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE);
! 			memcpy(result->attrs[i], tupDesc->attrs[i], ATTRIBUTE_TUPLE_SIZE);
! 
! 			/*
! 			 * If we're not copying constraints, fix up the attributes
! 			 * to remove NOT NULL or DEFAULT indicators.
! 			 */
! 			if (!copyConstr)
! 			{
! 				result->attrs[i]->attnotnull = false;
! 				result->attrs[i]->atthasdef  = false;
! 			}
  		}
  	}
  	else
! 		result->attrs = NULL;
! 
! 	if (copyConstr && tupDesc->constr)
  	{
! 		TupleConstr *constr;
  
! 		constr = (TupleConstr *) palloc(sizeof(*constr));
! 		memcpy(constr, tupDesc->constr, sizeof(*constr));
! 		constr->defval = NULL;
! 		constr->check = NULL;
  
! 		if (constr->num_defval > 0)
  		{
! 			constr->defval = (AttrDefault *) palloc(constr->num_defval * sizeof(AttrDefault));
! 			memcpy(constr->defval, tupDesc->constr->defval,
! 				   constr->num_defval * sizeof(AttrDefault));
! 			for (i = constr->num_defval - 1; i >= 0; i--)
  			{
  				if (constr->defval[i].adbin)
! 					constr->defval[i].adbin = pstrdup(constr->defval[i].adbin);
  			}
  		}
  
! 		if (constr->num_check > 0)
  		{
! 			constr->check = (ConstrCheck *) palloc(constr->num_check * sizeof(ConstrCheck));
! 			memcpy(constr->check, tupDesc->constr->check,
! 				   constr->num_check * sizeof(ConstrCheck));
! 			for (i = constr->num_check - 1; i >= 0; i--)
  			{
  				if (constr->check[i].ccname)
! 					constr->check[i].ccname = pstrdup(constr->check[i].ccname);
  				if (constr->check[i].ccbin)
! 					constr->check[i].ccbin = pstrdup(constr->check[i].ccbin);
  			}
  		}
  
! 		result->constr = constr;
  	}
  
! 	return result;
  }
  
  void
***************
*** 210,215 ****
--- 196,203 ----
  		pfree(tupdesc->attrs[i]);
  	if (tupdesc->attrs)
  		pfree(tupdesc->attrs);
+ 	if (tupdesc->attrs_by_pos)
+ 		pfree(tupdesc->attrs_by_pos);
  	if (tupdesc->constr)
  	{
  		if (tupdesc->constr->num_defval > 0)
***************
*** 266,274 ****
  		 * disregard attrelid, attnum (it was used to place the row in the
  		 * attrs array) and everything derived from the column datatype.
  		 */
  		if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0)
  			return false;
! 		if (attr1->atttypid != attr2->atttypid)
  			return false;
  		if (attr1->attstattarget != attr2->attstattarget)
  			return false;
--- 254,264 ----
  		 * disregard attrelid, attnum (it was used to place the row in the
  		 * attrs array) and everything derived from the column datatype.
  		 */
+ 		if (attr1->atttypid != attr2->atttypid)
+ 			return false;
  		if (strcmp(NameStr(attr1->attname), NameStr(attr2->attname)) != 0)
  			return false;
! 		if (attr1->attlogpos != attr2->attlogpos)
  			return false;
  		if (attr1->attstattarget != attr2->attstattarget)
  			return false;
***************
*** 402,407 ****
--- 392,398 ----
  	att->atttypmod = typmod;
  
  	att->attnum = attributeNumber;
+ 	att->attlogpos = attributeNumber;
  	att->attndims = attdim;
  	att->attisset = attisset;
  
***************
*** 484,489 ****
--- 475,548 ----
  	ReleaseSysCache(tuple);
  }
  
+ static int
+ CompareAttributesByPosition(const void *ptr1, const void *ptr2)
+ {
+ 	Form_pg_attribute attr1 = *(Form_pg_attribute *) ptr1;
+ 	Form_pg_attribute attr2 = *(Form_pg_attribute *) ptr2;
+ 
+ 	if (attr1 == attr2)
+ 		return 0;
+ 	/* Put NULL pointers at the end of the list */
+ 	if (attr1 == NULL)
+ 		return -1;
+ 	if (attr2 == NULL)
+ 		return 1;
+ 	else
+ 		return attr1->attlogpos - attr2->attlogpos;
+ }
+ 
+ static void
+ InitializeAttributesByPosition(TupleDesc tupdesc)
+ {
+ 	size_t size;
+ 
+ 	Assert(MemoryContextIsValid(tupdesc->mcxt));
+ 	Assert(tupdesc->attrs_by_pos == NULL);
+ 	Assert(tupdesc->attrs != NULL);
+ 
+ 	size = tupdesc->natts * sizeof(Form_pg_attribute);
+ 	tupdesc->attrs_by_pos = MemoryContextAlloc(tupdesc->mcxt, size);
+ 	memcpy(tupdesc->attrs_by_pos, tupdesc->attrs, size);
+ 
+ 	qsort(tupdesc->attrs_by_pos, tupdesc->natts,
+ 		  sizeof(Form_pg_attribute), CompareAttributesByPosition);
+ }
+ 
+ /*
+  * GetAttrByLogicalPosition
+  *
+  * Given an attribute's logical position number, return a description
+  * of the attribute. An attribute's "logical position" specifies the
+  * order in which attributes in a relation should be displayed to the
+  * user if no other order is specified. The position argument is an
+  * offset from one: the first attribute in a tuple has a "logical
+  * position" of 1.
+  *
+  * Since the logical position number is rarely needed, we don't need
+  * to always construct this array: it is allocated and initialized
+  * "lazily", when the caller first asks for it. Therefore, the
+  * attrs_by_pos array should always point to NULL when the TupleDesc
+  * is initially created.
+  *
+  * XXX: We don't synchronize 'attrs' and 'attrs_by_pos' after the
+  * first call to GetAttrByLogicalPosition(). Is this necessary?
+  */
+ Form_pg_attribute
+ GetAttrByLogicalPosition(TupleDesc tupdesc, int logical_position)
+ {
+ 	/* Zero-attribute tupledesc's not allowed */
+ 	Assert(tupdesc->natts > 0);
+ 	Assert(logical_position >= 1);
+ 	Assert(logical_position <= tupdesc->natts);
+ 
+ 	if (tupdesc->attrs_by_pos == NULL)
+ 		InitializeAttributesByPosition(tupdesc);
+ 
+ 	Assert(PointerIsValid(tupdesc->attrs_by_pos));
+ 
+ 	return tupdesc->attrs_by_pos[logical_position - 1];
+ }
  
  /*
   * BuildDescForRelation
***************
*** 501,507 ****
  	List	   *p;
  	TupleDesc	desc;
  	AttrDefault *attrdef = NULL;
! 	TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr));
  	char	   *attname;
  	int32		atttypmod;
  	int			attdim;
--- 560,566 ----
  	List	   *p;
  	TupleDesc	desc;
  	AttrDefault *attrdef = NULL;
! 	TupleConstr *constr;
  	char	   *attname;
  	int32		atttypmod;
  	int			attdim;
***************
*** 513,518 ****
--- 572,578 ----
  	 */
  	natts = length(schema);
  	desc = CreateTemplateTupleDesc(natts, false);
+ 	constr = (TupleConstr *) palloc(sizeof(*constr));
  	constr->has_not_null = false;
  
  	attnum = 0;
***************
*** 607,613 ****
  	relname_list = stringToQualifiedNameList(relname, "RelationNameGetTupleDesc");
  	relvar = makeRangeVarFromNameList(relname_list);
  	rel = relation_openrv(relvar, AccessShareLock);
! 	tupdesc = CreateTupleDescCopy(RelationGetDescr(rel));
  	relation_close(rel, AccessShareLock);
  
  	return tupdesc;
--- 667,673 ----
  	relname_list = stringToQualifiedNameList(relname, "RelationNameGetTupleDesc");
  	relvar = makeRangeVarFromNameList(relname_list);
  	rel = relation_openrv(relvar, AccessShareLock);
! 	tupdesc = CopyTupleDesc(RelationGetDescr(rel), false);
  	relation_close(rel, AccessShareLock);
  
  	return tupdesc;
***************
*** 631,637 ****
  	TupleDesc	tupdesc = NULL;
  
  	/*
! 	 * Build a suitable tupledesc representing the output rows
  	 */
  	if (functyptype == 'c')
  	{
--- 691,697 ----
  	TupleDesc	tupdesc = NULL;
  
  	/*
! 	 * Build a suitable TupleDesc representing the output rows
  	 */
  	if (functyptype == 'c')
  	{
***************
*** 644,650 ****
  			elog(ERROR, "invalid typrelid for complex type %u", typeoid);
  
  		rel = relation_open(relid, AccessShareLock);
! 		tupdesc = CreateTupleDescCopy(RelationGetDescr(rel));
  		natts = tupdesc->natts;
  		relation_close(rel, AccessShareLock);
  		/* XXX should we hold the lock to ensure table doesn't change? */
--- 704,710 ----
  			elog(ERROR, "invalid typrelid for complex type %u", typeoid);
  
  		rel = relation_open(relid, AccessShareLock);
! 		tupdesc = CopyTupleDesc(RelationGetDescr(rel), false);
  		natts = tupdesc->natts;
  		relation_close(rel, AccessShareLock);
  		/* XXX should we hold the lock to ensure table doesn't change? */
Index: src/backend/bootstrap/bootstrap.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/bootstrap/bootstrap.c,v
retrieving revision 1.167
diff -c -r1.167 bootstrap.c
*** src/backend/bootstrap/bootstrap.c	19 Nov 2003 15:55:07 -0000	1.167
--- src/backend/bootstrap/bootstrap.c	25 Nov 2003 01:30:13 -0000
***************
*** 675,680 ****
--- 675,681 ----
  	namestrcpy(&attrtypes[attnum]->attname, name);
  	elog(DEBUG4, "column %s %s", NameStr(attrtypes[attnum]->attname), type);
  	attrtypes[attnum]->attnum = attnum + 1;		/* fillatt */
+ 	attrtypes[attnum]->attlogpos = attnum + 1;
  
  	typeoid = gettype(type);
  
Index: src/backend/catalog/heap.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/catalog/heap.c,v
retrieving revision 1.255
diff -c -r1.255 heap.c
*** src/backend/catalog/heap.c	12 Nov 2003 21:15:48 -0000	1.255
--- src/backend/catalog/heap.c	24 Nov 2003 17:08:27 -0000
***************
*** 97,134 ****
  
  static FormData_pg_attribute a1 = {
  	0, {"ctid"}, TIDOID, 0, sizeof(ItemPointerData),
! 	SelfItemPointerAttributeNumber, 0, -1, -1,
! 	false, 'p', false, 'i', true, false, false, true, 0
  };
  
  static FormData_pg_attribute a2 = {
  	0, {"oid"}, OIDOID, 0, sizeof(Oid),
! 	ObjectIdAttributeNumber, 0, -1, -1,
! 	true, 'p', false, 'i', true, false, false, true, 0
  };
  
  static FormData_pg_attribute a3 = {
  	0, {"xmin"}, XIDOID, 0, sizeof(TransactionId),
! 	MinTransactionIdAttributeNumber, 0, -1, -1,
! 	true, 'p', false, 'i', true, false, false, true, 0
  };
  
  static FormData_pg_attribute a4 = {
  	0, {"cmin"}, CIDOID, 0, sizeof(CommandId),
! 	MinCommandIdAttributeNumber, 0, -1, -1,
! 	true, 'p', false, 'i', true, false, false, true, 0
  };
  
  static FormData_pg_attribute a5 = {
  	0, {"xmax"}, XIDOID, 0, sizeof(TransactionId),
! 	MaxTransactionIdAttributeNumber, 0, -1, -1,
! 	true, 'p', false, 'i', true, false, false, true, 0
  };
  
  static FormData_pg_attribute a6 = {
  	0, {"cmax"}, CIDOID, 0, sizeof(CommandId),
! 	MaxCommandIdAttributeNumber, 0, -1, -1,
! 	true, 'p', false, 'i', true, false, false, true, 0
  };
  
  /*
--- 97,134 ----
  
  static FormData_pg_attribute a1 = {
  	0, {"ctid"}, TIDOID, 0, sizeof(ItemPointerData),
! 	SelfItemPointerAttributeNumber, SelfItemPointerAttributeNumber,
! 	0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0
  };
  
  static FormData_pg_attribute a2 = {
  	0, {"oid"}, OIDOID, 0, sizeof(Oid),
! 	ObjectIdAttributeNumber, ObjectIdAttributeNumber,
! 	0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0
  };
  
  static FormData_pg_attribute a3 = {
  	0, {"xmin"}, XIDOID, 0, sizeof(TransactionId),
! 	MinTransactionIdAttributeNumber, MinTransactionIdAttributeNumber,
! 	0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0
  };
  
  static FormData_pg_attribute a4 = {
  	0, {"cmin"}, CIDOID, 0, sizeof(CommandId),
! 	MinCommandIdAttributeNumber, MinCommandIdAttributeNumber,
! 	0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0
  };
  
  static FormData_pg_attribute a5 = {
  	0, {"xmax"}, XIDOID, 0, sizeof(TransactionId),
! 	MaxTransactionIdAttributeNumber, MaxTransactionIdAttributeNumber,
! 	0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0
  };
  
  static FormData_pg_attribute a6 = {
  	0, {"cmax"}, CIDOID, 0, sizeof(CommandId),
! 	MaxCommandIdAttributeNumber, MaxCommandIdAttributeNumber,
! 	0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0
  };
  
  /*
***************
*** 139,146 ****
   */
  static FormData_pg_attribute a7 = {
  	0, {"tableoid"}, OIDOID, 0, sizeof(Oid),
! 	TableOidAttributeNumber, 0, -1, -1,
! 	true, 'p', false, 'i', true, false, false, true, 0
  };
  
  static Form_pg_attribute SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};
--- 139,146 ----
   */
  static FormData_pg_attribute a7 = {
  	0, {"tableoid"}, OIDOID, 0, sizeof(Oid),
! 	TableOidAttributeNumber, TableOidAttributeNumber,
! 	0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0
  };
  
  static Form_pg_attribute SysAtt[] = {&a1, &a2, &a3, &a4, &a5, &a6, &a7};
Index: src/backend/commands/cluster.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/commands/cluster.c,v
retrieving revision 1.118
diff -c -r1.118 cluster.c
*** src/backend/commands/cluster.c	12 Nov 2003 21:15:49 -0000	1.118
--- src/backend/commands/cluster.c	24 Nov 2003 23:45:20 -0000
***************
*** 494,500 ****
  	 * Need to make a copy of the tuple descriptor, since
  	 * heap_create_with_catalog modifies it.
  	 */
! 	tupdesc = CreateTupleDescCopyConstr(OldHeapDesc);
  
  	OIDNewHeap = heap_create_with_catalog(NewName,
  										  RelationGetNamespace(OldHeap),
--- 494,500 ----
  	 * Need to make a copy of the tuple descriptor, since
  	 * heap_create_with_catalog modifies it.
  	 */
! 	tupdesc = CopyTupleDesc(OldHeapDesc, true);
  
  	OIDNewHeap = heap_create_with_catalog(NewName,
  										  RelationGetNamespace(OldHeap),
Index: src/backend/commands/copy.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/commands/copy.c,v
retrieving revision 1.213
diff -c -r1.213 copy.c
*** src/backend/commands/copy.c	6 Oct 2003 02:38:53 -0000	1.213
--- src/backend/commands/copy.c	25 Nov 2003 02:46:37 -0000
***************
*** 2147,2153 ****
   *
   * The input attnamelist is either the user-specified column list,
   * or NIL if there was none (in which case we want all the non-dropped
!  * columns).
   */
  static List *
  CopyGetAttnums(Relation rel, List *attnamelist)
--- 2147,2153 ----
   *
   * The input attnamelist is either the user-specified column list,
   * or NIL if there was none (in which case we want all the non-dropped
!  * columns, sorted in ascending attpos order).
   */
  static List *
  CopyGetAttnums(Relation rel, List *attnamelist)
***************
*** 2157,2172 ****
  	if (attnamelist == NIL)
  	{
  		/* Generate default column list */
! 		TupleDesc	tupDesc = RelationGetDescr(rel);
! 		Form_pg_attribute *attr = tupDesc->attrs;
! 		int			attr_count = tupDesc->natts;
! 		int			i;
  
! 		for (i = 0; i < attr_count; i++)
  		{
! 			if (attr[i]->attisdropped)
  				continue;
! 			attnums = lappendi(attnums, i + 1);
  		}
  	}
  	else
--- 2157,2172 ----
  	if (attnamelist == NIL)
  	{
  		/* Generate default column list */
! 		TupleDesc tupDesc = RelationGetDescr(rel);
! 		int i;
  
! 		for (i = 1; i <= tupDesc->natts; i++)
  		{
! 			Form_pg_attribute attr = GetAttrByLogicalPosition(tupDesc, i);
! 
! 			if (attr->attisdropped)
  				continue;
! 			attnums = lappendi(attnums, attr->attnum);
  		}
  	}
  	else
Index: src/backend/commands/portalcmds.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/commands/portalcmds.c,v
retrieving revision 1.24
diff -c -r1.24 portalcmds.c
*** src/backend/commands/portalcmds.c	24 Aug 2003 21:02:43 -0000	1.24
--- src/backend/commands/portalcmds.c	24 Nov 2003 23:45:20 -0000
***************
*** 295,301 ****
  	 */
  	oldcxt = MemoryContextSwitchTo(portal->holdContext);
  
! 	portal->tupDesc = CreateTupleDescCopy(portal->tupDesc);
  
  	MemoryContextSwitchTo(oldcxt);
  
--- 295,301 ----
  	 */
  	oldcxt = MemoryContextSwitchTo(portal->holdContext);
  
! 	portal->tupDesc = CopyTupleDesc(portal->tupDesc, false);
  
  	MemoryContextSwitchTo(oldcxt);
  
Index: src/backend/commands/tablecmds.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/commands/tablecmds.c,v
retrieving revision 1.93
diff -c -r1.93 tablecmds.c
*** src/backend/commands/tablecmds.c	12 Nov 2003 21:15:51 -0000	1.93
--- src/backend/commands/tablecmds.c	25 Nov 2003 19:28:27 -0000
***************
*** 1786,1791 ****
--- 1786,1792 ----
  	attribute->attcacheoff = -1;
  	attribute->atttypmod = colDef->typename->typmod;
  	attribute->attnum = i;
+ 	attribute->attlogpos = i;
  	attribute->attbyval = tform->typbyval;
  	attribute->attndims = attndims;
  	attribute->attisset = (bool) (tform->typtype == 'c');
Index: src/backend/executor/execMain.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/executor/execMain.c,v
retrieving revision 1.221
diff -c -r1.221 execMain.c
*** src/backend/executor/execMain.c	6 Nov 2003 22:08:14 -0000	1.221
--- src/backend/executor/execMain.c	24 Nov 2003 23:45:20 -0000
***************
*** 804,810 ****
  		/*
  		 * have to copy tupType to get rid of constraints
  		 */
! 		tupdesc = CreateTupleDescCopy(tupType);
  
  		intoRelationId = heap_create_with_catalog(intoName,
  												  namespaceId,
--- 804,810 ----
  		/*
  		 * have to copy tupType to get rid of constraints
  		 */
! 		tupdesc = CopyTupleDesc(tupType, false);
  
  		intoRelationId = heap_create_with_catalog(intoName,
  												  namespaceId,
Index: src/backend/executor/execQual.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/executor/execQual.c,v
retrieving revision 1.150
diff -c -r1.150 execQual.c
*** src/backend/executor/execQual.c	13 Oct 2003 22:47:15 -0000	1.150
--- src/backend/executor/execQual.c	24 Nov 2003 23:45:20 -0000
***************
*** 1074,1080 ****
  						ereport(ERROR,
  								(errcode(ERRCODE_DATATYPE_MISMATCH),
  								 errmsg("function returning row did not return a valid tuple slot")));
! 					tupdesc = CreateTupleDescCopy(slot->ttc_tupleDescriptor);
  					returnsTuple = true;
  				}
  				else
--- 1074,1080 ----
  						ereport(ERROR,
  								(errcode(ERRCODE_DATATYPE_MISMATCH),
  								 errmsg("function returning row did not return a valid tuple slot")));
! 					tupdesc = CopyTupleDesc(slot->ttc_tupleDescriptor, false);
  					returnsTuple = true;
  				}
  				else
Index: src/backend/executor/functions.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/executor/functions.c,v
retrieving revision 1.75
diff -c -r1.75 functions.c
*** src/backend/executor/functions.c	25 Sep 2003 18:58:35 -0000	1.75
--- src/backend/executor/functions.c	24 Nov 2003 23:45:20 -0000
***************
*** 389,395 ****
  	 */
  	if (funcSlot->ttc_tupleDescriptor == NULL)
  	{
! 		resultTd = CreateTupleDescCopy(resultSlot->ttc_tupleDescriptor);
  		ExecSetSlotDescriptor(funcSlot, resultTd, true);
  		ExecSetSlotDescriptorIsNew(funcSlot, true);
  	}
--- 389,395 ----
  	 */
  	if (funcSlot->ttc_tupleDescriptor == NULL)
  	{
! 		resultTd = CopyTupleDesc(resultSlot->ttc_tupleDescriptor, false);
  		ExecSetSlotDescriptor(funcSlot, resultTd, true);
  		ExecSetSlotDescriptorIsNew(funcSlot, true);
  	}
Index: src/backend/executor/nodeFunctionscan.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/executor/nodeFunctionscan.c,v
retrieving revision 1.22
diff -c -r1.22 nodeFunctionscan.c
*** src/backend/executor/nodeFunctionscan.c	25 Sep 2003 23:02:12 -0000	1.22
--- src/backend/executor/nodeFunctionscan.c	24 Nov 2003 23:45:20 -0000
***************
*** 205,211 ****
  			elog(ERROR, "invalid typrelid for complex type %u",
  				 funcrettype);
  		rel = relation_open(funcrelid, AccessShareLock);
! 		tupdesc = CreateTupleDescCopy(RelationGetDescr(rel));
  		relation_close(rel, AccessShareLock);
  	}
  	else if (functyptype == 'b' || functyptype == 'd')
--- 205,211 ----
  			elog(ERROR, "invalid typrelid for complex type %u",
  				 funcrettype);
  		rel = relation_open(funcrelid, AccessShareLock);
! 		tupdesc = CopyTupleDesc(RelationGetDescr(rel), false);
  		relation_close(rel, AccessShareLock);
  	}
  	else if (functyptype == 'b' || functyptype == 'd')
Index: src/backend/executor/spi.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/executor/spi.c,v
retrieving revision 1.107
diff -c -r1.107 spi.c
*** src/backend/executor/spi.c	1 Oct 2003 21:30:52 -0000	1.107
--- src/backend/executor/spi.c	24 Nov 2003 23:45:20 -0000
***************
*** 386,392 ****
  		oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt);
  	}
  
! 	ctupdesc = CreateTupleDescCopy(tupdesc);
  
  	if (oldcxt)
  		MemoryContextSwitchTo(oldcxt);
--- 386,392 ----
  		oldcxt = MemoryContextSwitchTo(_SPI_current->savedcxt);
  	}
  
! 	ctupdesc = CopyTupleDesc(tupdesc, false);
  
  	if (oldcxt)
  		MemoryContextSwitchTo(oldcxt);
***************
*** 416,422 ****
  	}
  
  	ctuple = heap_copytuple(tuple);
! 	ctupdesc = CreateTupleDescCopy(tupdesc);
  
  	cslot = MakeTupleTableSlot();
  	ExecSetSlotDescriptor(cslot, ctupdesc, true);
--- 416,422 ----
  	}
  
  	ctuple = heap_copytuple(tuple);
! 	ctupdesc = CopyTupleDesc(tupdesc, false);
  
  	cslot = MakeTupleTableSlot();
  	ExecSetSlotDescriptor(cslot, ctupdesc, true);
***************
*** 950,956 ****
  	tuptable->tuptabcxt = tuptabcxt;
  	tuptable->alloced = tuptable->free = 128;
  	tuptable->vals = (HeapTuple *) palloc(tuptable->alloced * sizeof(HeapTuple));
! 	tuptable->tupdesc = CreateTupleDescCopy(typeinfo);
  
  	MemoryContextSwitchTo(oldcxt);
  }
--- 950,956 ----
  	tuptable->tuptabcxt = tuptabcxt;
  	tuptable->alloced = tuptable->free = 128;
  	tuptable->vals = (HeapTuple *) palloc(tuptable->alloced * sizeof(HeapTuple));
! 	tuptable->tupdesc = CopyTupleDesc(typeinfo, false);
  
  	MemoryContextSwitchTo(oldcxt);
  }
Index: src/backend/parser/parse_relation.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/parser/parse_relation.c,v
retrieving revision 1.90
diff -c -r1.90 parse_relation.c
*** src/backend/parser/parse_relation.c	25 Sep 2003 06:58:01 -0000	1.90
--- src/backend/parser/parse_relation.c	25 Nov 2003 20:06:25 -0000
***************
*** 1190,1196 ****
  	return rte;
  }
  
! /* expandRTE()
   *
   * Given a rangetable entry, create lists of its column names (aliases if
   * provided, else real names) and Vars for each column.  Only user columns
--- 1190,1197 ----
  	return rte;
  }
  
! /*
!  * expandRTE()
   *
   * Given a rangetable entry, create lists of its column names (aliases if
   * provided, else real names) and Vars for each column.  Only user columns
***************
*** 1220,1237 ****
  	{
  		case RTE_RELATION:
  			{
! 				/* Ordinary relation RTE */
  				Relation	rel;
  				int			maxattrs;
  				int			numaliases;
  
  				rel = heap_open(rte->relid, AccessShareLock);
  				maxattrs = RelationGetNumberOfAttributes(rel);
  				numaliases = length(rte->eref->colnames);
  
! 				for (varattno = 0; varattno < maxattrs; varattno++)
  				{
! 					Form_pg_attribute attr = rel->rd_att->attrs[varattno];
  
  					if (attr->attisdropped)
  						continue;
--- 1221,1248 ----
  	{
  		case RTE_RELATION:
  			{
! 				/*
! 				 * Ordinary relation RTE. When producing the column
! 				 * list for a relation, we need to ensure that it is
! 				 * ordered by the "logical positions" (the attlogpos
! 				 * fields) of the attributes in the relation.
! 				 */
  				Relation	rel;
+ 				TupleDesc	tupDesc;
  				int			maxattrs;
  				int			numaliases;
+ 				int			position;
  
  				rel = heap_open(rte->relid, AccessShareLock);
+ 				tupDesc = rel->rd_att;
  				maxattrs = RelationGetNumberOfAttributes(rel);
  				numaliases = length(rte->eref->colnames);
  
! 				for (position = 0; position < maxattrs; position++)
  				{
! 					Form_pg_attribute attr;
! 
! 					attr = GetAttrByLogicalPosition(tupDesc, position + 1);
  
  					if (attr->attisdropped)
  						continue;
***************
*** 1240,1247 ****
  					{
  						char	   *label;
  
! 						if (varattno < numaliases)
! 							label = strVal(nth(varattno, rte->eref->colnames));
  						else
  							label = NameStr(attr->attname);
  						*colnames = lappend(*colnames, makeString(pstrdup(label)));
--- 1251,1258 ----
  					{
  						char	   *label;
  
! 						if (position < numaliases)
! 							label = strVal(nth(position, rte->eref->colnames));
  						else
  							label = NameStr(attr->attname);
  						*colnames = lappend(*colnames, makeString(pstrdup(label)));
Index: src/backend/parser/parse_target.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/parser/parse_target.c,v
retrieving revision 1.113
diff -c -r1.113 parse_target.c
*** src/backend/parser/parse_target.c	25 Sep 2003 06:58:01 -0000	1.113
--- src/backend/parser/parse_target.c	25 Nov 2003 03:57:31 -0000
***************
*** 443,449 ****
  	resnode->resname = colname;
  }
  
- 
  /*
   * checkInsertTargets -
   *	  generate a list of INSERT column targets if not supplied, or
--- 443,448 ----
***************
*** 458,482 ****
  	if (cols == NIL)
  	{
  		/*
! 		 * Generate default column list for INSERT.
  		 */
! 		Form_pg_attribute *attr = pstate->p_target_relation->rd_att->attrs;
! 		int			numcol = pstate->p_target_relation->rd_rel->relnatts;
! 		int			i;
  
! 		for (i = 0; i < numcol; i++)
  		{
! 			ResTarget  *col;
  
! 			if (attr[i]->attisdropped)
  				continue;
  
  			col = makeNode(ResTarget);
! 			col->name = pstrdup(NameStr(attr[i]->attname));
  			col->indirection = NIL;
  			col->val = NULL;
  			cols = lappend(cols, col);
! 			*attrnos = lappendi(*attrnos, i + 1);
  		}
  	}
  	else
--- 457,490 ----
  	if (cols == NIL)
  	{
  		/*
! 		 * Generate default column list for INSERT. If no column list
! 		 * has been supplied, we generate a column list containing all
! 		 * the non-dropped user columns in the table, sorted in
! 		 * ascending 'attlogpos' order.
  		 */
! 		TupleDesc		tupDesc;
! 		int				i;
! 		int				num_atts;
! 
! 		tupDesc = pstate->p_target_relation->rd_att;
! 		num_atts = pstate->p_target_relation->rd_rel->relnatts;
  
! 		for (i = 1; i <= num_atts; i++)
  		{
! 			Form_pg_attribute	 attr;
! 			ResTarget			*col;
! 
! 			attr = GetAttrByLogicalPosition(tupDesc, i);
  
! 			if (attr->attisdropped)
  				continue;
  
  			col = makeNode(ResTarget);
! 			col->name = pstrdup(NameStr(attr->attname));
  			col->indirection = NIL;
  			col->val = NULL;
  			cols = lappend(cols, col);
! 			*attrnos = lappendi(*attrnos, attr->attnum);
  		}
  	}
  	else
Index: src/backend/rewrite/rewriteDefine.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/rewrite/rewriteDefine.c,v
retrieving revision 1.90
diff -c -r1.90 rewriteDefine.c
*** src/backend/rewrite/rewriteDefine.c	29 Sep 2003 00:05:25 -0000	1.90
--- src/backend/rewrite/rewriteDefine.c	25 Nov 2003 19:16:20 -0000
***************
*** 394,399 ****
--- 394,408 ----
  		 * If so, check that the relation is empty because the storage for
  		 * the relation is going to be deleted.  Also insist that the rel
  		 * not have any triggers, indexes, or child tables.
+ 		 *
+ 		 * XXX: This code path is present because some very old (6.X)
+ 		 * versions of pg_dump may still dump views as a CREATE TABLE
+ 		 * followed by a special CREATE RULE. This is a huge kludge,
+ 		 * of course, but worth keeping for the sake of backward
+ 		 * compatibility. Note also that the code below is broken in
+ 		 * at least two ways: it does not remove the TOAST tables of
+ 		 * the relation it is replacing, and it improperly trusts
+ 		 * pg_class.relhassubclass (see pg_class.h)
  		 */
  		if (event_relation->rd_rel->relkind != RELKIND_VIEW)
  		{
***************
*** 473,479 ****
  	}
  
  	/*
! 	 * IF the relation is becoming a view, delete the storage files
  	 * associated with it.	NB: we had better have AccessExclusiveLock to
  	 * do this ...
  	 *
--- 482,488 ----
  	}
  
  	/*
! 	 * If the relation is becoming a view, delete the storage files
  	 * associated with it.	NB: we had better have AccessExclusiveLock to
  	 * do this ...
  	 *
Index: src/backend/tcop/utility.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/tcop/utility.c,v
retrieving revision 1.208
diff -c -r1.208 utility.c
*** src/backend/tcop/utility.c	2 Oct 2003 06:34:04 -0000	1.208
--- src/backend/tcop/utility.c	24 Nov 2003 23:45:20 -0000
***************
*** 1119,1125 ****
  				portal = GetPortalByName(stmt->portalname);
  				if (!PortalIsValid(portal))
  					return NULL;	/* not our business to raise error */
! 				return CreateTupleDescCopy(portal->tupDesc);
  			}
  
  		case T_ExecuteStmt:
--- 1119,1125 ----
  				portal = GetPortalByName(stmt->portalname);
  				if (!PortalIsValid(portal))
  					return NULL;	/* not our business to raise error */
! 				return CopyTupleDesc(portal->tupDesc, false);
  			}
  
  		case T_ExecuteStmt:
Index: src/backend/utils/cache/catcache.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/utils/cache/catcache.c,v
retrieving revision 1.110
diff -c -r1.110 catcache.c
*** src/backend/utils/cache/catcache.c	12 Nov 2003 21:15:55 -0000	1.110
--- src/backend/utils/cache/catcache.c	24 Nov 2003 23:45:20 -0000
***************
*** 913,919 ****
  	/*
  	 * copy the relcache's tuple descriptor to permanent cache storage
  	 */
! 	tupdesc = CreateTupleDescCopyConstr(RelationGetDescr(relation));
  
  	/*
  	 * get the relation's OID and relisshared flag, too
--- 913,919 ----
  	/*
  	 * copy the relcache's tuple descriptor to permanent cache storage
  	 */
! 	tupdesc = CopyTupleDesc(RelationGetDescr(relation), true);
  
  	/*
  	 * get the relation's OID and relisshared flag, too
Index: src/backend/utils/cache/relcache.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/backend/utils/cache/relcache.c,v
retrieving revision 1.192
diff -c -r1.192 relcache.c
*** src/backend/utils/cache/relcache.c	12 Nov 2003 21:15:56 -0000	1.192
--- src/backend/utils/cache/relcache.c	24 Nov 2003 23:45:20 -0000
***************
*** 2132,2138 ****
  	 * multiple system catalogs.  We can copy attnotnull constraints here,
  	 * however.
  	 */
! 	rel->rd_att = CreateTupleDescCopy(tupDesc);
  	has_not_null = false;
  	for (i = 0; i < natts; i++)
  	{
--- 2132,2138 ----
  	 * multiple system catalogs.  We can copy attnotnull constraints here,
  	 * however.
  	 */
! 	rel->rd_att = CopyTupleDesc(tupDesc, false);
  	has_not_null = false;
  	for (i = 0; i < natts; i++)
  	{
Index: src/bin/psql/describe.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/bin/psql/describe.c,v
retrieving revision 1.87
diff -c -r1.87 describe.c
*** src/bin/psql/describe.c	26 Oct 2003 02:53:45 -0000	1.87
--- src/bin/psql/describe.c	25 Nov 2003 01:32:13 -0000
***************
*** 734,740 ****
  	appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attnum > 0 AND NOT a.attisdropped", oid);
  	if (tableinfo.relkind == 'i')
  		appendPQExpBuffer(&buf, " AND a.attrelid = i.indexrelid");
! 	appendPQExpBuffer(&buf, "\nORDER BY a.attnum");
  
  	res = PSQLexec(buf.data, false);
  	if (!res)
--- 734,740 ----
  	appendPQExpBuffer(&buf, "\nWHERE a.attrelid = '%s' AND a.attnum > 0 AND NOT a.attisdropped", oid);
  	if (tableinfo.relkind == 'i')
  		appendPQExpBuffer(&buf, " AND a.attrelid = i.indexrelid");
! 	appendPQExpBuffer(&buf, "\nORDER BY a.attlogpos");
  
  	res = PSQLexec(buf.data, false);
  	if (!res)
Index: src/include/access/tupdesc.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/access/tupdesc.h,v
retrieving revision 1.41
diff -c -r1.41 tupdesc.h
*** src/include/access/tupdesc.h	11 Aug 2003 23:04:50 -0000	1.41
--- src/include/access/tupdesc.h	25 Nov 2003 02:49:11 -0000
***************
*** 48,55 ****
  typedef struct tupleDesc
  {
  	int			natts;			/* Number of attributes in the tuple */
  	Form_pg_attribute *attrs;
! 	/* attrs[N] is a pointer to the description of Attribute Number N+1.  */
  	TupleConstr *constr;
  	bool		tdhasoid;		/* Tuple has oid attribute in its header */
  }	*TupleDesc;
--- 48,63 ----
  typedef struct tupleDesc
  {
  	int			natts;			/* Number of attributes in the tuple */
+ 	/* attrs[N] is a pointer to the description of Attribute Number N+1. */
  	Form_pg_attribute *attrs;
! 	/*
! 	 * attrs_by_pos[K] is a pointer to the description of an attribute
! 	 * with "attlogpos == K", if one exists. The content of this array
! 	 * is considered private: callers should not access it directly,
! 	 * and only use GetAttrByLogicalPosition()
! 	 */
! 	Form_pg_attribute *attrs_by_pos;
! 	MemoryContext mcxt;
  	TupleConstr *constr;
  	bool		tdhasoid;		/* Tuple has oid attribute in its header */
  }	*TupleDesc;
***************
*** 60,73 ****
  extern TupleDesc CreateTupleDesc(int natts, bool hasoid,
  				Form_pg_attribute *attrs);
  
! extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc);
! 
! extern TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc);
  
  extern void FreeTupleDesc(TupleDesc tupdesc);
  
  extern bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2);
  
  extern void TupleDescInitEntry(TupleDesc desc,
  				   AttrNumber attributeNumber,
  				   const char *attributeName,
--- 68,82 ----
  extern TupleDesc CreateTupleDesc(int natts, bool hasoid,
  				Form_pg_attribute *attrs);
  
! extern TupleDesc CopyTupleDesc(TupleDesc tupdesc, bool copyConstr);
  
  extern void FreeTupleDesc(TupleDesc tupdesc);
  
  extern bool equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2);
  
+ extern Form_pg_attribute GetAttrByLogicalPosition(TupleDesc tupdesc,
+ 												  int logical_position);
+ 
  extern void TupleDescInitEntry(TupleDesc desc,
  				   AttrNumber attributeNumber,
  				   const char *attributeName,
Index: src/include/catalog/catversion.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/catalog/catversion.h,v
retrieving revision 1.211
diff -c -r1.211 catversion.h
*** src/include/catalog/catversion.h	12 Nov 2003 21:15:57 -0000	1.211
--- src/include/catalog/catversion.h	25 Nov 2003 02:37:23 -0000
***************
*** 53,58 ****
   */
  
  /*							yyyymmddN */
! #define CATALOG_VERSION_NO	200311101
  
  #endif
--- 53,58 ----
   */
  
  /*							yyyymmddN */
! #define CATALOG_VERSION_NO	200311241
  
  #endif
Index: src/include/catalog/pg_attribute.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/catalog/pg_attribute.h,v
retrieving revision 1.105
diff -c -r1.105 pg_attribute.h
*** src/include/catalog/pg_attribute.h	16 Oct 2003 22:52:22 -0000	1.105
--- src/include/catalog/pg_attribute.h	25 Nov 2003 01:29:50 -0000
***************
*** 11,24 ****
   * $Id: pg_attribute.h,v 1.105 2003/10/16 22:52:22 tgl Exp $
   *
   * NOTES
!  *	  the genbki.sh script reads this file and generates .bki
   *	  information from the DATA() statements.
   *
!  *	  utils/cache/relcache.c requires hard-coded tuple descriptors
!  *	  for some of the system catalogs.	So if the schema for any of
!  *	  these changes, be sure and change the appropriate Schema_xxx
!  *	  macros!  -cim 2/5/91
!  *
   *-------------------------------------------------------------------------
   */
  #ifndef PG_ATTRIBUTE_H
--- 11,22 ----
   * $Id: pg_attribute.h,v 1.105 2003/10/16 22:52:22 tgl Exp $
   *
   * NOTES
!  *	  The genbki.sh script reads this file and generates .bki
   *	  information from the DATA() statements.
   *
!  *	  utils/cache/relcache.c requires hard-coded tuple descriptors for
!  *	  some of the system catalogs. So if the schema for any of these
!  *	  changes, be sure to change the approach Schema_pg_ constants!
   *-------------------------------------------------------------------------
   */
  #ifndef PG_ATTRIBUTE_H
***************
*** 46,55 ****
  	NameData	attname;		/* name of attribute */
  
  	/*
! 	 * atttypid is the OID of the instance in Catalog Class pg_type that
! 	 * defines the data type of this attribute (e.g. int4).  Information
! 	 * in that instance is redundant with the attlen, attbyval, and
! 	 * attalign attributes of this instance, so they had better match or
  	 * Postgres will fail.
  	 */
  	Oid			atttypid;
--- 44,53 ----
  	NameData	attname;		/* name of attribute */
  
  	/*
! 	 * atttypid is the OID of the row in pg_type that defines the data
! 	 * type of this attribute (e.g. int4).  Information in that
! 	 * instance is redundant with the attlen, attbyval, and attalign
! 	 * attributes of this instance, so they had better match or
  	 * Postgres will fail.
  	 */
  	Oid			atttypid;
***************
*** 85,90 ****
--- 83,98 ----
  	int2		attnum;
  
  	/*
+ 	 * attlogpos is the "logical position" of this attribute within
+ 	 * the relation that it belongs to. This is used so that we can
+ 	 * separate the on-disk format of a relation from the order in
+ 	 * which the relation's columns are presented to the user (we
+ 	 * store columns in attnum order, but present them in attlogpos
+ 	 * order).
+ 	 */
+ 	int2		attlogpos;
+ 
+ 	/*
  	 * attndims is the declared number of dimensions, if an array type,
  	 * otherwise zero.
  	 */
***************
*** 174,216 ****
   * ----------------
   */
  
! #define Natts_pg_attribute				18
  #define Anum_pg_attribute_attrelid		1
  #define Anum_pg_attribute_attname		2
  #define Anum_pg_attribute_atttypid		3
  #define Anum_pg_attribute_attstattarget 4
  #define Anum_pg_attribute_attlen		5
  #define Anum_pg_attribute_attnum		6
! #define Anum_pg_attribute_attndims		7
! #define Anum_pg_attribute_attcacheoff	8
! #define Anum_pg_attribute_atttypmod		9
! #define Anum_pg_attribute_attbyval		10
! #define Anum_pg_attribute_attstorage	11
! #define Anum_pg_attribute_attisset		12
! #define Anum_pg_attribute_attalign		13
! #define Anum_pg_attribute_attnotnull	14
! #define Anum_pg_attribute_atthasdef		15
! #define Anum_pg_attribute_attisdropped	16
! #define Anum_pg_attribute_attislocal	17
! #define Anum_pg_attribute_attinhcount	18
  
  
- 
- /* ----------------
-  *		SCHEMA_ macros for declaring hardcoded tuple descriptors.
-  *		these are used in utils/cache/relcache.c
-  * ----------------
- #define SCHEMA_NAME(x) CppConcat(Name_,x)
- #define SCHEMA_DESC(x) CppConcat(Desc_,x)
- #define SCHEMA_NATTS(x) CppConcat(Natts_,x)
- #define SCHEMA_DEF(x) \
- 	FormData_pg_attribute \
- 	SCHEMA_DESC(x) [ SCHEMA_NATTS(x) ] = \
- 	{ \
- 		CppConcat(Schema_,x) \
- 	}
-  */
- 
  /* ----------------
   *		initial contents of pg_attribute
   *
--- 182,209 ----
   * ----------------
   */
  
! #define Natts_pg_attribute				19
  #define Anum_pg_attribute_attrelid		1
  #define Anum_pg_attribute_attname		2
  #define Anum_pg_attribute_atttypid		3
  #define Anum_pg_attribute_attstattarget 4
  #define Anum_pg_attribute_attlen		5
  #define Anum_pg_attribute_attnum		6
! #define Anum_pg_attribute_attlogpos		7
! #define Anum_pg_attribute_attndims		8
! #define Anum_pg_attribute_attcacheoff	9
! #define Anum_pg_attribute_atttypmod		10
! #define Anum_pg_attribute_attbyval		11
! #define Anum_pg_attribute_attstorage	12
! #define Anum_pg_attribute_attisset		13
! #define Anum_pg_attribute_attalign		14
! #define Anum_pg_attribute_attnotnull	15
! #define Anum_pg_attribute_atthasdef		16
! #define Anum_pg_attribute_attisdropped	17
! #define Anum_pg_attribute_attislocal	18
! #define Anum_pg_attribute_attinhcount	19
  
  
  /* ----------------
   *		initial contents of pg_attribute
   *
***************
*** 226,499 ****
   * ----------------
   */
  #define Schema_pg_type \
! { 1247, {"typname"},	   19, -1, NAMEDATALEN, 1, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typnamespace"},  26, -1,	4,	2, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typowner"},	   23, -1,	4,	3, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typlen"},		   21, -1,	2,	4, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1247, {"typbyval"},	   16, -1,	1,	5, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typtype"},	   18, -1,	1,	6, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typisdefined"},  16, -1,	1,	7, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typdelim"},	   18, -1,	1,	8, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typrelid"},	   26, -1,	4,	9, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typelem"},	   26, -1,	4, 10, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typinput"},	   24, -1,	4, 11, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typoutput"},	   24, -1,	4, 12, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typreceive"},    24, -1,	4, 13, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typsend"},	   24, -1,	4, 14, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typalign"},	   18, -1,	1, 15, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typstorage"},    18, -1,	1, 16, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typnotnull"},    16, -1,	1, 17, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typbasetype"},   26, -1,	4, 18, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typtypmod"},	   23, -1,	4, 19, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typndims"},	   23, -1,	4, 20, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typdefaultbin"}, 25, -1, -1, 21, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }, \
! { 1247, {"typdefault"},    25, -1, -1, 22, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }
! 
! 
! DATA(insert ( 1247 typname			19 -1 NAMEDATALEN	1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1247 typnamespace		26 -1 4   2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typowner			23 -1 4   3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typlen			21 -1 2   4 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1247 typbyval			16 -1 1   5 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typtype			18 -1 1   6 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typisdefined		16 -1 1   7 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typdelim			18 -1 1   8 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typrelid			26 -1 4   9 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typelem			26 -1 4  10 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typinput			24 -1 4  11 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typoutput		24 -1 4  12 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typreceive		24 -1 4  13 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typsend			24 -1 4  14 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typalign			18 -1 1  15 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typstorage		18 -1 1  16 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typnotnull		16 -1 1  17 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typbasetype		26 -1 4  18 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typtypmod		23 -1 4  19 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typndims			23 -1 4  20 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typdefaultbin	25 -1 -1 21 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1247 typdefault		25 -1 -1 22 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1247 ctid				27 0  6  -1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1247 oid				26 0  4  -2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 xmin				28 0  4  -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 cmin				29 0  4  -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 xmax				28 0  4  -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 cmax				29 0  4  -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 tableoid			26 0  4  -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_database
   * ----------------
   */
! DATA(insert ( 1262 datname			19 -1 NAMEDATALEN   1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1262 datdba			23 -1 4   2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 encoding			23 -1 4   3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 datistemplate	16 -1 1   4 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1262 datallowconn		16 -1 1   5 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1262 datlastsysoid	26 -1 4   6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 datvacuumxid		28 -1 4   7 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 datfrozenxid		28 -1 4   8 0 -1 -1 t p f i t f f t 0));
  /* do not mark datpath as toastable; GetRawDatabaseInfo won't cope */
! DATA(insert ( 1262 datpath			25 -1 -1  9 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1262 datconfig	  1009 -1 -1 10 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1262 datacl		  1034 -1 -1 11 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1262 ctid				27 0  6  -1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1262 oid				26 0  4  -2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 xmin				28 0  4  -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 cmin				29 0  4  -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 xmax				28 0  4  -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 cmax				29 0  4  -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 tableoid			26 0  4  -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_proc
   * ----------------
   */
  #define Schema_pg_proc \
! { 1255, {"proname"},			19, -1, NAMEDATALEN,  1, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"pronamespace"},		26, -1, 4,	2, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"proowner"},			23, -1,	4,	3, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"prolang"},			26, -1,	4,	4, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"proisagg"},			16, -1, 1,	5, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1255, {"prosecdef"},			16, -1,	1,	6, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1255, {"proisstrict"},		16, -1,	1,	7, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1255, {"proretset"},			16, -1,	1,	8, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1255, {"provolatile"},		18, -1,	1,	9, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1255, {"pronargs"},			21, -1,	2, 10, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1255, {"prorettype"},			26, -1,	4, 11, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"proargtypes"},		30, -1, INDEX_MAX_KEYS*4, 12, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"prosrc"},				25, -1, -1, 13, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }, \
! { 1255, {"probin"},				17, -1, -1, 14, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }, \
! { 1255, {"proacl"},			  1034, -1, -1, 15, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }
! 
! DATA(insert ( 1255 proname			19 -1 NAMEDATALEN	1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1255 pronamespace		26 -1 4   2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 proowner			23 -1 4   3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 prolang			26 -1 4   4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 proisagg			16 -1 1   5 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1255 prosecdef		16 -1 1   6 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1255 proisstrict		16 -1 1   7 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1255 proretset		16 -1 1   8 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1255 provolatile		18 -1 1   9 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1255 pronargs			21 -1 2  10 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1255 prorettype		26 -1 4  11 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 proargtypes		30 -1 INDEX_MAX_KEYS*4 12 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1255 prosrc			25 -1 -1 13 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1255 probin			17 -1 -1 14 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1255 proacl		  1034 -1 -1 15 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1255 ctid				27 0  6  -1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1255 oid				26 0  4  -2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 xmin				28 0  4  -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 cmin				29 0  4  -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 xmax				28 0  4  -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 cmax				29 0  4  -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 tableoid			26 0  4  -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_shadow
   * ----------------
   */
! DATA(insert ( 1260 usename			19	-1 NAMEDATALEN	1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1260 usesysid			23	-1	4	2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1260 usecreatedb		16	-1	1	3 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1260 usesuper			16	-1	1	4 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1260 usecatupd		16	-1	1	5 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1260 passwd			25	-1 -1	6 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1260 valuntil		   702	-1	4	7 0 -1 -1 t p f i f f f t 0));
! DATA(insert ( 1260 useconfig	  1009	-1 -1	8 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1260 ctid				27 0  6  -1 0 -1 -1 f p f i t f f t 0));
  /* no OIDs in pg_shadow */
! DATA(insert ( 1260 xmin				28 0  4  -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1260 cmin				29 0  4  -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1260 xmax				28 0  4  -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1260 cmax				29 0  4  -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1260 tableoid			26 0  4  -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_group
   * ----------------
   */
! DATA(insert ( 1261 groname			19 -1 NAMEDATALEN  1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1261 grosysid			23 -1  4   2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1261 grolist		  1007 -1 -1   3 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1261 ctid				27 0  6  -1 0 -1 -1 f p f i t f f t 0));
  /* no OIDs in pg_group */
! DATA(insert ( 1261 xmin				28 0  4  -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1261 cmin				29 0  4  -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1261 xmax				28 0  4  -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1261 cmax				29 0  4  -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1261 tableoid			26 0  4  -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_attribute
   * ----------------
   */
  #define Schema_pg_attribute \
! { 1249, {"attrelid"},	  26, -1,	4,	1, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"attname"},	  19, -1, NAMEDATALEN,	2, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"atttypid"},	  26, -1,	4,	3, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"attstattarget"}, 23, -1,	4,	4, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"attlen"},		  21, -1,	2,	5, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1249, {"attnum"},		  21, -1,	2,	6, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1249, {"attndims"},	  23, -1,	4,	7, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"attcacheoff"},  23, -1,	4,	8, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"atttypmod"},	  23, -1,	4,	9, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"attbyval"},	  16, -1,	1, 10, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attstorage"},   18, -1,	1, 11, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attisset"},	  16, -1,	1, 12, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attalign"},	  18, -1,	1, 13, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attnotnull"},   16, -1,	1, 14, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"atthasdef"},	  16, -1,	1, 15, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attisdropped"}, 16, -1,	1, 16, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attislocal"},   16, -1,	1, 17, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attinhcount"},  23, -1,	4, 18, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }
! 
! DATA(insert ( 1249 attrelid			26 -1  4   1 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 attname			19 -1 NAMEDATALEN  2 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1249 atttypid			26 -1  4   3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 attstattarget	23 -1  4   4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 attlen			21 -1  2   5 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1249 attnum			21 -1  2   6 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1249 attndims			23 -1  4   7 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 attcacheoff		23 -1  4   8 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 atttypmod		23 -1  4   9 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 attbyval			16 -1  1  10 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attstorage		18 -1  1  11 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attisset			16 -1  1  12 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attalign			18 -1  1  13 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attnotnull		16 -1  1  14 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 atthasdef		16 -1  1  15 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attisdropped		16 -1  1  16 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attislocal		16 -1  1  17 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attinhcount		23 -1  4  18 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 ctid				27 0  6  -1 0 -1 -1 f p f i t f f t 0));
  /* no OIDs in pg_attribute */
! DATA(insert ( 1249 xmin				28 0  4  -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 cmin				29 0  4  -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 xmax				28 0  4  -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 cmax				29 0  4  -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 tableoid			26 0  4  -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_class
   * ----------------
   */
  #define Schema_pg_class \
! { 1259, {"relname"},	   19, -1, NAMEDATALEN, 1, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relnamespace"},  26, -1,	4,	2, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"reltype"},	   26, -1,	4,	3, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relowner"},	   23, -1,	4,	4, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relam"},		   26, -1,	4,	5, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relfilenode"},   26, -1,	4,	6, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relpages"},	   23, -1,	4,	7, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"reltuples"},	   700, -1,	4,	8, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"reltoastrelid"}, 26, -1,	4,	9, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"reltoastidxid"}, 26, -1,	4, 10, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relhasindex"},   16, -1,	1, 11, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relisshared"},   16, -1,	1, 12, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relkind"},	   18, -1,	1, 13, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relnatts"},	   21, -1,	2, 14, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"relchecks"},	   21, -1,	2, 15, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"reltriggers"},   21, -1,	2, 16, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"relukeys"},	   21, -1,	2, 17, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"relfkeys"},	   21, -1,	2, 18, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"relrefs"},	   21, -1,	2, 19, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"relhasoids"},    16, -1,	1, 20, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relhaspkey"},    16, -1,	1, 21, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relhasrules"},   16, -1,	1, 22, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relhassubclass"},16, -1,	1, 23, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relacl"},		 1034, -1, -1, 24, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }
! 
! DATA(insert ( 1259 relname			19 -1 NAMEDATALEN	1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1259 relnamespace		26 -1 4   2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 reltype			26 -1 4   3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 relowner			23 -1 4   4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 relam			26 -1 4   5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 relfilenode		26 -1 4   6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 relpages			23 -1 4   7 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 reltuples	   700 -1 4   8 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1259 reltoastrelid	26 -1 4   9 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 reltoastidxid	26 -1 4  10 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 relhasindex		16 -1 1  11 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relisshared		16 -1 1  12 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relkind			18 -1 1  13 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relnatts			21 -1 2  14 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 relchecks		21 -1 2  15 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 reltriggers		21 -1 2  16 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 relukeys			21 -1 2  17 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 relfkeys			21 -1 2  18 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 relrefs			21 -1 2  19 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 relhasoids		16 -1 1  20 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relhaspkey		16 -1 1  21 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relhasrules		16 -1 1  22 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relhassubclass	16 -1 1  23 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relacl		  1034 -1 -1 24 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1259 ctid				27 0  6  -1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1259 oid				26 0  4  -2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 xmin				28 0  4  -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 cmin				29 0  4  -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 xmax				28 0  4  -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 cmax				29 0  4  -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 tableoid			26 0  4  -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_xactlock - this is not a real relation, but is a placeholder
--- 219,494 ----
   * ----------------
   */
  #define Schema_pg_type \
! { 1247, {"typname"},	   19, -1, NAMEDATALEN, 1, 1, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typnamespace"},  26, -1,	4,	2, 2, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typowner"},	   23, -1,	4,	3, 3, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typlen"},		   21, -1,	2,	4, 4, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1247, {"typbyval"},	   16, -1,	1,	5, 5, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typtype"},	   18, -1,	1,	6, 6, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typisdefined"},  16, -1,	1,	7, 7, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typdelim"},	   18, -1,	1,	8, 8, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typrelid"},	   26, -1,	4,	9, 9, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typelem"},	   26, -1,	4, 10, 10, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typinput"},	   24, -1,	4, 11, 11, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typoutput"},	   24, -1,	4, 12, 12, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typreceive"},    24, -1,	4, 13, 13, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typsend"},	   24, -1,	4, 14, 14, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typalign"},	   18, -1,	1, 15, 15, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typstorage"},    18, -1,	1, 16, 16, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typnotnull"},    16, -1,	1, 17, 17, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1247, {"typbasetype"},   26, -1,	4, 18, 18, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typtypmod"},	   23, -1,	4, 19, 19, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typndims"},	   23, -1,	4, 20, 20, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1247, {"typdefaultbin"}, 25, -1, -1, 21, 21, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }, \
! { 1247, {"typdefault"},    25, -1, -1, 22, 22, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }
! 
! 
! DATA(insert ( 1247 typname			19 -1 NAMEDATALEN	1 1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1247 typnamespace		26 -1 4   2 2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typowner			23 -1 4   3 3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typlen			21 -1 2   4 4 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1247 typbyval			16 -1 1   5 5 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typtype			18 -1 1   6 6 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typisdefined		16 -1 1   7 7 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typdelim			18 -1 1   8 8 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typrelid			26 -1 4   9 9 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typelem			26 -1 4  10 10 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typinput			24 -1 4  11 11 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typoutput		24 -1 4  12 12 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typreceive		24 -1 4  13 13 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typsend			24 -1 4  14 14 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typalign			18 -1 1  15 15 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typstorage		18 -1 1  16 16 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typnotnull		16 -1 1  17 17 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1247 typbasetype		26 -1 4  18 18 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typtypmod		23 -1 4  19 19 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typndims			23 -1 4  20 20 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 typdefaultbin	25 -1 -1 21 21 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1247 typdefault		25 -1 -1 22 22 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1247 ctid				27 0  6  -1 -1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1247 oid				26 0  4  -2 -2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 xmin				28 0  4  -3 -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 cmin				29 0  4  -4 -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 xmax				28 0  4  -5 -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 cmax				29 0  4  -6 -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1247 tableoid			26 0  4  -7 -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_database
   * ----------------
   */
! DATA(insert ( 1262 datname			19 -1 NAMEDATALEN   1 1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1262 datdba			23 -1 4   2 2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 encoding			23 -1 4   3 3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 datistemplate	16 -1 1   4 4 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1262 datallowconn		16 -1 1   5 5 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1262 datlastsysoid	26 -1 4   6 6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 datvacuumxid		28 -1 4   7 7 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 datfrozenxid		28 -1 4   8 8 0 -1 -1 t p f i t f f t 0));
  /* do not mark datpath as toastable; GetRawDatabaseInfo won't cope */
! DATA(insert ( 1262 datpath			25 -1 -1  9 9 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1262 datconfig	  1009 -1 -1 10 10 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1262 datacl		  1034 -1 -1 11 11 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1262 ctid				27 0  6  -1 -1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1262 oid				26 0  4  -2 -2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 xmin				28 0  4  -3 -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 cmin				29 0  4  -4 -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 xmax				28 0  4  -5 -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 cmax				29 0  4  -6 -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1262 tableoid			26 0  4  -7 -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_proc
   * ----------------
   */
  #define Schema_pg_proc \
! { 1255, {"proname"},			19, -1, NAMEDATALEN,  1, 1, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"pronamespace"},		26, -1, 4,	2, 2, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"proowner"},			23, -1,	4,	3, 3, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"prolang"},			26, -1,	4,	4, 4, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"proisagg"},			16, -1, 1,	5, 5, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1255, {"prosecdef"},			16, -1,	1,	6, 6, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1255, {"proisstrict"},		16, -1,	1,	7, 7, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1255, {"proretset"},			16, -1,	1,	8, 8, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1255, {"provolatile"},		18, -1,	1,	9, 9, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1255, {"pronargs"},			21, -1,	2, 10, 10, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1255, {"prorettype"},			26, -1,	4, 11, 11, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"proargtypes"},		30, -1, INDEX_MAX_KEYS*4, 12, 12, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1255, {"prosrc"},				25, -1, -1, 13, 13, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }, \
! { 1255, {"probin"},				17, -1, -1, 14, 14, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }, \
! { 1255, {"proacl"},			  1034, -1, -1, 15, 15, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }
! 
! DATA(insert ( 1255 proname			19 -1 NAMEDATALEN	1 1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1255 pronamespace		26 -1 4   2 2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 proowner			23 -1 4   3 3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 prolang			26 -1 4   4 4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 proisagg			16 -1 1   5 5 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1255 prosecdef		16 -1 1   6 6 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1255 proisstrict		16 -1 1   7 7 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1255 proretset		16 -1 1   8 8 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1255 provolatile		18 -1 1   9 9 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1255 pronargs			21 -1 2  10 10 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1255 prorettype		26 -1 4  11 11 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 proargtypes		30 -1 INDEX_MAX_KEYS*4 12 12 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1255 prosrc			25 -1 -1 13 13 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1255 probin			17 -1 -1 14 14 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1255 proacl		  1034 -1 -1 15 15 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1255 ctid				27 0  6  -1 -1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1255 oid				26 0  4  -2 -2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 xmin				28 0  4  -3 -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 cmin				29 0  4  -4 -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 xmax				28 0  4  -5 -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 cmax				29 0  4  -6 -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1255 tableoid			26 0  4  -7 -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_shadow
   * ----------------
   */
! DATA(insert ( 1260 usename			19	-1 NAMEDATALEN	1 1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1260 usesysid			23	-1	4	2 2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1260 usecreatedb		16	-1	1	3 3 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1260 usesuper			16	-1	1	4 4 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1260 usecatupd		16	-1	1	5 5 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1260 passwd			25	-1 -1	6 6 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1260 valuntil		   702	-1	4	7 7 0 -1 -1 t p f i f f f t 0));
! DATA(insert ( 1260 useconfig	  1009	-1 -1	8 8 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1260 ctid				27 0  6  -1 -1 0 -1 -1 f p f i t f f t 0));
  /* no OIDs in pg_shadow */
! DATA(insert ( 1260 xmin				28 0  4  -3 -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1260 cmin				29 0  4  -4 -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1260 xmax				28 0  4  -5 -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1260 cmax				29 0  4  -6 -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1260 tableoid			26 0  4  -7 -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_group
   * ----------------
   */
! DATA(insert ( 1261 groname			19 -1 NAMEDATALEN  1 1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1261 grosysid			23 -1  4   2 2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1261 grolist		  1007 -1 -1   3 3 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1261 ctid				27 0  6  -1 -1 0 -1 -1 f p f i t f f t 0));
  /* no OIDs in pg_group */
! DATA(insert ( 1261 xmin				28 0  4  -3 -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1261 cmin				29 0  4  -4 -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1261 xmax				28 0  4  -5 -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1261 cmax				29 0  4  -6 -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1261 tableoid			26 0  4  -7 -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_attribute
   * ----------------
   */
  #define Schema_pg_attribute \
! { 1249, {"attrelid"},	  26, -1,	4,	1, 1, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"attname"},	  19, -1, NAMEDATALEN,	2, 2, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"atttypid"},	  26, -1,	4,	3, 3, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"attstattarget"}, 23, -1,	4,	4, 4, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"attlen"},		  21, -1,	2,	5, 5, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1249, {"attnum"},		  21, -1,	2,	6, 6, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1249, {"attlogpos"},	  21, -1,	2,  7, 7, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0},  \
! { 1249, {"attndims"},	  23, -1,	4,	8, 8, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"attcacheoff"},  23, -1,	4,	9, 9, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"atttypmod"},	  23, -1,	4, 10, 10, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1249, {"attbyval"},	  16, -1,	1, 11, 11, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attstorage"},   18, -1,	1, 12, 12, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attisset"},	  16, -1,	1, 13, 13, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attalign"},	  18, -1,	1, 14, 14, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attnotnull"},   16, -1,	1, 15, 15, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"atthasdef"},	  16, -1,	1, 16, 16, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attisdropped"}, 16, -1,	1, 17, 17, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attislocal"},   16, -1,	1, 18, 18, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1249, {"attinhcount"},  23, -1,	4, 19, 19, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }
! 
! DATA(insert ( 1249 attrelid			26 -1  4   1 1 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 attname			19 -1 NAMEDATALEN  2 2 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1249 atttypid			26 -1  4   3 3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 attstattarget	23 -1  4   4 4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 attlen			21 -1  2   5 5 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1249 attnum			21 -1  2   6 6 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1249 attlogpos		21 -1  2   7 7 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1249 attndims			23 -1  4   8 8 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 attcacheoff		23 -1  4   9 9 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 atttypmod		23 -1  4  10 10 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 attbyval			16 -1  1  11 11 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attstorage		18 -1  1  12 12 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attisset			16 -1  1  13 13 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attalign			18 -1  1  14 14 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attnotnull		16 -1  1  15 15 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 atthasdef		16 -1  1  16 16 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attisdropped		16 -1  1  17 17 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attislocal		16 -1  1  18 18 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1249 attinhcount		23 -1  4  19 19 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 ctid				27 0  6  -1 -1 0 -1 -1 f p f i t f f t 0));
  /* no OIDs in pg_attribute */
! DATA(insert ( 1249 xmin				28 0  4  -3 -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 cmin				29 0  4  -4 -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 xmax				28 0  4  -5 -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 cmax				29 0  4  -6 -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1249 tableoid			26 0  4  -7 -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_class
   * ----------------
   */
  #define Schema_pg_class \
! { 1259, {"relname"},	   19, -1, NAMEDATALEN, 1, 1, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relnamespace"},  26, -1,	4,	2, 2, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"reltype"},	   26, -1,	4,	3, 3, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relowner"},	   23, -1,	4,	4, 4, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relam"},		   26, -1,	4,	5, 5, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relfilenode"},   26, -1,	4,	6, 6, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relpages"},	   23, -1,	4,	7, 7, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"reltuples"},	   700, -1,	4,	8, 8, 0, -1, -1, false, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"reltoastrelid"}, 26, -1,	4,	9, 9, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"reltoastidxid"}, 26, -1,	4, 10, 10, 0, -1, -1, true, 'p', false, 'i', true, false, false, true, 0 }, \
! { 1259, {"relhasindex"},   16, -1,	1, 11, 11, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relisshared"},   16, -1,	1, 12, 12, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relkind"},	   18, -1,	1, 13, 13, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relnatts"},	   21, -1,	2, 14, 14, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"relchecks"},	   21, -1,	2, 15, 15, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"reltriggers"},   21, -1,	2, 16, 16, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"relukeys"},	   21, -1,	2, 17, 17, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"relfkeys"},	   21, -1,	2, 18, 18, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"relrefs"},	   21, -1,	2, 19, 19, 0, -1, -1, true, 'p', false, 's', true, false, false, true, 0 }, \
! { 1259, {"relhasoids"},    16, -1,	1, 20, 20, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relhaspkey"},    16, -1,	1, 21, 21, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relhasrules"},   16, -1,	1, 22, 22, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relhassubclass"},16, -1,	1, 23, 23, 0, -1, -1, true, 'p', false, 'c', true, false, false, true, 0 }, \
! { 1259, {"relacl"},		 1034, -1, -1, 24, 24, 0, -1, -1, false, 'x', false, 'i', false, false, false, true, 0 }
! 
! DATA(insert ( 1259 relname			19 -1 NAMEDATALEN	1 1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1259 relnamespace		26 -1 4   2 2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 reltype			26 -1 4   3 3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 relowner			23 -1 4   4 4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 relam			26 -1 4   5 5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 relfilenode		26 -1 4   6 6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 relpages			23 -1 4   7 7 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 reltuples	   700 -1 4   8 8 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1259 reltoastrelid	26 -1 4   9 9 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 reltoastidxid	26 -1 4  10 10 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 relhasindex		16 -1 1  11 11 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relisshared		16 -1 1  12 12 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relkind			18 -1 1  13 13 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relnatts			21 -1 2  14 14 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 relchecks		21 -1 2  15 15 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 reltriggers		21 -1 2  16 16 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 relukeys			21 -1 2  17 17 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 relfkeys			21 -1 2  18 18 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 relrefs			21 -1 2  19 19 0 -1 -1 t p f s t f f t 0));
! DATA(insert ( 1259 relhasoids		16 -1 1  20 20 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relhaspkey		16 -1 1  21 21 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relhasrules		16 -1 1  22 22 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relhassubclass	16 -1 1  23 23 0 -1 -1 t p f c t f f t 0));
! DATA(insert ( 1259 relacl		  1034 -1 -1 24 24 0 -1 -1 f x f i f f f t 0));
! DATA(insert ( 1259 ctid				27 0  6  -1 -1 0 -1 -1 f p f i t f f t 0));
! DATA(insert ( 1259 oid				26 0  4  -2 -2 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 xmin				28 0  4  -3 -3 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 cmin				29 0  4  -4 -4 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 xmax				28 0  4  -5 -5 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 cmax				29 0  4  -6 -6 0 -1 -1 t p f i t f f t 0));
! DATA(insert ( 1259 tableoid			26 0  4  -7 -7 0 -1 -1 t p f i t f f t 0));
  
  /* ----------------
   *		pg_xactlock - this is not a real relation, but is a placeholder
***************
*** 503,508 ****
   *				  table; and this entry is just to link to that one.
   * ----------------
   */
! DATA(insert ( 376 xactlockfoo		26 0  4   1 0 -1 -1 t p f i t f f t 0));
  
  #endif   /* PG_ATTRIBUTE_H */
--- 498,503 ----
   *				  table; and this entry is just to link to that one.
   * ----------------
   */
! DATA(insert ( 376 xactlockfoo		26 0  4   1 1 0 -1 -1 t p f i t f f t 0));
  
  #endif   /* PG_ATTRIBUTE_H */
Index: src/include/catalog/pg_class.h
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/include/catalog/pg_class.h,v
retrieving revision 1.77
diff -c -r1.77 pg_class.h
*** src/include/catalog/pg_class.h	4 Aug 2003 02:40:11 -0000	1.77
--- src/include/catalog/pg_class.h	24 Nov 2003 17:08:27 -0000
***************
*** 42,51 ****
   */
  CATALOG(pg_class) BOOTSTRAP
  {
! 	NameData	relname;		/* class name */
! 	Oid			relnamespace;	/* OID of namespace containing this class */
  	Oid			reltype;		/* OID of associated entry in pg_type */
! 	int4		relowner;		/* class owner */
  	Oid			relam;			/* index access method; 0 if not an index */
  	Oid			relfilenode;	/* identifier of physical storage file */
  	int4		relpages;		/* # of blocks (not always up-to-date) */
--- 42,51 ----
   */
  CATALOG(pg_class) BOOTSTRAP
  {
! 	NameData	relname;		/* relation name */
! 	Oid			relnamespace;	/* OID of namespace containing this relation */
  	Oid			reltype;		/* OID of associated entry in pg_type */
! 	int4		relowner;		/* relation owner */
  	Oid			relam;			/* index access method; 0 if not an index */
  	Oid			relfilenode;	/* identifier of physical storage file */
  	int4		relpages;		/* # of blocks (not always up-to-date) */
***************
*** 55,68 ****
  	bool		relhasindex;	/* T if has (or has had) any indexes */
  	bool		relisshared;	/* T if shared across databases */
  	char		relkind;		/* see RELKIND_xxx constants below */
- 	int2		relnatts;		/* number of user attributes */
- 
  	/*
! 	 * Class pg_attribute must contain exactly "relnatts" user attributes
! 	 * (with attnums ranging from 1 to relnatts) for this class.  It may
! 	 * also contain entries with negative attnums for system attributes.
  	 */
! 	int2		relchecks;		/* # of CHECK constraints for class */
  	int2		reltriggers;	/* # of TRIGGERs */
  	int2		relukeys;		/* # of Unique keys (not used) */
  	int2		relfkeys;		/* # of FOREIGN KEYs (not used) */
--- 55,69 ----
  	bool		relhasindex;	/* T if has (or has had) any indexes */
  	bool		relisshared;	/* T if shared across databases */
  	char		relkind;		/* see RELKIND_xxx constants below */
  	/*
! 	 * pg_attribute must contain exactly "relnatts" user attributes
! 	 * (with attnums ranging from 1 to relnatts) for this relation.
! 	 * It may also contain entries with negative attnums for system
! 	 * attributes.
  	 */
! 	int2		relnatts;		/* number of user attributes */
! 
! 	int2		relchecks;		/* # of CHECK constraints for relation */
  	int2		reltriggers;	/* # of TRIGGERs */
  	int2		relukeys;		/* # of Unique keys (not used) */
  	int2		relfkeys;		/* # of FOREIGN KEYs (not used) */
***************
*** 70,75 ****
--- 71,84 ----
  	bool		relhasoids;		/* T if we generate OIDs for rows of rel */
  	bool		relhaspkey;		/* has PRIMARY KEY index */
  	bool		relhasrules;	/* has associated rules */
+ 
+ 	/*
+ 	 * "relhassubclass" indicates that the relation MAY have one or
+ 	 * more derived relations. This attribute provides no claim to
+ 	 * certaintity: it is not updated when a derived relation is
+ 	 * dropped, due to concurrency concerns. Authoritive information
+ 	 * is available from the pg_inherits system catalog.
+ 	 */
  	bool		relhassubclass; /* has derived classes */
  
  	/*
***************
*** 136,142 ****
  
  DATA(insert OID = 1247 (  pg_type		PGNSP 71 PGUID 0 1247 0 0 0 0 f f r 22 0 0 0 0 0 t f f f _null_ ));
  DESCR("");
! DATA(insert OID = 1249 (  pg_attribute	PGNSP 75 PGUID 0 1249 0 0 0 0 f f r 18 0 0 0 0 0 f f f f _null_ ));
  DESCR("");
  DATA(insert OID = 1255 (  pg_proc		PGNSP 81 PGUID 0 1255 0 0 0 0 f f r 15 0 0 0 0 0 t f f f _null_ ));
  DESCR("");
--- 145,151 ----
  
  DATA(insert OID = 1247 (  pg_type		PGNSP 71 PGUID 0 1247 0 0 0 0 f f r 22 0 0 0 0 0 t f f f _null_ ));
  DESCR("");
! DATA(insert OID = 1249 (  pg_attribute	PGNSP 75 PGUID 0 1249 0 0 0 0 f f r 19 0 0 0 0 0 f f f f _null_ ));
  DESCR("");
  DATA(insert OID = 1255 (  pg_proc		PGNSP 81 PGUID 0 1255 0 0 0 0 f f r 15 0 0 0 0 0 t f f f _null_ ));
  DESCR("");
***************
*** 162,171 ****
  /* Xact lock pseudo-table */
  #define XactLockTableId			376
  
! #define		  RELKIND_INDEX			  'i'		/* secondary index */
  #define		  RELKIND_RELATION		  'r'		/* ordinary cataloged heap */
  #define		  RELKIND_SPECIAL		  's'		/* special (non-heap) */
! #define		  RELKIND_SEQUENCE		  'S'		/* SEQUENCE relation */
  #define		  RELKIND_UNCATALOGED	  'u'		/* temporary heap */
  #define		  RELKIND_TOASTVALUE	  't'		/* moved off huge values */
  #define		  RELKIND_VIEW			  'v'		/* view */
--- 171,180 ----
  /* Xact lock pseudo-table */
  #define XactLockTableId			376
  
! #define		  RELKIND_INDEX			  'i'		/* index relation */
  #define		  RELKIND_RELATION		  'r'		/* ordinary cataloged heap */
  #define		  RELKIND_SPECIAL		  's'		/* special (non-heap) */
! #define		  RELKIND_SEQUENCE		  'S'		/* sequence relation */
  #define		  RELKIND_UNCATALOGED	  'u'		/* temporary heap */
  #define		  RELKIND_TOASTVALUE	  't'		/* moved off huge values */
  #define		  RELKIND_VIEW			  'v'		/* view */
Index: src/pl/plpgsql/src/pl_comp.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/pl/plpgsql/src/pl_comp.c,v
retrieving revision 1.69
diff -c -r1.69 pl_comp.c
*** src/pl/plpgsql/src/pl_comp.c	30 Sep 2003 00:59:51 -0000	1.69
--- src/pl/plpgsql/src/pl_comp.c	24 Nov 2003 23:45:20 -0000
***************
*** 1494,1500 ****
  	 * memory context ...
  	 */
  	oldcxt = MemoryContextSwitchTo(TopMemoryContext);
! 	row->rowtupdesc = CreateTupleDescCopy(RelationGetDescr(rel));
  	MemoryContextSwitchTo(oldcxt);
  
  	row->nfields = classStruct->relnatts;
--- 1494,1500 ----
  	 * memory context ...
  	 */
  	oldcxt = MemoryContextSwitchTo(TopMemoryContext);
! 	row->rowtupdesc = CopyTupleDesc(RelationGetDescr(rel), false);
  	MemoryContextSwitchTo(oldcxt);
  
  	row->nfields = classStruct->relnatts;
Index: src/pl/plpgsql/src/pl_exec.c
===================================================================
RCS file: /var/lib/cvs/pgsql-server/src/pl/plpgsql/src/pl_exec.c,v
retrieving revision 1.93
diff -c -r1.93 pl_exec.c
*** src/pl/plpgsql/src/pl_exec.c	1 Oct 2003 21:47:42 -0000	1.93
--- src/pl/plpgsql/src/pl_exec.c	24 Nov 2003 23:45:20 -0000
***************
*** 352,358 ****
  				MemoryContext oldcxt;
  
  				oldcxt = MemoryContextSwitchTo(estate.tuple_store_cxt);
! 				rsi->setDesc = CreateTupleDescCopy(estate.rettupdesc);
  				MemoryContextSwitchTo(oldcxt);
  			}
  		}
--- 352,358 ----
  				MemoryContext oldcxt;
  
  				oldcxt = MemoryContextSwitchTo(estate.tuple_store_cxt);
! 				rsi->setDesc = CopyTupleDesc(estate.rettupdesc, false);
  				MemoryContextSwitchTo(oldcxt);
  			}
  		}
***************
*** 3390,3396 ****
  
  		if (tupdesc)
  		{
! 			rec->tupdesc = CreateTupleDescCopy(tupdesc);
  			rec->freetupdesc = true;
  		}
  		else
--- 3390,3396 ----
  
  		if (tupdesc)
  		{
! 			rec->tupdesc = CopyTupleDesc(tupdesc, false);
  			rec->freetupdesc = true;
  		}
  		else
