summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorBruce Momjian <bruce@momjian.us>2002-07-20 05:16:59 +0000
committerBruce Momjian <bruce@momjian.us>2002-07-20 05:16:59 +0000
commitb0f5086e4133d1d8ec092799952dda65ebd717c8 (patch)
tree0f717342af7cce7896d40fdb34ccc572e435d499 /src/backend/utils
parent38dd3ae7d032eecc6ddadcbd402d90f6ac38f6a3 (diff)
downloadpostgresql-b0f5086e4133d1d8ec092799952dda65ebd717c8.tar.gz
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
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/regproc.c18
-rw-r--r--src/backend/utils/adt/sets.c5
-rw-r--r--src/backend/utils/cache/catcache.c21
-rw-r--r--src/backend/utils/cache/inval.c7
-rw-r--r--src/backend/utils/cache/relcache.c17
-rw-r--r--src/backend/utils/cache/syscache.c4
-rw-r--r--src/backend/utils/init/postinit.c5
-rw-r--r--src/backend/utils/misc/database.c4
8 files changed, 51 insertions, 30 deletions
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 18569e5479..7dfd26d2db 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -13,7 +13,7 @@
*
*
* 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)
while (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
{
- result = (RegProcedure) tuple->t_data->t_oid;
+ AssertTupleDescHasOid(hdesc->rd_att);
+ result = (RegProcedure) HeapTupleGetOid(tuple);
if (++matches > 1)
break;
}
@@ -414,7 +415,8 @@ regoperin(PG_FUNCTION_ARGS)
while (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
{
- result = tuple->t_data->t_oid;
+ AssertTupleDescHasOid(hdesc->rd_att);
+ result = HeapTupleGetOid(tuple);
if (++matches > 1)
break;
}
@@ -731,7 +733,10 @@ regclassin(PG_FUNCTION_ARGS)
SnapshotNow, 1, skey);
if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
- result = tuple->t_data->t_oid;
+ {
+ AssertTupleDescHasOid(hdesc->rd_att);
+ result = HeapTupleGetOid(tuple);
+ }
else
elog(ERROR, "No class with name %s", class_name_or_oid);
@@ -884,7 +889,10 @@ regtypein(PG_FUNCTION_ARGS)
SnapshotNow, 1, skey);
if (HeapTupleIsValid(tuple = systable_getnext(sysscan)))
- result = tuple->t_data->t_oid;
+ {
+ AssertTupleDescHasOid(hdesc->rd_att);
+ result = HeapTupleGetOid(tuple);
+ }
else
elog(ERROR, "No type with name %s", typ_name_or_oid);
diff --git a/src/backend/utils/adt/sets.c b/src/backend/utils/adt/sets.c
index d03fd88e4d..0a378c4728 100644
--- a/src/backend/utils/adt/sets.c
+++ b/src/backend/utils/adt/sets.c
@@ -10,7 +10,7 @@
*
*
* 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)
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)
{
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c
index a4f05a7d11..21f1e01dab 100644
--- a/src/backend/utils/cache/catcache.c
+++ b/src/backend/utils/cache/catcache.c
@@ -8,7 +8,7 @@
*
*
* 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)
case 4:
cur_skey[3].sk_argument =
(cache->cc_key[3] == ObjectIdAttributeNumber)
- ? ObjectIdGetDatum(tuple->t_data->t_oid)
+ ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
: fastgetattr(tuple,
cache->cc_key[3],
cache->cc_tupdesc,
@@ -228,7 +228,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple)
case 3:
cur_skey[2].sk_argument =
(cache->cc_key[2] == ObjectIdAttributeNumber)
- ? ObjectIdGetDatum(tuple->t_data->t_oid)
+ ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
: fastgetattr(tuple,
cache->cc_key[2],
cache->cc_tupdesc,
@@ -238,7 +238,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple)
case 2:
cur_skey[1].sk_argument =
(cache->cc_key[1] == ObjectIdAttributeNumber)
- ? ObjectIdGetDatum(tuple->t_data->t_oid)
+ ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
: fastgetattr(tuple,
cache->cc_key[1],
cache->cc_tupdesc,
@@ -248,7 +248,7 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple)
case 1:
cur_skey[0].sk_argument =
(cache->cc_key[0] == ObjectIdAttributeNumber)
- ? ObjectIdGetDatum(tuple->t_data->t_oid)
+ ? ObjectIdGetDatum(HeapTupleGetOid(tuple))
: fastgetattr(tuple,
cache->cc_key[0],
cache->cc_tupdesc,
@@ -572,7 +572,7 @@ AtEOXact_CatCache(bool isCommit)
if (isCommit)
elog(WARNING, "Cache reference leak: cache %s (%d), tuple %u has count %d",
ct->my_cache->cc_relname, ct->my_cache->id,
- ct->tuple.t_data->t_oid,
+ HeapTupleGetOid(&ct->tuple),
ct->refcount);
ct->refcount = 0;
}
@@ -717,7 +717,7 @@ CatalogCacheFlushRelation(Oid relId)
continue;
if (cache->cc_reloidattr == ObjectIdAttributeNumber)
- tupRelid = ct->tuple.t_data->t_oid;
+ tupRelid = HeapTupleGetOid(&ct->tuple);
else
{
bool isNull;
@@ -907,6 +907,7 @@ CatalogCacheInitializeCache(CatCache *cache)
* copy the relcache's tuple descriptor to permanent cache storage
*/
tupdesc = CreateTupleDescCopyConstr(RelationGetDescr(relation));
+ AssertTupleDescHasOidIsValid(tupdesc);
/*
* get the relation's OID and relisshared flag, too
@@ -1685,7 +1686,11 @@ build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys)
}
ntp = heap_formtuple(tupDesc, values, nulls);
- ntp->t_data->t_oid = tupOid;
+ if (tupOid != InvalidOid)
+ {
+ AssertTupleDescHasOid(tupDesc);
+ HeapTupleSetOid(ntp, tupOid);
+ }
pfree(values);
pfree(nulls);
diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c
index 02a6d8f8dd..c292926238 100644
--- a/src/backend/utils/cache/inval.c
+++ b/src/backend/utils/cache/inval.c
@@ -74,7 +74,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* 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,
tupleRelId = RelationGetRelid(relation);
if (tupleRelId == RelOid_pg_class)
- relationId = tuple->t_data->t_oid;
+ {
+ AssertTupleDescHasOid(relation->rd_att);
+ relationId = HeapTupleGetOid(tuple);
+ }
else if (tupleRelId == RelOid_pg_attribute)
relationId = ((Form_pg_attribute) GETSTRUCT(tuple))->attrelid;
else
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 532c68f7b3..d7fd83775b 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -8,7 +8,7 @@
*
*
* 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)
relation->rd_rel = relationForm;
/* and allocate attribute tuple form storage */
- relation->rd_att = CreateTemplateTupleDesc(relationForm->relnatts);
+ relation->rd_att = CreateTemplateTupleDesc(relationForm->relnatts, BoolToHasOid(relationForm->relhasoids));
MemoryContextSwitchTo(oldcxt);
@@ -701,7 +701,8 @@ RelationBuildRuleLock(Relation relation)
rule = (RewriteRule *) MemoryContextAlloc(rulescxt,
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->attrno = rewrite_form->ev_attr;
@@ -839,7 +840,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo,
/*
* 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);
/*
@@ -872,6 +873,7 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo,
* initialize the tuple descriptor (relation->rd_att).
*/
RelationBuildTupleDesc(buildinfo, relation);
+ RelationGetDescr(relation)->tdhasoid = BoolToHasOid(RelationGetForm(relation)->relhasoids);
/*
* Fetch rules and triggers that affect this relation
@@ -1395,7 +1397,7 @@ formrdesc(const char *relationName,
* right because it will never be replaced. The input values must be
* 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
@@ -2067,7 +2069,7 @@ RelationBuildLocalRelation(const char *relname,
rel->rd_rel->relnamespace = relnamespace;
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->reltype = InvalidOid;
@@ -2313,6 +2315,7 @@ RelationCacheInitializePhase2(void)
*/
Assert(relation->rd_rel != NULL);
memcpy((char *) relation->rd_rel, (char *) relp, CLASS_TUPLE_SIZE);
+ relation->rd_att->tdhasoid = BoolToHasOid(relp->relhasoids);
ReleaseSysCache(htup);
}
@@ -2774,7 +2777,7 @@ load_relcache_init_file(void)
rel->rd_rel = relform;
/* 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 */
for (i = 0; i < relform->relnatts; i++)
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index 5f0be16b75..9966a8d881 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -8,7 +8,7 @@
*
*
* 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
* These routines allow the parser/planner/executor to perform
@@ -597,7 +597,7 @@ GetSysCacheOid(int cacheId,
tuple = SearchSysCache(cacheId, key1, key2, key3, key4);
if (!HeapTupleIsValid(tuple))
return InvalidOid;
- result = tuple->t_data->t_oid;
+ result = HeapTupleGetOid(tuple);
ReleaseSysCache(tuple);
return result;
}
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 04e33b9b19..433b9a5ed0 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -8,7 +8,7 @@
*
*
* 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)
pgdbscan = heap_beginscan(pgdbrel, SnapshotNow, 1, &key);
tup = heap_getnext(pgdbscan, ForwardScanDirection);
+ AssertTupleDescHasOid(pgdbrel->rd_att);
if (!HeapTupleIsValid(tup) ||
- tup->t_data->t_oid != MyDatabaseId)
+ HeapTupleGetOid(tup) != MyDatabaseId)
{
/* OOPS */
heap_close(pgdbrel, AccessShareLock);
diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c
index 9b2cb49022..fd80b23bb8 100644
--- a/src/backend/utils/misc/database.c
+++ b/src/backend/utils/misc/database.c
@@ -8,7 +8,7 @@
*
*
* 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)
if (strcmp(name, NameStr(tup_db->datname)) == 0)
{
/* 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;
if (pathlen < 0)
pathlen = 0; /* pure paranoia */