1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-17 06:41:09 +03:00

Code review for HeapTupleHeader changes. Add version number to page headers

(overlaying low byte of page size) and add HEAP_HASOID bit to t_infomask,
per earlier discussion.  Simplify scheme for overlaying fields in tuple
header (no need for cmax to live in more than one place).  Don't try to
clear infomask status bits in tqual.c --- not safe to do it there.  Don't
try to force output table of a SELECT INTO to have OIDs, either.  Get rid
of unnecessarily complex three-state scheme for TupleDesc.tdhasoids, which
has already caused one recent failure.  Improve documentation.
This commit is contained in:
Tom Lane
2002-09-02 01:05:06 +00:00
parent fcd34f9f7f
commit c7a165adc6
49 changed files with 513 additions and 561 deletions

View File

@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.80 2002/08/25 17:20:00 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.81 2002/09/02 01:05:03 tgl Exp $
*
* NOTES
* The old interface functions have been converted to macros
@ -80,7 +80,7 @@ DataFill(char *data,
bitmask = CSIGNBIT;
}
*infomask &= HEAP_XACT_MASK;
*infomask &= ~(HEAP_HASNULL | HEAP_HASVARWIDTH | HEAP_HASEXTENDED);
for (i = 0; i < numberOfAttributes; i++)
{
@ -584,8 +584,6 @@ heap_formtuple(TupleDesc tupleDescriptor,
elog(ERROR, "heap_formtuple: numberOfAttributes %d exceeds limit %d",
numberOfAttributes, MaxTupleAttributeNumber);
AssertTupleDescHasOidIsValid(tupleDescriptor);
for (i = 0; i < numberOfAttributes; i++)
{
if (nulls[i] != ' ')
@ -600,7 +598,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
if (hasnull)
len += BITMAPLEN(numberOfAttributes);
if (tupleDescriptor->tdhasoid == WITHOID)
if (tupleDescriptor->tdhasoid)
len += sizeof(Oid);
hoff = len = MAXALIGN(len); /* align user data safely */
@ -626,6 +624,9 @@ heap_formtuple(TupleDesc tupleDescriptor,
&td->t_infomask,
(hasnull ? td->t_bits : NULL));
if (tupleDescriptor->tdhasoid)
td->t_infomask |= HEAP_HASOID;
td->t_infomask |= HEAP_XMAX_INVALID;
return tuple;
@ -651,7 +652,6 @@ heap_modifytuple(HeapTuple tuple,
char *nulls;
bool isNull;
HeapTuple newTuple;
uint8 infomask;
/*
* sanity checks
@ -702,18 +702,10 @@ heap_modifytuple(HeapTuple tuple,
nulls);
/*
* copy the header except for t_len, t_natts, t_hoff, t_bits,
* t_infomask
* copy the identification info of the old tuple: t_ctid, t_self,
* and OID (if any)
*/
infomask = newTuple->t_data->t_infomask;
/*
* copy t_xmin, t_cid, t_xmax, t_ctid, t_natts, t_infomask
*/
memmove((char *) newTuple->t_data, /* XXX */
(char *) tuple->t_data,
offsetof(HeapTupleHeaderData, t_hoff)); /* XXX */
newTuple->t_data->t_infomask = infomask;
newTuple->t_data->t_natts = numberOfAttributes;
newTuple->t_data->t_ctid = tuple->t_data->t_ctid;
newTuple->t_self = tuple->t_self;
newTuple->t_tableOid = tuple->t_tableOid;
if (relation->rd_rel->relhasoids)
@ -776,11 +768,11 @@ heap_addheader(int natts, /* max domain index */
tuple->t_datamcxt = CurrentMemoryContext;
tuple->t_data = td = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
MemSet((char *) td, 0, len);
MemSet((char *) td, 0, hoff);
td->t_hoff = hoff;
td->t_natts = natts;
td->t_infomask = HEAP_XMAX_INVALID; /* XXX sufficient? */
td->t_infomask = withoid ? (HEAP_XMAX_INVALID | HEAP_HASOID) : HEAP_XMAX_INVALID;
memcpy((char *) td + hoff, structure, structlen);

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.87 2002/08/30 19:23:18 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.88 2002/09/02 01:05:03 tgl Exp $
*
* NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be
@ -37,7 +37,7 @@
* ----------------------------------------------------------------
*/
TupleDesc
CreateTemplateTupleDesc(int natts, hasoid_t withoid)
CreateTemplateTupleDesc(int natts, bool hasoid)
{
uint32 size;
TupleDesc desc;
@ -59,7 +59,7 @@ CreateTemplateTupleDesc(int natts, hasoid_t withoid)
MemSet(desc->attrs, 0, size);
desc->natts = natts;
desc->tdhasoid = withoid;
desc->tdhasoid = hasoid;
return desc;
}
@ -67,11 +67,12 @@ CreateTemplateTupleDesc(int natts, hasoid_t withoid)
/* ----------------------------------------------------------------
* CreateTupleDesc
*
* This function allocates a new TupleDesc from Form_pg_attribute array
* This function allocates a new TupleDesc pointing to a given
* Form_pg_attribute array
* ----------------------------------------------------------------
*/
TupleDesc
CreateTupleDesc(int natts, Form_pg_attribute *attrs)
CreateTupleDesc(int natts, bool hasoid, Form_pg_attribute *attrs)
{
TupleDesc desc;
@ -84,7 +85,7 @@ CreateTupleDesc(int natts, Form_pg_attribute *attrs)
desc->attrs = attrs;
desc->natts = natts;
desc->constr = NULL;
desc->tdhasoid = UNDEFOID;
desc->tdhasoid = hasoid;
return desc;
}
@ -129,7 +130,6 @@ CreateTupleDescCopy(TupleDesc tupdesc)
*
* This function creates a new TupleDesc by copying from an existing
* TupleDesc (with Constraints)
*
* ----------------------------------------------------------------
*/
TupleDesc
@ -477,6 +477,9 @@ TupleDescInitEntry(TupleDesc desc,
* BuildDescForRelation
*
* Given a relation schema (list of ColumnDef nodes), build a TupleDesc.
*
* Note: the default assumption is no OIDs; caller may modify the returned
* TupleDesc if it wants OIDs.
*/
TupleDesc
BuildDescForRelation(List *schema)
@ -497,7 +500,7 @@ BuildDescForRelation(List *schema)
* allocate a new tuple descriptor
*/
natts = length(schema);
desc = CreateTemplateTupleDesc(natts, UNDEFOID);
desc = CreateTemplateTupleDesc(natts, false);
constr->has_not_null = false;
attnum = 0;
@ -667,7 +670,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
/* OK, get the column alias */
attname = strVal(lfirst(colaliases));
tupdesc = CreateTemplateTupleDesc(1, WITHOUTOID);
tupdesc = CreateTemplateTupleDesc(1, false);
TupleDescInitEntry(tupdesc,
(AttrNumber) 1,
attname,