diff options
Diffstat (limited to 'src/backend/access/common')
| -rw-r--r-- | src/backend/access/common/heaptuple.c | 27 | ||||
| -rw-r--r-- | src/backend/access/common/tupdesc.c | 16 |
2 files changed, 31 insertions, 12 deletions
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index adad245c64..19e02dee67 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.77 2002/06/20 20:29:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.78 2002/07/20 05:16:56 momjian Exp $ * * NOTES * The old interface functions have been converted to macros @@ -436,7 +436,7 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull) result = PointerGetDatum(&(tup->t_self)); break; case ObjectIdAttributeNumber: - result = ObjectIdGetDatum(tup->t_data->t_oid); + result = ObjectIdGetDatum(HeapTupleGetOid(tup)); break; case MinTransactionIdAttributeNumber: result = TransactionIdGetDatum(HeapTupleHeaderGetXmin(tup->t_data)); @@ -581,6 +581,8 @@ 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] != ' ') @@ -595,6 +597,9 @@ heap_formtuple(TupleDesc tupleDescriptor, if (hasnull) len += BITMAPLEN(numberOfAttributes); + if (tupleDescriptor->tdhasoid == WITHOID) + len += sizeof(Oid); + hoff = len = MAXALIGN(len); /* align user data safely */ len += ComputeDataSize(tupleDescriptor, value, nulls); @@ -698,14 +703,18 @@ heap_modifytuple(HeapTuple tuple, * t_infomask */ infomask = newTuple->t_data->t_infomask; - memmove((char *) &newTuple->t_data->t_oid, /* XXX */ - (char *) &tuple->t_data->t_oid, - ((char *) &tuple->t_data->t_hoff - - (char *) &tuple->t_data->t_oid)); /* XXX */ + /* + * 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_self = tuple->t_self; newTuple->t_tableOid = tuple->t_tableOid; + if (relation->rd_rel->relhasoids) + HeapTupleSetOid(newTuple, HeapTupleGetOid(tuple)); return newTuple; } @@ -738,6 +747,7 @@ heap_freetuple(HeapTuple htup) */ HeapTuple heap_addheader(int natts, /* max domain index */ + bool withoid, /* reserve space for oid */ Size structlen, /* its length */ void *structure) /* pointer to the struct */ { @@ -749,7 +759,10 @@ heap_addheader(int natts, /* max domain index */ AssertArg(natts > 0); /* header needs no null bitmap */ - hoff = MAXALIGN(offsetof(HeapTupleHeaderData, t_bits)); + hoff = offsetof(HeapTupleHeaderData, t_bits); + if (withoid) + hoff += sizeof(Oid); + hoff = MAXALIGN(hoff); len = hoff + structlen; tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len); diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index af73941369..24f33fac4b 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.80 2002/06/20 20:29:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.81 2002/07/20 05:16:56 momjian Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -36,7 +36,7 @@ * ---------------------------------------------------------------- */ TupleDesc -CreateTemplateTupleDesc(int natts) +CreateTemplateTupleDesc(int natts, hasoid_t withoid) { uint32 size; TupleDesc desc; @@ -58,6 +58,7 @@ CreateTemplateTupleDesc(int natts) MemSet(desc->attrs, 0, size); desc->natts = natts; + desc->tdhasoid = withoid; return desc; } @@ -82,6 +83,7 @@ CreateTupleDesc(int natts, Form_pg_attribute *attrs) desc->attrs = attrs; desc->natts = natts; desc->constr = NULL; + desc->tdhasoid = UNDEFOID; return desc; } @@ -116,6 +118,7 @@ CreateTupleDescCopy(TupleDesc tupdesc) desc->attrs[i]->atthasdef = false; } desc->constr = NULL; + desc->tdhasoid = tupdesc->tdhasoid; return desc; } @@ -182,6 +185,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc) else desc->constr = NULL; + desc->tdhasoid = tupdesc->tdhasoid; return desc; } @@ -235,6 +239,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) if (tupdesc1->natts != tupdesc2->natts) return false; + if (tupdesc1->tdhasoid != tupdesc2->tdhasoid) + return false; for (i = 0; i < tupdesc1->natts; i++) { Form_pg_attribute attr1 = tupdesc1->attrs[i]; @@ -392,7 +398,7 @@ TupleDescInitEntry(TupleDesc desc, */ typeForm = (Form_pg_type) GETSTRUCT(tuple); - att->atttypid = tuple->t_data->t_oid; + att->atttypid = HeapTupleGetOid(tuple); /* * There are a couple of cases where we must override the information @@ -479,7 +485,7 @@ BuildDescForRelation(List *schema) * allocate a new tuple descriptor */ natts = length(schema); - desc = CreateTemplateTupleDesc(natts); + desc = CreateTemplateTupleDesc(natts, UNDEFOID); constr->has_not_null = false; attnum = 0; @@ -646,7 +652,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases) /* OK, get the column alias */ attname = strVal(lfirst(colaliases)); - tupdesc = CreateTemplateTupleDesc(1); + tupdesc = CreateTemplateTupleDesc(1, WITHOUTOID); TupleDescInitEntry(tupdesc, (AttrNumber) 1, attname, |
