Commit b0f5086e authored by Bruce Momjian's avatar Bruce Momjian

oid is needed, it is added at the end of the struct (after the null

bitmap, if present).

Per Tom Lane's suggestion the information whether a tuple has an oid
or not is carried in the tuple descriptor.  For debugging reasons
tdhasoid is of type char, not bool.  There are predefined values for
WITHOID, WITHOUTOID and UNDEFOID.

This patch has been generated against a cvs snapshot from last week
and I don't expect it to apply cleanly to current sources.  While I
post it here for public review, I'm working on a new version against a
current snapshot.  (There's been heavy activity recently; hope to
catch up some day ...)

This is a long patch;  if it is too hard to swallow, I can provide it
in smaller pieces:

Part 1:  Accessor macros
Part 2:  tdhasoid in TupDesc
Part 3:  Regression test
Part 4:  Parameter withoid to heap_addheader
Part 5:  Eliminate t_oid from HeapTupleHeader

Part 2 is the most hairy part because of changes in the executor and
even in the parser;  the other parts are straightforward.

Up to part 4 the patched postmaster stays binary compatible to
databases created with an unpatched version.  Part 5 is small (100
lines) and finally breaks compatibility.

Manfred Koizar
parent 38dd3ae7
...@@ -65,7 +65,7 @@ database_size(PG_FUNCTION_ARGS) ...@@ -65,7 +65,7 @@ database_size(PG_FUNCTION_ARGS)
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "database %s does not exist", NameStr(*dbname)); elog(ERROR, "database %s does not exist", NameStr(*dbname));
dbid = tuple->t_data->t_oid; dbid = HeapTupleGetOid(tuple);
if (dbid == InvalidOid) if (dbid == InvalidOid)
elog(ERROR, "invalid database id"); elog(ERROR, "invalid database id");
......
...@@ -190,7 +190,7 @@ fti(PG_FUNCTION_ARGS) ...@@ -190,7 +190,7 @@ fti(PG_FUNCTION_ARGS)
tupdesc = rel->rd_att; /* what the tuple looks like (?) */ tupdesc = rel->rd_att; /* what the tuple looks like (?) */
/* get oid of current tuple, needed by all, so place here */ /* get oid of current tuple, needed by all, so place here */
oid = rettuple->t_data->t_oid; oid = rel->rd_rel->relhasoids ? HeapTupleGetOid(rettuple) : InvalidOid;
if (!OidIsValid(oid)) if (!OidIsValid(oid))
elog(ERROR, "Full Text Indexing: Oid of current tuple is invalid"); elog(ERROR, "Full Text Indexing: Oid of current tuple is invalid");
......
...@@ -102,7 +102,9 @@ _rserv_log_() ...@@ -102,7 +102,9 @@ _rserv_log_()
if (keynum == ObjectIdAttributeNumber) if (keynum == ObjectIdAttributeNumber)
{ {
sprintf(oidbuf, "%u", tuple->t_data->t_oid); sprintf(oidbuf, "%u", rel->rd_rel->relhasoids
? HeapTupleGetOid(tuple)
: InvalidOid);
key = oidbuf; key = oidbuf;
} }
else else
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* The old interface functions have been converted to macros * The old interface functions have been converted to macros
...@@ -436,7 +436,7 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull) ...@@ -436,7 +436,7 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull)
result = PointerGetDatum(&(tup->t_self)); result = PointerGetDatum(&(tup->t_self));
break; break;
case ObjectIdAttributeNumber: case ObjectIdAttributeNumber:
result = ObjectIdGetDatum(tup->t_data->t_oid); result = ObjectIdGetDatum(HeapTupleGetOid(tup));
break; break;
case MinTransactionIdAttributeNumber: case MinTransactionIdAttributeNumber:
result = TransactionIdGetDatum(HeapTupleHeaderGetXmin(tup->t_data)); result = TransactionIdGetDatum(HeapTupleHeaderGetXmin(tup->t_data));
...@@ -581,6 +581,8 @@ heap_formtuple(TupleDesc tupleDescriptor, ...@@ -581,6 +581,8 @@ heap_formtuple(TupleDesc tupleDescriptor,
elog(ERROR, "heap_formtuple: numberOfAttributes %d exceeds limit %d", elog(ERROR, "heap_formtuple: numberOfAttributes %d exceeds limit %d",
numberOfAttributes, MaxTupleAttributeNumber); numberOfAttributes, MaxTupleAttributeNumber);
AssertTupleDescHasOidIsValid(tupleDescriptor);
for (i = 0; i < numberOfAttributes; i++) for (i = 0; i < numberOfAttributes; i++)
{ {
if (nulls[i] != ' ') if (nulls[i] != ' ')
...@@ -595,6 +597,9 @@ heap_formtuple(TupleDesc tupleDescriptor, ...@@ -595,6 +597,9 @@ heap_formtuple(TupleDesc tupleDescriptor,
if (hasnull) if (hasnull)
len += BITMAPLEN(numberOfAttributes); len += BITMAPLEN(numberOfAttributes);
if (tupleDescriptor->tdhasoid == WITHOID)
len += sizeof(Oid);
hoff = len = MAXALIGN(len); /* align user data safely */ hoff = len = MAXALIGN(len); /* align user data safely */
len += ComputeDataSize(tupleDescriptor, value, nulls); len += ComputeDataSize(tupleDescriptor, value, nulls);
...@@ -698,14 +703,18 @@ heap_modifytuple(HeapTuple tuple, ...@@ -698,14 +703,18 @@ heap_modifytuple(HeapTuple tuple,
* t_infomask * t_infomask
*/ */
infomask = newTuple->t_data->t_infomask; infomask = newTuple->t_data->t_infomask;
memmove((char *) &newTuple->t_data->t_oid, /* XXX */ /*
(char *) &tuple->t_data->t_oid, * copy t_xmin, t_cid, t_xmax, t_ctid, t_natts, t_infomask
((char *) &tuple->t_data->t_hoff - */
(char *) &tuple->t_data->t_oid)); /* XXX */ 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_infomask = infomask;
newTuple->t_data->t_natts = numberOfAttributes; newTuple->t_data->t_natts = numberOfAttributes;
newTuple->t_self = tuple->t_self; newTuple->t_self = tuple->t_self;
newTuple->t_tableOid = tuple->t_tableOid; newTuple->t_tableOid = tuple->t_tableOid;
if (relation->rd_rel->relhasoids)
HeapTupleSetOid(newTuple, HeapTupleGetOid(tuple));
return newTuple; return newTuple;
} }
...@@ -738,6 +747,7 @@ heap_freetuple(HeapTuple htup) ...@@ -738,6 +747,7 @@ heap_freetuple(HeapTuple htup)
*/ */
HeapTuple HeapTuple
heap_addheader(int natts, /* max domain index */ heap_addheader(int natts, /* max domain index */
bool withoid, /* reserve space for oid */
Size structlen, /* its length */ Size structlen, /* its length */
void *structure) /* pointer to the struct */ void *structure) /* pointer to the struct */
{ {
...@@ -749,7 +759,10 @@ heap_addheader(int natts, /* max domain index */ ...@@ -749,7 +759,10 @@ heap_addheader(int natts, /* max domain index */
AssertArg(natts > 0); AssertArg(natts > 0);
/* header needs no null bitmap */ /* 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; len = hoff + structlen;
tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len); tuple = (HeapTuple) palloc(HEAPTUPLESIZE + len);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* some of the executor utility code such as "ExecTypeFromTL" should be * some of the executor utility code such as "ExecTypeFromTL" should be
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
TupleDesc TupleDesc
CreateTemplateTupleDesc(int natts) CreateTemplateTupleDesc(int natts, hasoid_t withoid)
{ {
uint32 size; uint32 size;
TupleDesc desc; TupleDesc desc;
...@@ -58,6 +58,7 @@ CreateTemplateTupleDesc(int natts) ...@@ -58,6 +58,7 @@ CreateTemplateTupleDesc(int natts)
MemSet(desc->attrs, 0, size); MemSet(desc->attrs, 0, size);
desc->natts = natts; desc->natts = natts;
desc->tdhasoid = withoid;
return desc; return desc;
} }
...@@ -82,6 +83,7 @@ CreateTupleDesc(int natts, Form_pg_attribute *attrs) ...@@ -82,6 +83,7 @@ CreateTupleDesc(int natts, Form_pg_attribute *attrs)
desc->attrs = attrs; desc->attrs = attrs;
desc->natts = natts; desc->natts = natts;
desc->constr = NULL; desc->constr = NULL;
desc->tdhasoid = UNDEFOID;
return desc; return desc;
} }
...@@ -116,6 +118,7 @@ CreateTupleDescCopy(TupleDesc tupdesc) ...@@ -116,6 +118,7 @@ CreateTupleDescCopy(TupleDesc tupdesc)
desc->attrs[i]->atthasdef = false; desc->attrs[i]->atthasdef = false;
} }
desc->constr = NULL; desc->constr = NULL;
desc->tdhasoid = tupdesc->tdhasoid;
return desc; return desc;
} }
...@@ -182,6 +185,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc) ...@@ -182,6 +185,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc)
else else
desc->constr = NULL; desc->constr = NULL;
desc->tdhasoid = tupdesc->tdhasoid;
return desc; return desc;
} }
...@@ -235,6 +239,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2) ...@@ -235,6 +239,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
if (tupdesc1->natts != tupdesc2->natts) if (tupdesc1->natts != tupdesc2->natts)
return false; return false;
if (tupdesc1->tdhasoid != tupdesc2->tdhasoid)
return false;
for (i = 0; i < tupdesc1->natts; i++) for (i = 0; i < tupdesc1->natts; i++)
{ {
Form_pg_attribute attr1 = tupdesc1->attrs[i]; Form_pg_attribute attr1 = tupdesc1->attrs[i];
...@@ -392,7 +398,7 @@ TupleDescInitEntry(TupleDesc desc, ...@@ -392,7 +398,7 @@ TupleDescInitEntry(TupleDesc desc,
*/ */
typeForm = (Form_pg_type) GETSTRUCT(tuple); 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 * There are a couple of cases where we must override the information
...@@ -479,7 +485,7 @@ BuildDescForRelation(List *schema) ...@@ -479,7 +485,7 @@ BuildDescForRelation(List *schema)
* allocate a new tuple descriptor * allocate a new tuple descriptor
*/ */
natts = length(schema); natts = length(schema);
desc = CreateTemplateTupleDesc(natts); desc = CreateTemplateTupleDesc(natts, UNDEFOID);
constr->has_not_null = false; constr->has_not_null = false;
attnum = 0; attnum = 0;
...@@ -646,7 +652,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases) ...@@ -646,7 +652,7 @@ TypeGetTupleDesc(Oid typeoid, List *colaliases)
/* OK, get the column alias */ /* OK, get the column alias */
attname = strVal(lfirst(colaliases)); attname = strVal(lfirst(colaliases));
tupdesc = CreateTemplateTupleDesc(1); tupdesc = CreateTemplateTupleDesc(1, WITHOUTOID);
TupleDescInitEntry(tupdesc, TupleDescInitEntry(tupdesc,
(AttrNumber) 1, (AttrNumber) 1,
attname, attname,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.141 2002/07/02 05:48:44 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.142 2002/07/20 05:16:56 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -1116,10 +1116,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid) ...@@ -1116,10 +1116,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
* to support a persistent object store (objects need to contain * to support a persistent object store (objects need to contain
* pointers to one another). * pointers to one another).
*/ */
if (!OidIsValid(tup->t_data->t_oid)) AssertTupleDescHasOid(relation->rd_att);
tup->t_data->t_oid = newoid(); if (!OidIsValid(HeapTupleGetOid(tup)))
HeapTupleSetOid(tup, newoid());
else else
CheckMaxObjectId(tup->t_data->t_oid); CheckMaxObjectId(HeapTupleGetOid(tup));
} }
HeapTupleHeaderSetXmin(tup->t_data, GetCurrentTransactionId()); HeapTupleHeaderSetXmin(tup->t_data, GetCurrentTransactionId());
...@@ -1166,7 +1167,13 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid) ...@@ -1166,7 +1167,13 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
rdata[0].len = SizeOfHeapInsert; rdata[0].len = SizeOfHeapInsert;
rdata[0].next = &(rdata[1]); rdata[0].next = &(rdata[1]);
xlhdr.t_oid = tup->t_data->t_oid; if (relation->rd_rel->relhasoids)
{
AssertTupleDescHasOid(relation->rd_att);
xlhdr.t_oid = HeapTupleGetOid(tup);
}
else
xlhdr.t_oid = InvalidOid;
xlhdr.t_natts = tup->t_data->t_natts; xlhdr.t_natts = tup->t_data->t_natts;
xlhdr.t_hoff = tup->t_data->t_hoff; xlhdr.t_hoff = tup->t_data->t_hoff;
xlhdr.mask = tup->t_data->t_infomask; xlhdr.mask = tup->t_data->t_infomask;
...@@ -1176,6 +1183,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid) ...@@ -1176,6 +1183,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
rdata[1].next = &(rdata[2]); rdata[1].next = &(rdata[2]);
rdata[2].buffer = buffer; rdata[2].buffer = buffer;
/* PG73FORMAT: write bitmap [+ padding] [+ oid] + data */
rdata[2].data = (char *) tup->t_data + offsetof(HeapTupleHeaderData, t_bits); rdata[2].data = (char *) tup->t_data + offsetof(HeapTupleHeaderData, t_bits);
rdata[2].len = tup->t_len - offsetof(HeapTupleHeaderData, t_bits); rdata[2].len = tup->t_len - offsetof(HeapTupleHeaderData, t_bits);
rdata[2].next = NULL; rdata[2].next = NULL;
...@@ -1206,7 +1214,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid) ...@@ -1206,7 +1214,11 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
*/ */
CacheInvalidateHeapTuple(relation, tup); CacheInvalidateHeapTuple(relation, tup);
return tup->t_data->t_oid; if (!relation->rd_rel->relhasoids)
return InvalidOid;
AssertTupleDescHasOid(relation->rd_att);
return HeapTupleGetOid(tup);
} }
/* /*
...@@ -1499,7 +1511,11 @@ l2: ...@@ -1499,7 +1511,11 @@ l2:
} }
/* Fill in OID and transaction status data for newtup */ /* Fill in OID and transaction status data for newtup */
newtup->t_data->t_oid = oldtup.t_data->t_oid; if (relation->rd_rel->relhasoids)
{
AssertTupleDescHasOid(relation->rd_att);
HeapTupleSetOid(newtup, HeapTupleGetOid(&oldtup));
}
newtup->t_data->t_infomask &= ~(HEAP_XACT_MASK); newtup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
newtup->t_data->t_infomask |= (HEAP_XMAX_INVALID | HEAP_UPDATED); newtup->t_data->t_infomask |= (HEAP_XMAX_INVALID | HEAP_UPDATED);
HeapTupleHeaderSetXmin(newtup->t_data, GetCurrentTransactionId()); HeapTupleHeaderSetXmin(newtup->t_data, GetCurrentTransactionId());
...@@ -1972,24 +1988,28 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from, ...@@ -1972,24 +1988,28 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from,
rdata[1].len = 0; rdata[1].len = 0;
rdata[1].next = &(rdata[2]); rdata[1].next = &(rdata[2]);
xlhdr.hdr.t_oid = newtup->t_data->t_oid; if (reln->rd_rel->relhasoids)
{
AssertTupleDescHasOid(reln->rd_att);
xlhdr.hdr.t_oid = HeapTupleGetOid(newtup);
}
else
xlhdr.hdr.t_oid = InvalidOid;
xlhdr.hdr.t_natts = newtup->t_data->t_natts; xlhdr.hdr.t_natts = newtup->t_data->t_natts;
xlhdr.hdr.t_hoff = newtup->t_data->t_hoff; xlhdr.hdr.t_hoff = newtup->t_data->t_hoff;
xlhdr.hdr.mask = newtup->t_data->t_infomask; xlhdr.hdr.mask = newtup->t_data->t_infomask;
if (move) /* remember xmin & xmax */ if (move) /* remember xmin & xmax */
{ {
TransactionId xmax; TransactionId xid[2]; /* xmax, xmin */
TransactionId xmin;
if (newtup->t_data->t_infomask & HEAP_XMAX_INVALID || if (newtup->t_data->t_infomask & (HEAP_XMAX_INVALID |
newtup->t_data->t_infomask & HEAP_MARKED_FOR_UPDATE) HEAP_MARKED_FOR_UPDATE))
xmax = InvalidTransactionId; xid[0] = InvalidTransactionId;
else else
xmax = HeapTupleHeaderGetXmax(newtup->t_data); xid[0] = HeapTupleHeaderGetXmax(newtup->t_data);
xmin = HeapTupleHeaderGetXmin(newtup->t_data); xid[1] = HeapTupleHeaderGetXmin(newtup->t_data);
memcpy((char *) &xlhdr + hsize, &xmax, sizeof(TransactionId)); memcpy((char *) &xlhdr + hsize,
memcpy((char *) &xlhdr + hsize + sizeof(TransactionId), (char *) xid, 2 * sizeof(TransactionId));
&xmin, sizeof(TransactionId));
hsize += 2 * sizeof(TransactionId); hsize += 2 * sizeof(TransactionId);
} }
rdata[2].buffer = newbuf; rdata[2].buffer = newbuf;
...@@ -1998,6 +2018,7 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from, ...@@ -1998,6 +2018,7 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from,
rdata[2].next = &(rdata[3]); rdata[2].next = &(rdata[3]);
rdata[3].buffer = newbuf; rdata[3].buffer = newbuf;
/* PG73FORMAT: write bitmap [+ padding] [+ oid] + data */
rdata[3].data = (char *) newtup->t_data + offsetof(HeapTupleHeaderData, t_bits); rdata[3].data = (char *) newtup->t_data + offsetof(HeapTupleHeaderData, t_bits);
rdata[3].len = newtup->t_len - offsetof(HeapTupleHeaderData, t_bits); rdata[3].len = newtup->t_len - offsetof(HeapTupleHeaderData, t_bits);
rdata[3].next = NULL; rdata[3].next = NULL;
...@@ -2193,12 +2214,13 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -2193,12 +2214,13 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record)
memcpy((char *) &xlhdr, memcpy((char *) &xlhdr,
(char *) xlrec + SizeOfHeapInsert, (char *) xlrec + SizeOfHeapInsert,
SizeOfHeapHeader); SizeOfHeapHeader);
htup = &tbuf.hdr;
MemSet((char *) htup, 0, sizeof(HeapTupleHeaderData));
/* PG73FORMAT: get bitmap [+ padding] [+ oid] + data */
memcpy((char *) &tbuf + offsetof(HeapTupleHeaderData, t_bits), memcpy((char *) &tbuf + offsetof(HeapTupleHeaderData, t_bits),
(char *) xlrec + SizeOfHeapInsert + SizeOfHeapHeader, (char *) xlrec + SizeOfHeapInsert + SizeOfHeapHeader,
newlen); newlen);
newlen += offsetof(HeapTupleHeaderData, t_bits); newlen += offsetof(HeapTupleHeaderData, t_bits);
htup = &tbuf.hdr;
htup->t_oid = xlhdr.t_oid;
htup->t_natts = xlhdr.t_natts; htup->t_natts = xlhdr.t_natts;
htup->t_hoff = xlhdr.t_hoff; htup->t_hoff = xlhdr.t_hoff;
htup->t_infomask = HEAP_XMAX_INVALID | xlhdr.mask; htup->t_infomask = HEAP_XMAX_INVALID | xlhdr.mask;
...@@ -2206,6 +2228,11 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record) ...@@ -2206,6 +2228,11 @@ heap_xlog_insert(bool redo, XLogRecPtr lsn, XLogRecord *record)
HeapTupleHeaderSetCmin(htup, FirstCommandId); HeapTupleHeaderSetCmin(htup, FirstCommandId);
HeapTupleHeaderSetXmaxInvalid(htup); HeapTupleHeaderSetXmaxInvalid(htup);
HeapTupleHeaderSetCmax(htup, FirstCommandId); HeapTupleHeaderSetCmax(htup, FirstCommandId);
if (reln->rd_rel->relhasoids)
{
AssertTupleDescHasOid(reln->rd_att);
HeapTupleHeaderSetOid(htup, xlhdr.t_oid);
}
offnum = PageAddItem(page, (Item) htup, newlen, offnum, offnum = PageAddItem(page, (Item) htup, newlen, offnum,
LP_USED | OverwritePageMode); LP_USED | OverwritePageMode);
...@@ -2362,28 +2389,33 @@ newsame:; ...@@ -2362,28 +2389,33 @@ newsame:;
memcpy((char *) &xlhdr, memcpy((char *) &xlhdr,
(char *) xlrec + SizeOfHeapUpdate, (char *) xlrec + SizeOfHeapUpdate,
SizeOfHeapHeader); SizeOfHeapHeader);
htup = &tbuf.hdr;
MemSet((char *) htup, 0, sizeof(HeapTupleHeaderData));
/* PG73FORMAT: get bitmap [+ padding] [+ oid] + data */
memcpy((char *) &tbuf + offsetof(HeapTupleHeaderData, t_bits), memcpy((char *) &tbuf + offsetof(HeapTupleHeaderData, t_bits),
(char *) xlrec + hsize, (char *) xlrec + hsize,
newlen); newlen);
newlen += offsetof(HeapTupleHeaderData, t_bits); newlen += offsetof(HeapTupleHeaderData, t_bits);
htup = &tbuf.hdr;
htup->t_oid = xlhdr.t_oid;
htup->t_natts = xlhdr.t_natts; htup->t_natts = xlhdr.t_natts;
htup->t_hoff = xlhdr.t_hoff; htup->t_hoff = xlhdr.t_hoff;
if (reln->rd_rel->relhasoids)
{
AssertTupleDescHasOid(reln->rd_att);
HeapTupleHeaderSetOid(htup, xlhdr.t_oid);
}
if (move) if (move)
{ {
TransactionId xmax; TransactionId xid[2]; /* xmax, xmin */
TransactionId xmin;
hsize = SizeOfHeapUpdate + SizeOfHeapHeader; hsize = SizeOfHeapUpdate + SizeOfHeapHeader;
memcpy(&xmax, (char *) xlrec + hsize, sizeof(TransactionId)); memcpy((char *) xid,
memcpy(&xmin, (char *) xlrec + hsize + sizeof(TransactionId), sizeof(TransactionId)); (char *) xlrec + hsize, 2 * sizeof(TransactionId));
htup->t_infomask = xlhdr.mask; htup->t_infomask = xlhdr.mask;
htup->t_infomask &= ~(HEAP_XMIN_COMMITTED | htup->t_infomask &= ~(HEAP_XMIN_COMMITTED |
HEAP_XMIN_INVALID | HEAP_MOVED_OFF); HEAP_XMIN_INVALID | HEAP_MOVED_OFF);
htup->t_infomask |= HEAP_MOVED_IN; htup->t_infomask |= HEAP_MOVED_IN;
HeapTupleHeaderSetXmin(htup, xmin); HeapTupleHeaderSetXmin(htup, xid[1]);
HeapTupleHeaderSetXmax(htup, xmax); HeapTupleHeaderSetXmax(htup, xid[0]);
HeapTupleHeaderSetXvac(htup, record->xl_xid); HeapTupleHeaderSetXvac(htup, record->xl_xid);
} }
else else
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.32 2002/05/27 19:53:33 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.33 2002/07/20 05:16:56 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -726,6 +726,8 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup) ...@@ -726,6 +726,8 @@ toast_insert_or_update(Relation rel, HeapTuple newtup, HeapTuple oldtup)
new_len = offsetof(HeapTupleHeaderData, t_bits); new_len = offsetof(HeapTupleHeaderData, t_bits);
if (has_nulls) if (has_nulls)
new_len += BITMAPLEN(numAttrs); new_len += BITMAPLEN(numAttrs);
if (rel->rd_rel->relhasoids)
new_len += sizeof(Oid);
new_len = MAXALIGN(new_len); new_len = MAXALIGN(new_len);
Assert(new_len == olddata->t_hoff); Assert(new_len == olddata->t_hoff);
new_len += ComputeDataSize(tupleDesc, toast_values, toast_nulls); new_len += ComputeDataSize(tupleDesc, toast_values, toast_nulls);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.49 2002/07/12 18:43:13 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.50 2002/07/20 05:16:56 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -179,13 +179,13 @@ Boot_CreateStmt: ...@@ -179,13 +179,13 @@ Boot_CreateStmt:
} }
tupdesc = CreateTupleDesc(numattr, attrtypes); tupdesc = CreateTupleDesc(numattr, attrtypes);
tupdesc->tdhasoid = BoolToHasOid(! ($4));
boot_reldesc = heap_create(LexIDStr($5), boot_reldesc = heap_create(LexIDStr($5),
PG_CATALOG_NAMESPACE, PG_CATALOG_NAMESPACE,
tupdesc, tupdesc,
$3, $3,
true, true,
true); true);
boot_reldesc->rd_rel->relhasoids = ! ($4);
elog(DEBUG3, "bootstrap relation created"); elog(DEBUG3, "bootstrap relation created");
} }
else else
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.132 2002/06/20 20:29:26 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.133 2002/07/20 05:16:56 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -495,7 +495,8 @@ boot_openrel(char *relname) ...@@ -495,7 +495,8 @@ boot_openrel(char *relname)
app = Typ; app = Typ;
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL) while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
{ {
(*app)->am_oid = tup->t_data->t_oid; AssertTupleDescHasOid(rel->rd_att);
(*app)->am_oid = HeapTupleGetOid(tup);
memcpy((char *) &(*app)->am_typ, memcpy((char *) &(*app)->am_typ,
(char *) GETSTRUCT(tup), (char *) GETSTRUCT(tup),
sizeof((*app)->am_typ)); sizeof((*app)->am_typ));
...@@ -675,11 +676,15 @@ InsertOneTuple(Oid objectid) ...@@ -675,11 +676,15 @@ InsertOneTuple(Oid objectid)
elog(DEBUG3, "inserting row oid %u, %d columns", objectid, numattr); elog(DEBUG3, "inserting row oid %u, %d columns", objectid, numattr);
tupDesc = CreateTupleDesc(numattr, attrtypes); tupDesc = CreateTupleDesc(numattr, attrtypes);
tupDesc->tdhasoid = BoolToHasOid(RelationGetForm(boot_reldesc)->relhasoids);
tuple = heap_formtuple(tupDesc, values, Blanks); tuple = heap_formtuple(tupDesc, values, Blanks);
pfree(tupDesc); /* just free's tupDesc, not the attrtypes */
if (objectid != (Oid) 0) if (objectid != (Oid) 0)
tuple->t_data->t_oid = objectid; {
AssertTupleDescHasOid(tupDesc);
HeapTupleSetOid(tuple, objectid);
}
pfree(tupDesc); /* just free's tupDesc, not the attrtypes */
simple_heap_insert(boot_reldesc, tuple); simple_heap_insert(boot_reldesc, tuple);
heap_freetuple(tuple); heap_freetuple(tuple);
elog(DEBUG3, "row inserted"); elog(DEBUG3, "row inserted");
...@@ -871,7 +876,8 @@ gettype(char *type) ...@@ -871,7 +876,8 @@ gettype(char *type)
app = Typ; app = Typ;
while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL) while ((tup = heap_getnext(scan, ForwardScanDirection)) != NULL)
{ {
(*app)->am_oid = tup->t_data->t_oid; AssertTupleDescHasOid(rel->rd_att);
(*app)->am_oid = HeapTupleGetOid(tup);
memmove((char *) &(*app++)->am_typ, memmove((char *) &(*app++)->am_typ,
(char *) GETSTRUCT(tup), (char *) GETSTRUCT(tup),
sizeof((*app)->am_typ)); sizeof((*app)->am_typ));
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.70 2002/07/18 04:50:10 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.71 2002/07/20 05:16:56 momjian Exp $
* *
* NOTES * NOTES
* See acl.h. * See acl.h.
...@@ -592,7 +592,8 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt) ...@@ -592,7 +592,8 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt)
elog(ERROR, "namespace \"%s\" not found", nspname); elog(ERROR, "namespace \"%s\" not found", nspname);
pg_namespace_tuple = (Form_pg_namespace) GETSTRUCT(tuple); pg_namespace_tuple = (Form_pg_namespace) GETSTRUCT(tuple);
if (!pg_namespace_ownercheck(tuple->t_data->t_oid, GetUserId())) AssertTupleDescHasOid(relation->rd_att);
if (!pg_namespace_ownercheck(HeapTupleGetOid(tuple), GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, nspname); aclcheck_error(ACLCHECK_NOT_OWNER, nspname);
/* /*
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.211 2002/07/19 22:21:17 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.212 2002/07/20 05:16:56 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
static void AddNewRelationTuple(Relation pg_class_desc, static void AddNewRelationTuple(Relation pg_class_desc,
Relation new_rel_desc, Relation new_rel_desc,
Oid new_rel_oid, Oid new_type_oid, Oid new_rel_oid, Oid new_type_oid,
char relkind, bool relhasoids); char relkind);
static void AddNewRelationType(const char *typeName, static void AddNewRelationType(const char *typeName,
Oid typeNamespace, Oid typeNamespace,
Oid new_rel_oid, Oid new_rel_oid,
...@@ -445,6 +445,7 @@ AddNewAttributeTuples(Oid new_rel_oid, ...@@ -445,6 +445,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
(*dpp)->attcacheoff = -1; (*dpp)->attcacheoff = -1;
tup = heap_addheader(Natts_pg_attribute, tup = heap_addheader(Natts_pg_attribute,
false,
ATTRIBUTE_TUPLE_SIZE, ATTRIBUTE_TUPLE_SIZE,
(void *) *dpp); (void *) *dpp);
...@@ -481,6 +482,7 @@ AddNewAttributeTuples(Oid new_rel_oid, ...@@ -481,6 +482,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
Form_pg_attribute attStruct; Form_pg_attribute attStruct;
tup = heap_addheader(Natts_pg_attribute, tup = heap_addheader(Natts_pg_attribute,
false,
ATTRIBUTE_TUPLE_SIZE, ATTRIBUTE_TUPLE_SIZE,
(void *) *dpp); (void *) *dpp);
...@@ -527,8 +529,7 @@ AddNewRelationTuple(Relation pg_class_desc, ...@@ -527,8 +529,7 @@ AddNewRelationTuple(Relation pg_class_desc,
Relation new_rel_desc, Relation new_rel_desc,
Oid new_rel_oid, Oid new_rel_oid,
Oid new_type_oid, Oid new_type_oid,
char relkind, char relkind)
bool relhasoids)
{ {
Form_pg_class new_rel_reltup; Form_pg_class new_rel_reltup;
HeapTuple tup; HeapTuple tup;
...@@ -579,7 +580,6 @@ AddNewRelationTuple(Relation pg_class_desc, ...@@ -579,7 +580,6 @@ AddNewRelationTuple(Relation pg_class_desc,
new_rel_reltup->relowner = GetUserId(); new_rel_reltup->relowner = GetUserId();
new_rel_reltup->reltype = new_type_oid; new_rel_reltup->reltype = new_type_oid;
new_rel_reltup->relkind = relkind; new_rel_reltup->relkind = relkind;
new_rel_reltup->relhasoids = relhasoids;
/* ---------------- /* ----------------
* now form a tuple to add to pg_class * now form a tuple to add to pg_class
...@@ -587,11 +587,13 @@ AddNewRelationTuple(Relation pg_class_desc, ...@@ -587,11 +587,13 @@ AddNewRelationTuple(Relation pg_class_desc,
* ---------------- * ----------------
*/ */
tup = heap_addheader(Natts_pg_class_fixed, tup = heap_addheader(Natts_pg_class_fixed,
true,
CLASS_TUPLE_SIZE, CLASS_TUPLE_SIZE,
(void *) new_rel_reltup); (void *) new_rel_reltup);
/* force tuple to have the desired OID */ /* force tuple to have the desired OID */
tup->t_data->t_oid = new_rel_oid; AssertTupleDescHasOid(pg_class_desc->rd_att);
HeapTupleSetOid(tup, new_rel_oid);
/* /*
* finally insert the new tuple and free it. * finally insert the new tuple and free it.
...@@ -691,6 +693,8 @@ heap_create_with_catalog(const char *relname, ...@@ -691,6 +693,8 @@ heap_create_with_catalog(const char *relname,
if (get_relname_relid(relname, relnamespace)) if (get_relname_relid(relname, relnamespace))
elog(ERROR, "Relation '%s' already exists", relname); elog(ERROR, "Relation '%s' already exists", relname);
tupdesc->tdhasoid = BoolToHasOid(relhasoids);
/* /*
* Tell heap_create not to create a physical file; we'll do that below * Tell heap_create not to create a physical file; we'll do that below
* after all our catalog updates are done. (This isn't really * after all our catalog updates are done. (This isn't really
...@@ -723,8 +727,7 @@ heap_create_with_catalog(const char *relname, ...@@ -723,8 +727,7 @@ heap_create_with_catalog(const char *relname,
new_rel_desc, new_rel_desc,
new_rel_oid, new_rel_oid,
new_type_oid, new_type_oid,
relkind, relkind);
relhasoids);
/* /*
* since defining a relation also defines a complex type, we add a new * since defining a relation also defines a complex type, we add a new
...@@ -920,13 +923,14 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum, ...@@ -920,13 +923,14 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum,
scan = systable_beginscan(attrdef_rel, AttrDefaultIndex, true, scan = systable_beginscan(attrdef_rel, AttrDefaultIndex, true,
SnapshotNow, 2, scankeys); SnapshotNow, 2, scankeys);
AssertTupleDescHasOid(attrdef_rel->rd_att);
/* There should be at most one matching tuple, but we loop anyway */ /* There should be at most one matching tuple, but we loop anyway */
while (HeapTupleIsValid(tuple = systable_getnext(scan))) while (HeapTupleIsValid(tuple = systable_getnext(scan)))
{ {
ObjectAddress object; ObjectAddress object;
object.classId = RelationGetRelid(attrdef_rel); object.classId = RelationGetRelid(attrdef_rel);
object.objectId = tuple->t_data->t_oid; object.objectId = HeapTupleGetOid(tuple);
object.objectSubId = 0; object.objectSubId = 0;
performDeletion(&object, behavior); performDeletion(&object, behavior);
...@@ -1711,6 +1715,7 @@ RemoveRelConstraints(Relation rel, const char *constrName, ...@@ -1711,6 +1715,7 @@ RemoveRelConstraints(Relation rel, const char *constrName,
conscan = systable_beginscan(conrel, ConstraintRelidIndex, true, conscan = systable_beginscan(conrel, ConstraintRelidIndex, true,
SnapshotNow, 1, key); SnapshotNow, 1, key);
AssertTupleDescHasOid(conrel->rd_att);
/* /*
* Scan over the result set, removing any matching entries. * Scan over the result set, removing any matching entries.
*/ */
...@@ -1723,7 +1728,7 @@ RemoveRelConstraints(Relation rel, const char *constrName, ...@@ -1723,7 +1728,7 @@ RemoveRelConstraints(Relation rel, const char *constrName,
ObjectAddress conobj; ObjectAddress conobj;
conobj.classId = RelationGetRelid(conrel); conobj.classId = RelationGetRelid(conrel);
conobj.objectId = contup->t_data->t_oid; conobj.objectId = HeapTupleGetOid(contup);
conobj.objectSubId = 0; conobj.objectSubId = 0;
performDeletion(&conobj, behavior); performDeletion(&conobj, behavior);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.185 2002/07/18 16:47:23 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.186 2002/07/20 05:16:56 momjian Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -111,7 +111,7 @@ BuildFuncTupleDesc(Oid funcOid, ...@@ -111,7 +111,7 @@ BuildFuncTupleDesc(Oid funcOid,
/* /*
* Allocate and zero a tuple descriptor for a one-column tuple. * Allocate and zero a tuple descriptor for a one-column tuple.
*/ */
funcTupDesc = CreateTemplateTupleDesc(1); funcTupDesc = CreateTemplateTupleDesc(1, UNDEFOID);
funcTupDesc->attrs[0] = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE); funcTupDesc->attrs[0] = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE);
MemSet(funcTupDesc->attrs[0], 0, ATTRIBUTE_TUPLE_SIZE); MemSet(funcTupDesc->attrs[0], 0, ATTRIBUTE_TUPLE_SIZE);
...@@ -199,7 +199,7 @@ ConstructTupleDescriptor(Relation heapRelation, ...@@ -199,7 +199,7 @@ ConstructTupleDescriptor(Relation heapRelation,
* allocate the new tuple descriptor * allocate the new tuple descriptor
*/ */
indexTupDesc = CreateTemplateTupleDesc(numatts); indexTupDesc = CreateTemplateTupleDesc(numatts, WITHOUTOID);
/* ---------------- /* ----------------
* for each attribute we are indexing, obtain its attribute * for each attribute we are indexing, obtain its attribute
...@@ -320,6 +320,7 @@ UpdateRelationRelation(Relation indexRelation) ...@@ -320,6 +320,7 @@ UpdateRelationRelation(Relation indexRelation)
/* XXX Natts_pg_class_fixed is a hack - see pg_class.h */ /* XXX Natts_pg_class_fixed is a hack - see pg_class.h */
tuple = heap_addheader(Natts_pg_class_fixed, tuple = heap_addheader(Natts_pg_class_fixed,
true,
CLASS_TUPLE_SIZE, CLASS_TUPLE_SIZE,
(void *) indexRelation->rd_rel); (void *) indexRelation->rd_rel);
...@@ -327,7 +328,8 @@ UpdateRelationRelation(Relation indexRelation) ...@@ -327,7 +328,8 @@ UpdateRelationRelation(Relation indexRelation)
* the new tuple must have the oid already chosen for the index. * the new tuple must have the oid already chosen for the index.
* sure would be embarrassing to do this sort of thing in polite company. * sure would be embarrassing to do this sort of thing in polite company.
*/ */
tuple->t_data->t_oid = RelationGetRelid(indexRelation); AssertTupleDescHasOid(pg_class->rd_att);
HeapTupleSetOid(tuple, RelationGetRelid(indexRelation));
simple_heap_insert(pg_class, tuple); simple_heap_insert(pg_class, tuple);
/* /*
...@@ -406,6 +408,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts) ...@@ -406,6 +408,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts)
Assert(indexTupDesc->attrs[i]->attcacheoff == -1); Assert(indexTupDesc->attrs[i]->attcacheoff == -1);
new_tuple = heap_addheader(Natts_pg_attribute, new_tuple = heap_addheader(Natts_pg_attribute,
false,
ATTRIBUTE_TUPLE_SIZE, ATTRIBUTE_TUPLE_SIZE,
(void *) indexTupDesc->attrs[i]); (void *) indexTupDesc->attrs[i]);
...@@ -495,6 +498,7 @@ UpdateIndexRelation(Oid indexoid, ...@@ -495,6 +498,7 @@ UpdateIndexRelation(Oid indexoid,
* form a tuple to insert into pg_index * form a tuple to insert into pg_index
*/ */
tuple = heap_addheader(Natts_pg_index, tuple = heap_addheader(Natts_pg_index,
false,
itupLen, itupLen,
(void *) indexForm); (void *) indexForm);
...@@ -599,6 +603,7 @@ index_create(Oid heapRelationId, ...@@ -599,6 +603,7 @@ index_create(Oid heapRelationId,
indexInfo->ii_KeyAttrNumbers, indexInfo->ii_KeyAttrNumbers,
classObjectId); classObjectId);
indexTupDesc->tdhasoid = WITHOUTOID;
/* /*
* create the index relation (but don't create storage yet) * create the index relation (but don't create storage yet)
*/ */
...@@ -626,7 +631,7 @@ index_create(Oid heapRelationId, ...@@ -626,7 +631,7 @@ index_create(Oid heapRelationId,
indexRelation->rd_rel->relowner = GetUserId(); indexRelation->rd_rel->relowner = GetUserId();
indexRelation->rd_rel->relam = accessMethodObjectId; indexRelation->rd_rel->relam = accessMethodObjectId;
indexRelation->rd_rel->relkind = RELKIND_INDEX; indexRelation->rd_rel->relkind = RELKIND_INDEX;
indexRelation->rd_rel->relhasoids = false; indexRelation->rd_rel->relhasoids = false; /* WITHOUTOID! */
/* /*
* store index's pg_class entry * store index's pg_class entry
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.25 2002/07/16 06:58:14 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.26 2002/07/20 05:16:56 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -571,7 +571,7 @@ FuncnameGetCandidates(List *names, int nargs) ...@@ -571,7 +571,7 @@ FuncnameGetCandidates(List *names, int nargs)
continue; /* keep previous result */ continue; /* keep previous result */
/* replace previous result */ /* replace previous result */
prevResult->pathpos = pathpos; prevResult->pathpos = pathpos;
prevResult->oid = proctup->t_data->t_oid; prevResult->oid = HeapTupleGetOid(proctup);
continue; /* args are same, of course */ continue; /* args are same, of course */
} }
} }
...@@ -584,7 +584,7 @@ FuncnameGetCandidates(List *names, int nargs) ...@@ -584,7 +584,7 @@ FuncnameGetCandidates(List *names, int nargs)
palloc(sizeof(struct _FuncCandidateList) - sizeof(Oid) palloc(sizeof(struct _FuncCandidateList) - sizeof(Oid)
+ nargs * sizeof(Oid)); + nargs * sizeof(Oid));
newResult->pathpos = pathpos; newResult->pathpos = pathpos;
newResult->oid = proctup->t_data->t_oid; newResult->oid = HeapTupleGetOid(proctup);
newResult->nargs = nargs; newResult->nargs = nargs;
memcpy(newResult->args, procform->proargtypes, nargs * sizeof(Oid)); memcpy(newResult->args, procform->proargtypes, nargs * sizeof(Oid));
...@@ -818,7 +818,7 @@ OpernameGetCandidates(List *names, char oprkind) ...@@ -818,7 +818,7 @@ OpernameGetCandidates(List *names, char oprkind)
continue; /* keep previous result */ continue; /* keep previous result */
/* replace previous result */ /* replace previous result */
prevResult->pathpos = pathpos; prevResult->pathpos = pathpos;
prevResult->oid = opertup->t_data->t_oid; prevResult->oid = HeapTupleGetOid(opertup);
continue; /* args are same, of course */ continue; /* args are same, of course */
} }
} }
...@@ -830,7 +830,7 @@ OpernameGetCandidates(List *names, char oprkind) ...@@ -830,7 +830,7 @@ OpernameGetCandidates(List *names, char oprkind)
newResult = (FuncCandidateList) newResult = (FuncCandidateList)
palloc(sizeof(struct _FuncCandidateList) + sizeof(Oid)); palloc(sizeof(struct _FuncCandidateList) + sizeof(Oid));
newResult->pathpos = pathpos; newResult->pathpos = pathpos;
newResult->oid = opertup->t_data->t_oid; newResult->oid = HeapTupleGetOid(opertup);
newResult->nargs = 2; newResult->nargs = 2;
newResult->args[0] = operform->oprleft; newResult->args[0] = operform->oprleft;
newResult->args[1] = operform->oprright; newResult->args[1] = operform->oprright;
...@@ -994,7 +994,7 @@ OpclassGetCandidates(Oid amid) ...@@ -994,7 +994,7 @@ OpclassGetCandidates(Oid amid)
/* replace previous result */ /* replace previous result */
prevResult->opcname_tmp = NameStr(opcform->opcname); prevResult->opcname_tmp = NameStr(opcform->opcname);
prevResult->pathpos = pathpos; prevResult->pathpos = pathpos;
prevResult->oid = opctup->t_data->t_oid; prevResult->oid = HeapTupleGetOid(opctup);
prevResult->opcintype = opcform->opcintype; prevResult->opcintype = opcform->opcintype;
prevResult->opcdefault = opcform->opcdefault; prevResult->opcdefault = opcform->opcdefault;
prevResult->opckeytype = opcform->opckeytype; prevResult->opckeytype = opcform->opckeytype;
...@@ -1009,7 +1009,7 @@ OpclassGetCandidates(Oid amid) ...@@ -1009,7 +1009,7 @@ OpclassGetCandidates(Oid amid)
palloc(sizeof(struct _OpclassCandidateList)); palloc(sizeof(struct _OpclassCandidateList));
newResult->opcname_tmp = NameStr(opcform->opcname); newResult->opcname_tmp = NameStr(opcform->opcname);
newResult->pathpos = pathpos; newResult->pathpos = pathpos;
newResult->oid = opctup->t_data->t_oid; newResult->oid = HeapTupleGetOid(opctup);
newResult->opcintype = opcform->opcintype; newResult->opcintype = opcform->opcintype;
newResult->opcdefault = opcform->opcdefault; newResult->opcdefault = opcform->opcdefault;
newResult->opckeytype = opcform->opckeytype; newResult->opckeytype = opcform->opckeytype;
...@@ -1572,8 +1572,9 @@ RemoveTempRelations(Oid tempNamespaceId) ...@@ -1572,8 +1572,9 @@ RemoveTempRelations(Oid tempNamespaceId)
case RELKIND_RELATION: case RELKIND_RELATION:
case RELKIND_SEQUENCE: case RELKIND_SEQUENCE:
case RELKIND_VIEW: case RELKIND_VIEW:
AssertTupleDescHasOid(pgclass->rd_att);
object.classId = RelOid_pg_class; object.classId = RelOid_pg_class;
object.objectId = tuple->t_data->t_oid; object.objectId = HeapTupleGetOid(tuple);
object.objectSubId = 0; object.objectSubId = 0;
performDeletion(&object, DROP_CASCADE); performDeletion(&object, DROP_CASCADE);
break; break;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.72 2002/07/18 16:47:23 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.73 2002/07/20 05:16:56 momjian Exp $
* *
* NOTES * NOTES
* these routines moved here from commands/define.c and somewhat cleaned up. * these routines moved here from commands/define.c and somewhat cleaned up.
...@@ -144,7 +144,7 @@ OperatorGet(const char *operatorName, ...@@ -144,7 +144,7 @@ OperatorGet(const char *operatorName,
{ {
RegProcedure oprcode = ((Form_pg_operator) GETSTRUCT(tup))->oprcode; RegProcedure oprcode = ((Form_pg_operator) GETSTRUCT(tup))->oprcode;
operatorObjectId = tup->t_data->t_oid; operatorObjectId = HeapTupleGetOid(tup);
*defined = RegProcedureIsValid(oprcode); *defined = RegProcedureIsValid(oprcode);
ReleaseSysCache(tup); ReleaseSysCache(tup);
} }
...@@ -918,7 +918,7 @@ makeOperatorDependencies(HeapTuple tuple, Oid pg_operator_relid) ...@@ -918,7 +918,7 @@ makeOperatorDependencies(HeapTuple tuple, Oid pg_operator_relid)
referenced; referenced;
myself.classId = pg_operator_relid; myself.classId = pg_operator_relid;
myself.objectId = tuple->t_data->t_oid; myself.objectId = HeapTupleGetOid(tuple);
myself.objectSubId = 0; myself.objectSubId = 0;
/* In case we are updating a shell, delete any existing entries */ /* In case we are updating a shell, delete any existing entries */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.79 2002/07/18 23:11:27 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.80 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -239,6 +239,7 @@ ProcedureCreate(const char *procedureName, ...@@ -239,6 +239,7 @@ ProcedureCreate(const char *procedureName,
/* start out with empty permissions */ /* start out with empty permissions */
nulls[Anum_pg_proc_proacl-1] = 'n'; nulls[Anum_pg_proc_proacl-1] = 'n';
AssertTupleDescHasOid(tupDesc);
tup = heap_formtuple(tupDesc, values, nulls); tup = heap_formtuple(tupDesc, values, nulls);
simple_heap_insert(rel, tup); simple_heap_insert(rel, tup);
is_update = false; is_update = false;
...@@ -254,7 +255,8 @@ ProcedureCreate(const char *procedureName, ...@@ -254,7 +255,8 @@ ProcedureCreate(const char *procedureName,
CatalogCloseIndices(Num_pg_proc_indices, idescs); CatalogCloseIndices(Num_pg_proc_indices, idescs);
} }
retval = tup->t_data->t_oid; AssertTupleDescHasOid(tupDesc);
retval = HeapTupleGetOid(tup);
/* /*
* Create dependencies for the new function. If we are updating an * Create dependencies for the new function. If we are updating an
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.74 2002/07/18 16:47:23 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.75 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -274,7 +274,8 @@ TypeCreate(const char *typeName, ...@@ -274,7 +274,8 @@ TypeCreate(const char *typeName,
simple_heap_update(pg_type_desc, &tup->t_self, tup); simple_heap_update(pg_type_desc, &tup->t_self, tup);
typeObjectId = tup->t_data->t_oid; AssertTupleDescHasOid(pg_type_desc->rd_att);
typeObjectId = HeapTupleGetOid(tup);
} }
else else
{ {
...@@ -285,7 +286,8 @@ TypeCreate(const char *typeName, ...@@ -285,7 +286,8 @@ TypeCreate(const char *typeName,
nulls); nulls);
/* preassign tuple Oid, if one was given */ /* preassign tuple Oid, if one was given */
tup->t_data->t_oid = assignedTypeOid; AssertTupleDescHasOid(tupDesc);
HeapTupleSetOid(tup, assignedTypeOid);
typeObjectId = simple_heap_insert(pg_type_desc, tup); typeObjectId = simple_heap_insert(pg_type_desc, tup);
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Copyright (c) 1996-2001, PostgreSQL Global Development Group * Copyright (c) 1996-2001, PostgreSQL Global Development Group
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.51 2002/07/14 23:38:13 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.52 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -435,7 +435,8 @@ CommentDatabase(List *qualname, char *comment) ...@@ -435,7 +435,8 @@ CommentDatabase(List *qualname, char *comment)
if (!HeapTupleIsValid(dbtuple)) if (!HeapTupleIsValid(dbtuple))
elog(ERROR, "database \"%s\" does not exist", database); elog(ERROR, "database \"%s\" does not exist", database);
oid = dbtuple->t_data->t_oid; AssertTupleDescHasOid(pg_database->rd_att);
oid = HeapTupleGetOid(dbtuple);
/* Allow if the user matches the database dba or is a superuser */ /* Allow if the user matches the database dba or is a superuser */
...@@ -481,7 +482,8 @@ CommentNamespace(List *qualname, char *comment) ...@@ -481,7 +482,8 @@ CommentNamespace(List *qualname, char *comment)
elog(ERROR, "CommentSchema: Schema \"%s\" could not be found", elog(ERROR, "CommentSchema: Schema \"%s\" could not be found",
namespace); namespace);
oid = tp->t_data->t_oid; /* no TupleDesc here to Assert(...->tdhasoid); */
oid = HeapTupleGetOid(tp);
/* Check object security */ /* Check object security */
if (!pg_namespace_ownercheck(oid, GetUserId())) if (!pg_namespace_ownercheck(oid, GetUserId()))
...@@ -552,7 +554,8 @@ CommentRule(List *qualname, char *comment) ...@@ -552,7 +554,8 @@ CommentRule(List *qualname, char *comment)
if (HeapTupleIsValid(tuple)) if (HeapTupleIsValid(tuple))
{ {
reloid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class; reloid = ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class;
ruleoid = tuple->t_data->t_oid; AssertTupleDescHasOid(RewriteRelation->rd_att);
ruleoid = HeapTupleGetOid(tuple);
} }
else else
{ {
...@@ -592,7 +595,8 @@ CommentRule(List *qualname, char *comment) ...@@ -592,7 +595,8 @@ CommentRule(List *qualname, char *comment)
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "rule \"%s\" does not exist", rulename); elog(ERROR, "rule \"%s\" does not exist", rulename);
Assert(reloid == ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class); Assert(reloid == ((Form_pg_rewrite) GETSTRUCT(tuple))->ev_class);
ruleoid = tuple->t_data->t_oid; AssertTupleDescHasOid(relation->rd_att);
ruleoid = HeapTupleGetOid(tuple);
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
} }
...@@ -805,7 +809,8 @@ CommentTrigger(List *qualname, char *comment) ...@@ -805,7 +809,8 @@ CommentTrigger(List *qualname, char *comment)
elog(ERROR, "trigger \"%s\" for relation \"%s\" does not exist", elog(ERROR, "trigger \"%s\" for relation \"%s\" does not exist",
trigname, RelationGetRelationName(relation)); trigname, RelationGetRelationName(relation));
oid = triggertuple->t_data->t_oid; AssertTupleDescHasOid(pg_trigger->rd_att);
oid = HeapTupleGetOid(triggertuple);
systable_endscan(scan); systable_endscan(scan);
...@@ -880,7 +885,7 @@ CommentConstraint(List *qualname, char *comment) ...@@ -880,7 +885,7 @@ CommentConstraint(List *qualname, char *comment)
if (OidIsValid(conOid)) if (OidIsValid(conOid))
elog(ERROR, "Relation \"%s\" has multiple constraints named \"%s\"", elog(ERROR, "Relation \"%s\" has multiple constraints named \"%s\"",
RelationGetRelationName(relation), conName); RelationGetRelationName(relation), conName);
conOid = tuple->t_data->t_oid; conOid = HeapTupleGetOid(tuple);
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.159 2002/07/18 04:43:50 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.160 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -614,9 +614,13 @@ CopyTo(Relation rel, List *attlist, bool binary, bool oids, ...@@ -614,9 +614,13 @@ CopyTo(Relation rel, List *attlist, bool binary, bool oids,
/* Send OID if wanted --- note fld_count doesn't include it */ /* Send OID if wanted --- note fld_count doesn't include it */
if (oids) if (oids)
{ {
Oid oid;
AssertTupleDescHasOid(tupDesc);
oid = HeapTupleGetOid(tuple);
fld_size = sizeof(Oid); fld_size = sizeof(Oid);
CopySendData(&fld_size, sizeof(int16), fp); CopySendData(&fld_size, sizeof(int16), fp);
CopySendData(&tuple->t_data->t_oid, sizeof(Oid), fp); CopySendData(&oid, sizeof(Oid), fp);
} }
} }
else else
...@@ -624,8 +628,9 @@ CopyTo(Relation rel, List *attlist, bool binary, bool oids, ...@@ -624,8 +628,9 @@ CopyTo(Relation rel, List *attlist, bool binary, bool oids,
/* Text format has no per-tuple header, but send OID if wanted */ /* Text format has no per-tuple header, but send OID if wanted */
if (oids) if (oids)
{ {
AssertTupleDescHasOid(tupDesc);
string = DatumGetCString(DirectFunctionCall1(oidout, string = DatumGetCString(DirectFunctionCall1(oidout,
ObjectIdGetDatum(tuple->t_data->t_oid))); ObjectIdGetDatum(HeapTupleGetOid(tuple))));
CopySendString(string, fp); CopySendString(string, fp);
pfree(string); pfree(string);
need_delim = true; need_delim = true;
...@@ -1069,7 +1074,7 @@ CopyFrom(Relation rel, List *attlist, bool binary, bool oids, ...@@ -1069,7 +1074,7 @@ CopyFrom(Relation rel, List *attlist, bool binary, bool oids,
tuple = heap_formtuple(tupDesc, values, nulls); tuple = heap_formtuple(tupDesc, values, nulls);
if (oids && file_has_oids) if (oids && file_has_oids)
tuple->t_data->t_oid = loaded_oid; HeapTupleSetOid(tuple, loaded_oid);
skip_tuple = false; skip_tuple = false;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.96 2002/07/12 18:43:15 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.97 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -341,7 +341,8 @@ createdb(const CreatedbStmt *stmt) ...@@ -341,7 +341,8 @@ createdb(const CreatedbStmt *stmt)
tuple = heap_formtuple(pg_database_dsc, new_record, new_record_nulls); tuple = heap_formtuple(pg_database_dsc, new_record, new_record_nulls);
tuple->t_data->t_oid = dboid; /* override heap_insert's OID AssertTupleDescHasOid(pg_database_dsc);
HeapTupleSetOid(tuple, dboid); /* override heap_insert's OID
* selection */ * selection */
simple_heap_insert(pg_database_rel, tuple); simple_heap_insert(pg_database_rel, tuple);
...@@ -616,7 +617,10 @@ get_db_info(const char *name, Oid *dbIdP, int4 *ownerIdP, ...@@ -616,7 +617,10 @@ get_db_info(const char *name, Oid *dbIdP, int4 *ownerIdP,
/* oid of the database */ /* oid of the database */
if (dbIdP) if (dbIdP)
*dbIdP = tuple->t_data->t_oid; {
AssertTupleDescHasOid(relation->rd_att);
*dbIdP = HeapTupleGetOid(tuple);
}
/* sysid of the owner */ /* sysid of the owner */
if (ownerIdP) if (ownerIdP)
*ownerIdP = dbform->datdba; *ownerIdP = dbform->datdba;
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994-5, Regents of the University of California * Portions Copyright (c) 1994-5, Regents of the University of California
* *
* $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.80 2002/06/20 20:29:27 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.81 2002/07/20 05:16:57 momjian Exp $
* *
*/ */
...@@ -855,7 +855,7 @@ begin_text_output(CommandDest dest, char *title) ...@@ -855,7 +855,7 @@ begin_text_output(CommandDest dest, char *title)
tstate = (TextOutputState *) palloc(sizeof(TextOutputState)); tstate = (TextOutputState *) palloc(sizeof(TextOutputState));
/* need a tuple descriptor representing a single TEXT column */ /* need a tuple descriptor representing a single TEXT column */
tupdesc = CreateTemplateTupleDesc(1); tupdesc = CreateTemplateTupleDesc(1, WITHOUTOID);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, title, TupleDescInitEntry(tupdesc, (AttrNumber) 1, title,
TEXTOID, -1, 0, false); TEXTOID, -1, 0, false);
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.9 2002/07/18 23:11:27 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.10 2002/07/20 05:16:57 momjian Exp $
* *
* DESCRIPTION * DESCRIPTION
* These routines take the parse tree and pick out the * These routines take the parse tree and pick out the
...@@ -425,7 +425,7 @@ CreateFunction(CreateFunctionStmt *stmt) ...@@ -425,7 +425,7 @@ CreateFunction(CreateFunctionStmt *stmt)
if (!HeapTupleIsValid(languageTuple)) if (!HeapTupleIsValid(languageTuple))
elog(ERROR, "language \"%s\" does not exist", languageName); elog(ERROR, "language \"%s\" does not exist", languageName);
languageOid = languageTuple->t_data->t_oid; languageOid = HeapTupleGetOid(languageTuple);
languageStruct = (Form_pg_language) GETSTRUCT(languageTuple); languageStruct = (Form_pg_language) GETSTRUCT(languageTuple);
if (languageStruct->lanpltrusted) if (languageStruct->lanpltrusted)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.77 2002/07/12 18:43:16 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.78 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -141,7 +141,7 @@ DefineIndex(RangeVar *heapRelation, ...@@ -141,7 +141,7 @@ DefineIndex(RangeVar *heapRelation,
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
elog(ERROR, "DefineIndex: access method \"%s\" not found", elog(ERROR, "DefineIndex: access method \"%s\" not found",
accessMethodName); accessMethodName);
accessMethodId = tuple->t_data->t_oid; accessMethodId = HeapTupleGetOid(tuple);
accessMethodForm = (Form_pg_am) GETSTRUCT(tuple); accessMethodForm = (Form_pg_am) GETSTRUCT(tuple);
if (unique && !accessMethodForm->amcanunique) if (unique && !accessMethodForm->amcanunique)
...@@ -496,7 +496,7 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType, ...@@ -496,7 +496,7 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType,
* Verify that the index operator class accepts this * Verify that the index operator class accepts this
* datatype. Note we will accept binary compatibility. * datatype. Note we will accept binary compatibility.
*/ */
opClassId = tuple->t_data->t_oid; opClassId = HeapTupleGetOid(tuple);
opInputType = ((Form_pg_opclass) GETSTRUCT(tuple))->opcintype; opInputType = ((Form_pg_opclass) GETSTRUCT(tuple))->opcintype;
if (!IsBinaryCompatible(attrType, opInputType)) if (!IsBinaryCompatible(attrType, opInputType))
...@@ -761,7 +761,7 @@ ReindexDatabase(const char *dbname, bool force, bool all) ...@@ -761,7 +761,7 @@ ReindexDatabase(const char *dbname, bool force, bool all)
relids = repalloc(relids, sizeof(Oid) * relalc); relids = repalloc(relids, sizeof(Oid) * relalc);
} }
MemoryContextSwitchTo(old); MemoryContextSwitchTo(old);
relids[relcnt] = tuple->t_data->t_oid; relids[relcnt] = HeapTupleGetOid(tuple);
relcnt++; relcnt++;
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.36 2002/07/16 22:12:19 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.37 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -134,7 +134,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) ...@@ -134,7 +134,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
* Create dependencies for language * Create dependencies for language
*/ */
myself.classId = RelationGetRelid(rel); myself.classId = RelationGetRelid(rel);
myself.objectId = tup->t_data->t_oid; myself.objectId = HeapTupleGetOid(tup);
myself.objectSubId = 0; myself.objectSubId = 0;
/* dependency on the PL handler function */ /* dependency on the PL handler function */
...@@ -191,7 +191,7 @@ DropProceduralLanguage(DropPLangStmt *stmt) ...@@ -191,7 +191,7 @@ DropProceduralLanguage(DropPLangStmt *stmt)
languageName); languageName);
object.classId = get_system_catalog_relid(LanguageRelationName); object.classId = get_system_catalog_relid(LanguageRelationName);
object.objectId = langTup->t_data->t_oid; object.objectId = HeapTupleGetOid(langTup);
object.objectSubId = 0; object.objectSubId = 0;
ReleaseSysCache(langTup); ReleaseSysCache(langTup);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.23 2002/07/16 22:12:19 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.24 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -149,6 +149,7 @@ DefineRelation(CreateStmt *stmt, char relkind) ...@@ -149,6 +149,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
* have to copy inherited constraints here.) * have to copy inherited constraints here.)
*/ */
descriptor = BuildDescForRelation(schema); descriptor = BuildDescForRelation(schema);
descriptor->tdhasoid = BoolToHasOid(stmt->hasoids || parentHasOids);
if (old_constraints != NIL) if (old_constraints != NIL)
{ {
...@@ -1658,6 +1659,7 @@ AlterTableAddColumn(Oid myrelid, ...@@ -1658,6 +1659,7 @@ AlterTableAddColumn(Oid myrelid,
tform = (Form_pg_type) GETSTRUCT(typeTuple); tform = (Form_pg_type) GETSTRUCT(typeTuple);
attributeTuple = heap_addheader(Natts_pg_attribute, attributeTuple = heap_addheader(Natts_pg_attribute,
false,
ATTRIBUTE_TUPLE_SIZE, ATTRIBUTE_TUPLE_SIZE,
(void *) &attributeD); (void *) &attributeD);
...@@ -1665,7 +1667,7 @@ AlterTableAddColumn(Oid myrelid, ...@@ -1665,7 +1667,7 @@ AlterTableAddColumn(Oid myrelid,
attribute->attrelid = myrelid; attribute->attrelid = myrelid;
namestrcpy(&(attribute->attname), colDef->colname); namestrcpy(&(attribute->attname), colDef->colname);
attribute->atttypid = typeTuple->t_data->t_oid; attribute->atttypid = HeapTupleGetOid(typeTuple);
attribute->attstattarget = DEFAULT_ATTSTATTARGET; attribute->attstattarget = DEFAULT_ATTSTATTARGET;
attribute->attlen = tform->typlen; attribute->attlen = tform->typlen;
attribute->attcacheoff = -1; attribute->attcacheoff = -1;
...@@ -1682,6 +1684,7 @@ AlterTableAddColumn(Oid myrelid, ...@@ -1682,6 +1684,7 @@ AlterTableAddColumn(Oid myrelid,
ReleaseSysCache(typeTuple); ReleaseSysCache(typeTuple);
AssertTupleDescHasNoOid(attrdesc->rd_att);
simple_heap_insert(attrdesc, attributeTuple); simple_heap_insert(attrdesc, attributeTuple);
/* Update indexes on pg_attribute */ /* Update indexes on pg_attribute */
...@@ -1702,6 +1705,7 @@ AlterTableAddColumn(Oid myrelid, ...@@ -1702,6 +1705,7 @@ AlterTableAddColumn(Oid myrelid,
newreltup = heap_copytuple(reltup); newreltup = heap_copytuple(reltup);
((Form_pg_class) GETSTRUCT(newreltup))->relnatts = maxatts; ((Form_pg_class) GETSTRUCT(newreltup))->relnatts = maxatts;
AssertTupleDescHasOid(pgclass->rd_att);
simple_heap_update(pgclass, &newreltup->t_self, newreltup); simple_heap_update(pgclass, &newreltup->t_self, newreltup);
/* keep catalog indices current */ /* keep catalog indices current */
...@@ -3299,7 +3303,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent) ...@@ -3299,7 +3303,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent)
sprintf(toast_idxname, "pg_toast_%u_index", relOid); sprintf(toast_idxname, "pg_toast_%u_index", relOid);
/* this is pretty painful... need a tuple descriptor */ /* this is pretty painful... need a tuple descriptor */
tupdesc = CreateTemplateTupleDesc(3); tupdesc = CreateTemplateTupleDesc(3, WITHOUTOID);
TupleDescInitEntry(tupdesc, (AttrNumber) 1, TupleDescInitEntry(tupdesc, (AttrNumber) 1,
"chunk_id", "chunk_id",
OIDOID, OIDOID,
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.121 2002/07/12 18:43:16 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.122 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -400,8 +400,9 @@ DropTrigger(Oid relid, const char *trigname, DropBehavior behavior) ...@@ -400,8 +400,9 @@ DropTrigger(Oid relid, const char *trigname, DropBehavior behavior)
if (!pg_class_ownercheck(relid, GetUserId())) if (!pg_class_ownercheck(relid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, get_rel_name(relid)); aclcheck_error(ACLCHECK_NOT_OWNER, get_rel_name(relid));
AssertTupleDescHasOid(tgrel->rd_att);
object.classId = RelationGetRelid(tgrel); object.classId = RelationGetRelid(tgrel);
object.objectId = tup->t_data->t_oid; object.objectId = HeapTupleGetOid(tup);
object.objectSubId = 0; object.objectSubId = 0;
systable_endscan(tgscan); systable_endscan(tgscan);
...@@ -671,7 +672,8 @@ RelationBuildTriggers(Relation relation) ...@@ -671,7 +672,8 @@ RelationBuildTriggers(Relation relation)
RelationGetRelationName(relation)); RelationGetRelationName(relation));
build = &(triggers[found]); build = &(triggers[found]);
build->tgoid = htup->t_data->t_oid; AssertTupleDescHasOid(tgrel->rd_att);
build->tgoid = HeapTupleGetOid(htup);
build->tgname = MemoryContextStrdup(CacheMemoryContext, build->tgname = MemoryContextStrdup(CacheMemoryContext,
DatumGetCString(DirectFunctionCall1(nameout, DatumGetCString(DirectFunctionCall1(nameout,
NameGetDatum(&pg_trigger->tgname)))); NameGetDatum(&pg_trigger->tgname))));
...@@ -1932,7 +1934,8 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) ...@@ -1932,7 +1934,8 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt)
elog(ERROR, "Constraint '%s' is not deferrable", elog(ERROR, "Constraint '%s' is not deferrable",
cname); cname);
constr_oid = htup->t_data->t_oid; AssertTupleDescHasOid(tgrel->rd_att);
constr_oid = HeapTupleGetOid(htup);
loid = lappendi(loid, constr_oid); loid = lappendi(loid, constr_oid);
found = true; found = true;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.6 2002/07/16 22:12:19 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.7 2002/07/20 05:16:57 momjian Exp $
* *
* DESCRIPTION * DESCRIPTION
* The "DefineFoo" routines take the parse tree and pick out the * The "DefineFoo" routines take the parse tree and pick out the
...@@ -396,7 +396,7 @@ DefineDomain(CreateDomainStmt *stmt) ...@@ -396,7 +396,7 @@ DefineDomain(CreateDomainStmt *stmt)
typeTup = typenameType(stmt->typename); typeTup = typenameType(stmt->typename);
baseType = (Form_pg_type) GETSTRUCT(typeTup); baseType = (Form_pg_type) GETSTRUCT(typeTup);
basetypeoid = typeTup->t_data->t_oid; basetypeoid = HeapTupleGetOid(typeTup);
/* /*
* What we really don't want is domains of domains. This could cause all sorts * What we really don't want is domains of domains. This could cause all sorts
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.231 2002/07/20 04:57:13 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.232 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -392,7 +392,8 @@ getrels(const RangeVar *vacrel, const char *stmttype) ...@@ -392,7 +392,8 @@ getrels(const RangeVar *vacrel, const char *stmttype)
{ {
/* Make a relation list entry for this guy */ /* Make a relation list entry for this guy */
oldcontext = MemoryContextSwitchTo(vac_context); oldcontext = MemoryContextSwitchTo(vac_context);
vrl = lappendi(vrl, tuple->t_data->t_oid); AssertTupleDescHasOid(pgclass->rd_att);
vrl = lappendi(vrl, HeapTupleGetOid(tuple));
MemoryContextSwitchTo(oldcontext); MemoryContextSwitchTo(oldcontext);
} }
...@@ -1172,8 +1173,8 @@ scan_heap(VRelStats *vacrelstats, Relation onerel, ...@@ -1172,8 +1173,8 @@ scan_heap(VRelStats *vacrelstats, Relation onerel,
/* /*
* Other checks... * Other checks...
*/ */
if (!OidIsValid(tuple.t_data->t_oid) && if (onerel->rd_rel->relhasoids &&
onerel->rd_rel->relhasoids) !OidIsValid(HeapTupleGetOid(&tuple)))
elog(WARNING, "Rel %s: TID %u/%u: OID IS INVALID. TUPGONE %d.", elog(WARNING, "Rel %s: TID %u/%u: OID IS INVALID. TUPGONE %d.",
relname, blkno, offnum, (int) tupgone); relname, blkno, offnum, (int) tupgone);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.16 2002/06/20 20:29:27 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.17 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -368,8 +368,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats, ...@@ -368,8 +368,8 @@ lazy_scan_heap(Relation onerel, LVRelStats *vacrelstats,
/* /*
* Other checks... * Other checks...
*/ */
if (!OidIsValid(tuple.t_data->t_oid) && if (onerel->rd_rel->relhasoids &&
onerel->rd_rel->relhasoids) !OidIsValid(HeapTupleGetOid(&tuple)))
elog(WARNING, "Rel %s: TID %u/%u: OID IS INVALID. TUPGONE %d.", elog(WARNING, "Rel %s: TID %u/%u: OID IS INVALID. TUPGONE %d.",
relname, blkno, offnum, (int) tupgone); relname, blkno, offnum, (int) tupgone);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.30 2002/06/20 20:29:27 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.31 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -170,7 +170,7 @@ ExecInitJunkFilter(List *targetList, TupleDesc tupType, ...@@ -170,7 +170,7 @@ ExecInitJunkFilter(List *targetList, TupleDesc tupType,
* Now calculate the tuple type for the cleaned tuple (we were already * Now calculate the tuple type for the cleaned tuple (we were already
* given the type for the original targetlist). * given the type for the original targetlist).
*/ */
cleanTupType = ExecTypeFromTL(cleanTargetList); cleanTupType = ExecTypeFromTL(cleanTargetList, tupType->tdhasoid);
len = ExecTargetListLength(targetList); len = ExecTargetListLength(targetList);
cleanLength = ExecTargetListLength(cleanTargetList); cleanLength = ExecTargetListLength(cleanTargetList);
...@@ -383,8 +383,8 @@ ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot) ...@@ -383,8 +383,8 @@ ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot)
* information for the new "clean" tuple. * information for the new "clean" tuple.
* *
* Note: we use memory on the stack to optimize things when we are * Note: we use memory on the stack to optimize things when we are
* dealing with a small number of tuples. for large tuples we just use * dealing with a small number of attributes. for large tuples we
* palloc. * just use palloc.
*/ */
if (cleanLength > 64) if (cleanLength > 64)
{ {
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.170 2002/07/11 21:36:20 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.171 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -716,6 +716,10 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate) ...@@ -716,6 +716,10 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
get_namespace_name(namespaceId)); get_namespace_name(namespaceId));
} }
/*
* new "INTO" table is created WITH OIDS
*/
tupType->tdhasoid = WITHOID;
/* /*
* have to copy tupType to get rid of constraints * have to copy tupType to get rid of constraints
*/ */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.99 2002/07/18 17:14:19 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.100 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1770,7 +1770,10 @@ ExecTargetList(List *targetlist, ...@@ -1770,7 +1770,10 @@ ExecTargetList(List *targetlist,
* natts = 0 to deal with it. * natts = 0 to deal with it.
*/ */
if (targettype == NULL) if (targettype == NULL)
{
targettype = &NullTupleDesc; targettype = &NullTupleDesc;
targettype->tdhasoid = WITHOUTOID;
}
/* /*
* allocate an array of char's to hold the "null" information only if * allocate an array of char's to hold the "null" information only if
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.54 2002/07/18 04:40:30 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.55 2002/07/20 05:16:57 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -540,6 +540,7 @@ ExecInitNullTupleSlot(EState *estate, TupleDesc tupType) ...@@ -540,6 +540,7 @@ ExecInitNullTupleSlot(EState *estate, TupleDesc tupType)
ExecSetSlotDescriptor(slot, tupType, false); ExecSetSlotDescriptor(slot, tupType, false);
NullTupleDesc.tdhasoid = WITHOUTOID;
nullTuple = heap_formtuple(&NullTupleDesc, values, nulls); nullTuple = heap_formtuple(&NullTupleDesc, values, nulls);
return ExecStoreTuple(nullTuple, slot, InvalidBuffer, true); return ExecStoreTuple(nullTuple, slot, InvalidBuffer, true);
...@@ -557,7 +558,7 @@ ExecInitNullTupleSlot(EState *estate, TupleDesc tupType) ...@@ -557,7 +558,7 @@ ExecInitNullTupleSlot(EState *estate, TupleDesc tupType)
* ---------------------------------------------------------------- * ----------------------------------------------------------------
*/ */
TupleDesc TupleDesc
ExecTypeFromTL(List *targetList) ExecTypeFromTL(List *targetList, hasoid_t withoid)
{ {
List *tlitem; List *tlitem;
TupleDesc typeInfo; TupleDesc typeInfo;
...@@ -576,7 +577,7 @@ ExecTypeFromTL(List *targetList) ...@@ -576,7 +577,7 @@ ExecTypeFromTL(List *targetList)
/* /*
* allocate a new typeInfo * allocate a new typeInfo
*/ */
typeInfo = CreateTemplateTupleDesc(len); typeInfo = CreateTemplateTupleDesc(len, withoid);
/* /*
* scan list, generate type info for each entry * scan list, generate type info for each entry
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.86 2002/06/26 21:58:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.87 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -290,9 +290,23 @@ ExecAssignResultTypeFromOuterPlan(Plan *node, CommonState *commonstate) ...@@ -290,9 +290,23 @@ ExecAssignResultTypeFromOuterPlan(Plan *node, CommonState *commonstate)
void void
ExecAssignResultTypeFromTL(Plan *node, CommonState *commonstate) ExecAssignResultTypeFromTL(Plan *node, CommonState *commonstate)
{ {
ResultRelInfo *ri;
Relation rel;
hasoid_t withoid;
TupleDesc tupDesc; TupleDesc tupDesc;
tupDesc = ExecTypeFromTL(node->targetlist); ri = node->state->es_result_relation_info;
if (ri != NULL)
rel = ri->ri_RelationDesc;
else
rel = node->state->es_into_relation_descriptor;
if (rel != NULL)
withoid = BoolToHasOid(rel->rd_rel->relhasoids);
else
withoid = WITHOUTOID;
tupDesc = ExecTypeFromTL(node->targetlist, withoid);
ExecAssignResultType(commonstate, tupDesc, true); ExecAssignResultType(commonstate, tupDesc, true);
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.2 2002/06/20 20:29:28 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.3 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -234,7 +234,7 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, Plan *parent) ...@@ -234,7 +234,7 @@ ExecInitFunctionScan(FunctionScan *node, EState *estate, Plan *parent)
*/ */
char *attname = strVal(lfirst(rte->eref->colnames)); char *attname = strVal(lfirst(rte->eref->colnames));
tupdesc = CreateTemplateTupleDesc(1); tupdesc = CreateTemplateTupleDesc(1, WITHOUTOID);
TupleDescInitEntry(tupdesc, TupleDescInitEntry(tupdesc,
(AttrNumber) 1, (AttrNumber) 1,
attname, attname,
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.71 2002/06/20 20:29:28 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.72 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -435,11 +435,15 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum, ...@@ -435,11 +435,15 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum,
{ {
mtuple = heap_formtuple(rel->rd_att, v, n); mtuple = heap_formtuple(rel->rd_att, v, n);
infomask = mtuple->t_data->t_infomask; infomask = mtuple->t_data->t_infomask;
memmove(&(mtuple->t_data->t_oid), &(tuple->t_data->t_oid), /*
((char *) &(tuple->t_data->t_hoff) - * copy t_xmin, t_cid, t_xmax, t_ctid, t_natts, t_infomask
(char *) &(tuple->t_data->t_oid))); */
memmove((char *)mtuple->t_data, (char *)tuple->t_data,
offsetof(HeapTupleHeaderData, t_hoff));
mtuple->t_data->t_infomask = infomask; mtuple->t_data->t_infomask = infomask;
mtuple->t_data->t_natts = numberOfAttributes; mtuple->t_data->t_natts = numberOfAttributes;
if (rel->rd_rel->relhasoids)
HeapTupleSetOid(mtuple, HeapTupleGetOid(tuple));
} }
else else
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.105 2002/07/18 17:14:19 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.106 2002/07/20 05:16:58 momjian Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -1071,7 +1071,7 @@ CommuteClause(Expr *clause) ...@@ -1071,7 +1071,7 @@ CommuteClause(Expr *clause)
commuTup = (Form_pg_operator) GETSTRUCT(optup); commuTup = (Form_pg_operator) GETSTRUCT(optup);
commu = makeOper(optup->t_data->t_oid, commu = makeOper(HeapTupleGetOid(optup),
commuTup->oprcode, commuTup->oprcode,
commuTup->oprresult, commuTup->oprresult,
((Oper *) clause->oper)->opretset); ((Oper *) clause->oper)->opretset);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.57 2002/06/20 20:29:33 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.58 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -150,7 +150,7 @@ any_ordering_op(Oid argtype) ...@@ -150,7 +150,7 @@ any_ordering_op(Oid argtype)
Oid Oid
oprid(Operator op) oprid(Operator op)
{ {
return op->t_data->t_oid; return HeapTupleGetOid(op);
} }
/* given operator tuple, return the underlying function's OID */ /* given operator tuple, return the underlying function's OID */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.44 2002/07/06 20:16:36 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.45 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -283,7 +283,7 @@ typeTypeId(Type tp) ...@@ -283,7 +283,7 @@ typeTypeId(Type tp)
{ {
if (tp == NULL) if (tp == NULL)
elog(ERROR, "typeTypeId() called with NULL type struct"); elog(ERROR, "typeTypeId() called with NULL type struct");
return tp->t_data->t_oid; return HeapTupleGetOid(tp);
} }
/* given type (as type struct), return the length of type */ /* given type (as type struct), return the length of type */
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* Copyright (c) 2001, PostgreSQL Global Development Group * Copyright (c) 2001, PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.21 2002/05/20 23:51:43 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.22 2002/07/20 05:16:58 momjian Exp $
* ---------- * ----------
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -628,7 +628,8 @@ pgstat_vacuum_tabstat(void) ...@@ -628,7 +628,8 @@ pgstat_vacuum_tabstat(void)
dbidlist = (Oid *) repalloc((char *) dbidlist, dbidlist = (Oid *) repalloc((char *) dbidlist,
sizeof(Oid) * dbidalloc); sizeof(Oid) * dbidalloc);
} }
dbidlist[dbidused++] = dbtup->t_data->t_oid; AssertTupleDescHasOid(dbrel->rd_att);
dbidlist[dbidused++] = HeapTupleGetOid(dbtup);
} }
heap_endscan(dbscan); heap_endscan(dbscan);
heap_close(dbrel, AccessShareLock); heap_close(dbrel, AccessShareLock);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.51 2002/07/12 18:43:17 tgl Exp $ * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.52 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -69,7 +69,7 @@ RemoveRewriteRule(Oid owningRel, const char *ruleName, DropBehavior behavior) ...@@ -69,7 +69,7 @@ RemoveRewriteRule(Oid owningRel, const char *ruleName, DropBehavior behavior)
* Do the deletion * Do the deletion
*/ */
object.classId = get_system_catalog_relid(RewriteRelationName); object.classId = get_system_catalog_relid(RewriteRelationName);
object.objectId = tuple->t_data->t_oid; object.objectId = HeapTupleGetOid(tuple);
object.objectSubId = 0; object.objectSubId = 0;
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.70 2002/06/20 20:29:38 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.71 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -110,7 +110,8 @@ regprocin(PG_FUNCTION_ARGS) ...@@ -110,7 +110,8 @@ regprocin(PG_FUNCTION_ARGS)
while (HeapTupleIsValid(tuple = systable_getnext(sysscan))) while (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
{ {
result = (RegProcedure) tuple->t_data->t_oid; AssertTupleDescHasOid(hdesc->rd_att);
result = (RegProcedure) HeapTupleGetOid(tuple);
if (++matches > 1) if (++matches > 1)
break; break;
} }
...@@ -414,7 +415,8 @@ regoperin(PG_FUNCTION_ARGS) ...@@ -414,7 +415,8 @@ regoperin(PG_FUNCTION_ARGS)
while (HeapTupleIsValid(tuple = systable_getnext(sysscan))) while (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
{ {
result = tuple->t_data->t_oid; AssertTupleDescHasOid(hdesc->rd_att);
result = HeapTupleGetOid(tuple);
if (++matches > 1) if (++matches > 1)
break; break;
} }
...@@ -731,7 +733,10 @@ regclassin(PG_FUNCTION_ARGS) ...@@ -731,7 +733,10 @@ regclassin(PG_FUNCTION_ARGS)
SnapshotNow, 1, skey); SnapshotNow, 1, skey);
if (HeapTupleIsValid(tuple = systable_getnext(sysscan))) if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
result = tuple->t_data->t_oid; {
AssertTupleDescHasOid(hdesc->rd_att);
result = HeapTupleGetOid(tuple);
}
else else
elog(ERROR, "No class with name %s", class_name_or_oid); elog(ERROR, "No class with name %s", class_name_or_oid);
...@@ -884,7 +889,10 @@ regtypein(PG_FUNCTION_ARGS) ...@@ -884,7 +889,10 @@ regtypein(PG_FUNCTION_ARGS)
SnapshotNow, 1, skey); SnapshotNow, 1, skey);
if (HeapTupleIsValid(tuple = systable_getnext(sysscan))) if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
result = tuple->t_data->t_oid; {
AssertTupleDescHasOid(hdesc->rd_att);
result = HeapTupleGetOid(tuple);
}
else else
elog(ERROR, "No type with name %s", typ_name_or_oid); elog(ERROR, "No type with name %s", typ_name_or_oid);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.47 2002/07/18 23:11:29 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.48 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -119,7 +119,8 @@ SetDefine(char *querystr, Oid elemType) ...@@ -119,7 +119,8 @@ SetDefine(char *querystr, Oid elemType)
simple_heap_update(procrel, &newtup->t_self, newtup); simple_heap_update(procrel, &newtup->t_self, newtup);
setoid = newtup->t_data->t_oid; AssertTupleDescHasOid(procrel->rd_att);
setoid = HeapTupleGetOid(newtup);
if (RelationGetForm(procrel)->relhasindex) if (RelationGetForm(procrel)->relhasindex)
{ {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.96 2002/06/20 20:29:39 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.97 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -218,7 +218,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple) ...@@ -218,7 +218,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple)
case 4: case 4:
cur_skey[3].sk_argument = cur_skey[3].sk_argument =
(cache->cc_key[3] == ObjectIdAttributeNumber) (cache->cc_key[3] == ObjectIdAttributeNumber)
? ObjectIdGetDatum(tuple->t_data->t_oid) ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
: fastgetattr(tuple, : fastgetattr(tuple,
cache->cc_key[3], cache->cc_key[3],
cache->cc_tupdesc, cache->cc_tupdesc,
...@@ -228,7 +228,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple) ...@@ -228,7 +228,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple)
case 3: case 3:
cur_skey[2].sk_argument = cur_skey[2].sk_argument =
(cache->cc_key[2] == ObjectIdAttributeNumber) (cache->cc_key[2] == ObjectIdAttributeNumber)
? ObjectIdGetDatum(tuple->t_data->t_oid) ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
: fastgetattr(tuple, : fastgetattr(tuple,
cache->cc_key[2], cache->cc_key[2],
cache->cc_tupdesc, cache->cc_tupdesc,
...@@ -238,7 +238,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple) ...@@ -238,7 +238,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple)
case 2: case 2:
cur_skey[1].sk_argument = cur_skey[1].sk_argument =
(cache->cc_key[1] == ObjectIdAttributeNumber) (cache->cc_key[1] == ObjectIdAttributeNumber)
? ObjectIdGetDatum(tuple->t_data->t_oid) ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
: fastgetattr(tuple, : fastgetattr(tuple,
cache->cc_key[1], cache->cc_key[1],
cache->cc_tupdesc, cache->cc_tupdesc,
...@@ -248,7 +248,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple) ...@@ -248,7 +248,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple)
case 1: case 1:
cur_skey[0].sk_argument = cur_skey[0].sk_argument =
(cache->cc_key[0] == ObjectIdAttributeNumber) (cache->cc_key[0] == ObjectIdAttributeNumber)
? ObjectIdGetDatum(tuple->t_data->t_oid) ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
: fastgetattr(tuple, : fastgetattr(tuple,
cache->cc_key[0], cache->cc_key[0],
cache->cc_tupdesc, cache->cc_tupdesc,
...@@ -572,7 +572,7 @@ AtEOXact_CatCache(bool isCommit) ...@@ -572,7 +572,7 @@ AtEOXact_CatCache(bool isCommit)
if (isCommit) if (isCommit)
elog(WARNING, "Cache reference leak: cache %s (%d), tuple %u has count %d", elog(WARNING, "Cache reference leak: cache %s (%d), tuple %u has count %d",
ct->my_cache->cc_relname, ct->my_cache->id, ct->my_cache->cc_relname, ct->my_cache->id,
ct->tuple.t_data->t_oid, HeapTupleGetOid(&ct->tuple),
ct->refcount); ct->refcount);
ct->refcount = 0; ct->refcount = 0;
} }
...@@ -717,7 +717,7 @@ CatalogCacheFlushRelation(Oid relId) ...@@ -717,7 +717,7 @@ CatalogCacheFlushRelation(Oid relId)
continue; continue;
if (cache->cc_reloidattr == ObjectIdAttributeNumber) if (cache->cc_reloidattr == ObjectIdAttributeNumber)
tupRelid = ct->tuple.t_data->t_oid; tupRelid = HeapTupleGetOid(&ct->tuple);
else else
{ {
bool isNull; bool isNull;
...@@ -907,6 +907,7 @@ CatalogCacheInitializeCache(CatCache *cache) ...@@ -907,6 +907,7 @@ CatalogCacheInitializeCache(CatCache *cache)
* copy the relcache's tuple descriptor to permanent cache storage * copy the relcache's tuple descriptor to permanent cache storage
*/ */
tupdesc = CreateTupleDescCopyConstr(RelationGetDescr(relation)); tupdesc = CreateTupleDescCopyConstr(RelationGetDescr(relation));
AssertTupleDescHasOidIsValid(tupdesc);
/* /*
* get the relation's OID and relisshared flag, too * get the relation's OID and relisshared flag, too
...@@ -1685,7 +1686,11 @@ build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys) ...@@ -1685,7 +1686,11 @@ build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys)
} }
ntp = heap_formtuple(tupDesc, values, nulls); ntp = heap_formtuple(tupDesc, values, nulls);
ntp->t_data->t_oid = tupOid; if (tupOid != InvalidOid)
{
AssertTupleDescHasOid(tupDesc);
HeapTupleSetOid(ntp, tupOid);
}
pfree(values); pfree(values);
pfree(nulls); pfree(nulls);
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.52 2002/06/20 20:29:39 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.53 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -525,7 +525,10 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple, ...@@ -525,7 +525,10 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple,
tupleRelId = RelationGetRelid(relation); tupleRelId = RelationGetRelid(relation);
if (tupleRelId == RelOid_pg_class) if (tupleRelId == RelOid_pg_class)
relationId = tuple->t_data->t_oid; {
AssertTupleDescHasOid(relation->rd_att);
relationId = HeapTupleGetOid(tuple);
}
else if (tupleRelId == RelOid_pg_attribute) else if (tupleRelId == RelOid_pg_attribute)
relationId = ((Form_pg_attribute) GETSTRUCT(tuple))->attrelid; relationId = ((Form_pg_attribute) GETSTRUCT(tuple))->attrelid;
else else
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.167 2002/07/15 01:57:51 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.168 2002/07/20 05:16:58 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -440,7 +440,7 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp) ...@@ -440,7 +440,7 @@ AllocateRelationDesc(Relation relation, Form_pg_class relp)
relation->rd_rel = relationForm; relation->rd_rel = relationForm;
/* and allocate attribute tuple form storage */ /* and allocate attribute tuple form storage */
relation->rd_att = CreateTemplateTupleDesc(relationForm->relnatts); relation->rd_att = CreateTemplateTupleDesc(relationForm->relnatts, BoolToHasOid(relationForm->relhasoids));
MemoryContextSwitchTo(oldcxt); MemoryContextSwitchTo(oldcxt);
...@@ -701,7 +701,8 @@ RelationBuildRuleLock(Relation relation) ...@@ -701,7 +701,8 @@ RelationBuildRuleLock(Relation relation)
rule = (RewriteRule *) MemoryContextAlloc(rulescxt, rule = (RewriteRule *) MemoryContextAlloc(rulescxt,
sizeof(RewriteRule)); sizeof(RewriteRule));
rule->ruleId = rewrite_tuple->t_data->t_oid; AssertTupleDescHasOid(rewrite_tupdesc);
rule->ruleId = HeapTupleGetOid(rewrite_tuple);
rule->event = rewrite_form->ev_type - '0'; rule->event = rewrite_form->ev_type - '0';
rule->attrno = rewrite_form->ev_attr; rule->attrno = rewrite_form->ev_attr;
...@@ -839,7 +840,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo, ...@@ -839,7 +840,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo,
/* /*
* get information from the pg_class_tuple * get information from the pg_class_tuple
*/ */
relid = pg_class_tuple->t_data->t_oid; relid = HeapTupleGetOid(pg_class_tuple);
relp = (Form_pg_class) GETSTRUCT(pg_class_tuple); relp = (Form_pg_class) GETSTRUCT(pg_class_tuple);
/* /*
...@@ -872,6 +873,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo, ...@@ -872,6 +873,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo,
* initialize the tuple descriptor (relation->rd_att). * initialize the tuple descriptor (relation->rd_att).
*/ */
RelationBuildTupleDesc(buildinfo, relation); RelationBuildTupleDesc(buildinfo, relation);
RelationGetDescr(relation)->tdhasoid = BoolToHasOid(RelationGetForm(relation)->relhasoids);
/* /*
* Fetch rules and triggers that affect this relation * Fetch rules and triggers that affect this relation
...@@ -1395,7 +1397,7 @@ formrdesc(const char *relationName, ...@@ -1395,7 +1397,7 @@ formrdesc(const char *relationName,
* right because it will never be replaced. The input values must be * right because it will never be replaced. The input values must be
* correctly defined by macros in src/include/catalog/ headers. * correctly defined by macros in src/include/catalog/ headers.
*/ */
relation->rd_att = CreateTemplateTupleDesc(natts); relation->rd_att = CreateTemplateTupleDesc(natts, BoolToHasOid(relation->rd_rel->relhasoids));
/* /*
* initialize tuple desc info * initialize tuple desc info
...@@ -2067,7 +2069,7 @@ RelationBuildLocalRelation(const char *relname, ...@@ -2067,7 +2069,7 @@ RelationBuildLocalRelation(const char *relname,
rel->rd_rel->relnamespace = relnamespace; rel->rd_rel->relnamespace = relnamespace;
rel->rd_rel->relkind = RELKIND_UNCATALOGED; rel->rd_rel->relkind = RELKIND_UNCATALOGED;
rel->rd_rel->relhasoids = true; rel->rd_rel->relhasoids = (rel->rd_att->tdhasoid == WITHOID);
rel->rd_rel->relnatts = natts; rel->rd_rel->relnatts = natts;
rel->rd_rel->reltype = InvalidOid; rel->rd_rel->reltype = InvalidOid;
...@@ -2313,6 +2315,7 @@ RelationCacheInitializePhase2(void) ...@@ -2313,6 +2315,7 @@ RelationCacheInitializePhase2(void)
*/ */
Assert(relation->rd_rel != NULL); Assert(relation->rd_rel != NULL);
memcpy((char *) relation->rd_rel, (char *) relp, CLASS_TUPLE_SIZE); memcpy((char *) relation->rd_rel, (char *) relp, CLASS_TUPLE_SIZE);
relation->rd_att->tdhasoid = BoolToHasOid(relp->relhasoids);
ReleaseSysCache(htup); ReleaseSysCache(htup);
} }
...@@ -2774,7 +2777,7 @@ load_relcache_init_file(void) ...@@ -2774,7 +2777,7 @@ load_relcache_init_file(void)
rel->rd_rel = relform; rel->rd_rel = relform;
/* initialize attribute tuple forms */ /* initialize attribute tuple forms */
rel->rd_att = CreateTemplateTupleDesc(relform->relnatts); rel->rd_att = CreateTemplateTupleDesc(relform->relnatts, BoolToHasOid(relform->relhasoids));
/* next read all the attribute tuple form data entries */ /* next read all the attribute tuple form data entries */
for (i = 0; i < relform->relnatts; i++) for (i = 0; i < relform->relnatts; i++)
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.82 2002/07/18 23:11:29 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.83 2002/07/20 05:16:58 momjian Exp $
* *
* NOTES * NOTES
* These routines allow the parser/planner/executor to perform * These routines allow the parser/planner/executor to perform
...@@ -597,7 +597,7 @@ GetSysCacheOid(int cacheId, ...@@ -597,7 +597,7 @@ GetSysCacheOid(int cacheId,
tuple = SearchSysCache(cacheId, key1, key2, key3, key4); tuple = SearchSysCache(cacheId, key1, key2, key3, key4);
if (!HeapTupleIsValid(tuple)) if (!HeapTupleIsValid(tuple))
return InvalidOid; return InvalidOid;
result = tuple->t_data->t_oid; result = HeapTupleGetOid(tuple);
ReleaseSysCache(tuple); ReleaseSysCache(tuple);
return result; return result;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.108 2002/06/20 20:29:40 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.109 2002/07/20 05:16:59 momjian Exp $
* *
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
...@@ -98,8 +98,9 @@ ReverifyMyDatabase(const char *name) ...@@ -98,8 +98,9 @@ ReverifyMyDatabase(const char *name)
pgdbscan = heap_beginscan(pgdbrel, SnapshotNow, 1, &key); pgdbscan = heap_beginscan(pgdbrel, SnapshotNow, 1, &key);
tup = heap_getnext(pgdbscan, ForwardScanDirection); tup = heap_getnext(pgdbscan, ForwardScanDirection);
AssertTupleDescHasOid(pgdbrel->rd_att);
if (!HeapTupleIsValid(tup) || if (!HeapTupleIsValid(tup) ||
tup->t_data->t_oid != MyDatabaseId) HeapTupleGetOid(tup) != MyDatabaseId)
{ {
/* OOPS */ /* OOPS */
heap_close(pgdbrel, AccessShareLock); heap_close(pgdbrel, AccessShareLock);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.51 2002/06/20 20:29:40 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.52 2002/07/20 05:16:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -220,7 +220,7 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path) ...@@ -220,7 +220,7 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path)
if (strcmp(name, NameStr(tup_db->datname)) == 0) if (strcmp(name, NameStr(tup_db->datname)) == 0)
{ {
/* Found it; extract the OID and the database path. */ /* Found it; extract the OID and the database path. */
*db_id = tup.t_data->t_oid; *db_id = HeapTupleGetOid(&tup);
pathlen = VARSIZE(&(tup_db->datpath)) - VARHDRSZ; pathlen = VARSIZE(&(tup_db->datpath)) - VARHDRSZ;
if (pathlen < 0) if (pathlen < 0)
pathlen = 0; /* pure paranoia */ pathlen = 0; /* pure paranoia */
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: heapam.h,v 1.77 2002/06/20 20:29:43 momjian Exp $ * $Id: heapam.h,v 1.78 2002/07/20 05:16:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -200,6 +200,6 @@ extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor, ...@@ -200,6 +200,6 @@ extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor,
extern HeapTuple heap_modifytuple(HeapTuple tuple, extern HeapTuple heap_modifytuple(HeapTuple tuple,
Relation relation, Datum *replValue, char *replNull, char *repl); Relation relation, Datum *replValue, char *replNull, char *repl);
extern void heap_freetuple(HeapTuple tuple); extern void heap_freetuple(HeapTuple tuple);
extern HeapTuple heap_addheader(int natts, Size structlen, void *structure); extern HeapTuple heap_addheader(int natts, bool withoid, Size structlen, void *structure);
#endif /* HEAPAM_H */ #endif /* HEAPAM_H */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: htup.h,v 1.56 2002/07/08 01:52:23 momjian Exp $ * $Id: htup.h,v 1.57 2002/07/20 05:16:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -70,8 +70,6 @@ ...@@ -70,8 +70,6 @@
*/ */
typedef struct HeapTupleHeaderData typedef struct HeapTupleHeaderData
{ {
Oid t_oid; /* OID of this tuple -- 4 bytes */
TransactionId t_xmin; /* Xmin -- 4 bytes each */ TransactionId t_xmin; /* Xmin -- 4 bytes each */
TransactionId t_cid; /* Cmin, Cmax, Xvac */ TransactionId t_cid; /* Cmin, Cmax, Xvac */
TransactionId t_xmax; /* Xmax, Cmax */ TransactionId t_xmax; /* Xmax, Cmax */
...@@ -84,7 +82,7 @@ typedef struct HeapTupleHeaderData ...@@ -84,7 +82,7 @@ typedef struct HeapTupleHeaderData
uint8 t_hoff; /* sizeof header incl. bitmap, padding */ uint8 t_hoff; /* sizeof header incl. bitmap, padding */
/* ^ - 27 bytes - ^ */ /* ^ - 23 bytes - ^ */
bits8 t_bits[1]; /* bitmap of NULLs -- VARIABLE LENGTH */ bits8 t_bits[1]; /* bitmap of NULLs -- VARIABLE LENGTH */
...@@ -123,10 +121,42 @@ typedef HeapTupleHeaderData *HeapTupleHeader; ...@@ -123,10 +121,42 @@ typedef HeapTupleHeaderData *HeapTupleHeader;
#define HEAP_XACT_MASK 0xFFF0 /* visibility-related bits */ #define HEAP_XACT_MASK 0xFFF0 /* visibility-related bits */
/* paranoid checking */
#ifdef DEBUG_TUPLE_ACCESS
#define HeapTupleHeaderExpectedLen(tup, withoid) \
MAXALIGN(offsetof(HeapTupleHeaderData, t_bits) + \
(((tup)->t_infomask & HEAP_HASNULL) \
? BITMAPLEN((tup)->t_natts) : 0) + \
((withoid) ? sizeof(Oid) : 0) \
)
#define AssertHeapTupleHeaderHoffIsValid(tup, withoid) \
AssertMacro((tup)->t_hoff == HeapTupleHeaderExpectedLen(tup, withoid))
#else
#define AssertHeapTupleHeaderHoffIsValid(tup, withoid) ((void)true)
#endif /* DEBUG_TUPLE_ACCESS */
/* HeapTupleHeader accessor macros */ /* HeapTupleHeader accessor macros */
#define HeapTupleHeaderGetOid(tup) \
( \
AssertHeapTupleHeaderHoffIsValid(tup, true), \
*((Oid *)((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) \
)
#define HeapTupleHeaderSetOid(tup, oid) \
( \
AssertHeapTupleHeaderHoffIsValid(tup, true), \
*((Oid *)((char *)(tup) + (tup)->t_hoff - sizeof(Oid))) = (oid) \
)
#define HeapTupleHeaderGetXmin(tup) \ #define HeapTupleHeaderGetXmin(tup) \
( \ ( \
(tup)->t_xmin \ (tup)->t_xmin \
...@@ -406,4 +436,10 @@ typedef HeapTupleData *HeapTuple; ...@@ -406,4 +436,10 @@ typedef HeapTupleData *HeapTuple;
#define HeapTupleHasExtended(tuple) \ #define HeapTupleHasExtended(tuple) \
((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASEXTENDED) != 0) ((((HeapTuple)(tuple))->t_data->t_infomask & HEAP_HASEXTENDED) != 0)
#define HeapTupleGetOid(tuple) \
HeapTupleHeaderGetOid(((HeapTuple)(tuple))->t_data)
#define HeapTupleSetOid(tuple, oid) \
HeapTupleHeaderSetOid(((HeapTuple)(tuple))->t_data, (oid))
#endif /* HTUP_H */ #endif /* HTUP_H */
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: tupdesc.h,v 1.36 2002/07/12 18:43:19 tgl Exp $ * $Id: tupdesc.h,v 1.37 2002/07/20 05:16:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -41,6 +41,11 @@ typedef struct tupleConstr ...@@ -41,6 +41,11 @@ typedef struct tupleConstr
bool has_not_null; bool has_not_null;
} TupleConstr; } TupleConstr;
typedef char hasoid_t;
#define WITHOID 'C'
#define WITHOUTOID 'S'
#define UNDEFOID '?'
#define BoolToHasOid(b) ((b) ? WITHOID : WITHOUTOID)
/* /*
* This structure contains all information (i.e. from Classes * This structure contains all information (i.e. from Classes
* pg_attribute, pg_attrdef, pg_constraint) for a tuple. * pg_attribute, pg_attrdef, pg_constraint) for a tuple.
...@@ -51,9 +56,27 @@ typedef struct tupleDesc ...@@ -51,9 +56,27 @@ typedef struct tupleDesc
Form_pg_attribute *attrs; Form_pg_attribute *attrs;
/* attrs[N] is a pointer to the description of Attribute Number N+1. */ /* attrs[N] is a pointer to the description of Attribute Number N+1. */
TupleConstr *constr; TupleConstr *constr;
hasoid_t tdhasoid; /* Tuple has an oid attribute in its header */
} *TupleDesc; } *TupleDesc;
extern TupleDesc CreateTemplateTupleDesc(int natts); #ifdef DEBUG_TUPLE_ACCESS
#define AssertTupleDescHasOidIsValid(td) \
Assert(((td)->tdhasoid == WITHOID) || ((td)->tdhasoid == WITHOUTOID))
#define AssertTupleDescHasOid(td) \
Assert((td)->tdhasoid == WITHOID)
#define AssertTupleDescHasNoOid(td) \
Assert((td)->tdhasoid == WITHOUTOID)
#else
#define AssertTupleDescHasOidIsValid(td)
#define AssertTupleDescHasOid(td)
#define AssertTupleDescHasNoOid(td)
#endif
extern TupleDesc CreateTemplateTupleDesc(int natts, hasoid_t withoid);
extern TupleDesc CreateTupleDesc(int natts, Form_pg_attribute *attrs); extern TupleDesc CreateTupleDesc(int natts, Form_pg_attribute *attrs);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $Id: executor.h,v 1.69 2002/06/26 21:58:56 momjian Exp $ * $Id: executor.h,v 1.70 2002/07/20 05:16:59 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -118,7 +118,7 @@ extern void ExecInitScanTupleSlot(EState *estate, ...@@ -118,7 +118,7 @@ extern void ExecInitScanTupleSlot(EState *estate,
extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate); extern TupleTableSlot *ExecInitExtraTupleSlot(EState *estate);
extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate, extern TupleTableSlot *ExecInitNullTupleSlot(EState *estate,
TupleDesc tupType); TupleDesc tupType);
extern TupleDesc ExecTypeFromTL(List *targetList); extern TupleDesc ExecTypeFromTL(List *targetList, hasoid_t withoid);
extern void SetChangedParamList(Plan *node, List *newchg); extern void SetChangedParamList(Plan *node, List *newchg);
/* /*
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your * or in pg_config.h afterwards. Of course, if you edit pg_config.h, then your
* changes will be overwritten the next time you run configure. * changes will be overwritten the next time you run configure.
* *
* $Id: pg_config.h.in,v 1.24 2002/05/05 00:03:29 tgl Exp $ * $Id: pg_config.h.in,v 1.25 2002/07/20 05:16:59 momjian Exp $
*/ */
#ifndef PG_CONFIG_H #ifndef PG_CONFIG_H
...@@ -311,6 +311,12 @@ ...@@ -311,6 +311,12 @@
/* #define ACLDEBUG */ /* #define ACLDEBUG */
/* #define RTDEBUG */ /* #define RTDEBUG */
/* #define GISTDEBUG */ /* #define GISTDEBUG */
/*
* DEBUG_TUPLE_ACCESS enables paranoid assertions during
* elimination of oids from the fixed sized part of HeapTupleHeader.
* This is expected to be undef'd after v7.3 release at the latest.
*/
#define DEBUG_TUPLE_ACCESS
/* /*
* defining unsafe floats will make float4 and float8 ops faster * defining unsafe floats will make float4 and float8 ops faster
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. * MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.18 2002/06/15 19:54:24 momjian Exp $ * $Header: /cvsroot/pgsql/src/pl/plpython/plpython.c,v 1.19 2002/07/20 05:16:59 momjian Exp $
* *
********************************************************************* *********************************************************************
*/ */
...@@ -2091,7 +2091,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args) ...@@ -2091,7 +2091,7 @@ PLy_spi_prepare(PyObject * self, PyObject * args)
Py_DECREF(optr); Py_DECREF(optr);
optr = NULL; /* this is important */ optr = NULL; /* this is important */
plan->types[i] = typeTup->t_data->t_oid; plan->types[i] = HeapTupleGetOid(typeTup);
typeStruct = (Form_pg_type) GETSTRUCT(typeTup); typeStruct = (Form_pg_type) GETSTRUCT(typeTup);
if (typeStruct->typrelid == InvalidOid) if (typeStruct->typrelid == InvalidOid)
PLy_output_datum_func(&plan->args[i], typeStruct); PLy_output_datum_func(&plan->args[i], typeStruct);
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* ENHANCEMENTS, OR MODIFICATIONS. * ENHANCEMENTS, OR MODIFICATIONS.
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.58 2002/07/18 05:07:30 ishii Exp $ * $Header: /cvsroot/pgsql/src/pl/tcl/pltcl.c,v 1.59 2002/07/20 05:16:59 momjian Exp $
* *
**********************************************************************/ **********************************************************************/
...@@ -1743,7 +1743,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp, ...@@ -1743,7 +1743,7 @@ pltcl_SPI_prepare(ClientData cdata, Tcl_Interp *interp,
{ {
/* XXX should extend this to allow qualified type names */ /* XXX should extend this to allow qualified type names */
typeTup = typenameType(makeTypeName(args[i])); typeTup = typenameType(makeTypeName(args[i]));
qdesc->argtypes[i] = typeTup->t_data->t_oid; qdesc->argtypes[i] = HeapTupleGetOid(typeTup);
perm_fmgr_info(((Form_pg_type) GETSTRUCT(typeTup))->typinput, perm_fmgr_info(((Form_pg_type) GETSTRUCT(typeTup))->typinput,
&(qdesc->arginfuncs[i])); &(qdesc->arginfuncs[i]));
qdesc->argtypelems[i] = ((Form_pg_type) GETSTRUCT(typeTup))->typelem; qdesc->argtypelems[i] = ((Form_pg_type) GETSTRUCT(typeTup))->typelem;
......
...@@ -75,3 +75,6 @@ test: select_views alter_table portals_p2 rules foreign_key ...@@ -75,3 +75,6 @@ test: select_views alter_table portals_p2 rules foreign_key
# ---------- # ----------
# "plpgsql" cannot run concurrently with "rules" # "plpgsql" cannot run concurrently with "rules"
test: limit plpgsql temp domain rangefuncs copy2 test: limit plpgsql temp domain rangefuncs copy2
test: without_oid
# $Header: /cvsroot/pgsql/src/test/regress/serial_schedule,v 1.12 2002/07/20 04:57:13 momjian Exp $ # $Header: /cvsroot/pgsql/src/test/regress/serial_schedule,v 1.13 2002/07/20 05:16:59 momjian Exp $
# This should probably be in an order similar to parallel_schedule. # This should probably be in an order similar to parallel_schedule.
test: boolean test: boolean
test: char test: char
...@@ -85,3 +85,4 @@ test: copy2 ...@@ -85,3 +85,4 @@ test: copy2
test: temp test: temp
test: domain test: domain
test: rangefuncs test: rangefuncs
test: without_oid
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment