diff options
author | Bruce Momjian <bruce@momjian.us> | 2002-07-20 05:16:59 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2002-07-20 05:16:59 +0000 |
commit | b0f5086e4133d1d8ec092799952dda65ebd717c8 (patch) | |
tree | 0f717342af7cce7896d40fdb34ccc572e435d499 /src/backend/utils/cache | |
parent | 38dd3ae7d032eecc6ddadcbd402d90f6ac38f6a3 (diff) | |
download | postgresql-b0f5086e4133d1d8ec092799952dda65ebd717c8.tar.gz postgresql-b0f5086e4133d1d8ec092799952dda65ebd717c8.zip |
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/cache')
-rw-r--r-- | src/backend/utils/cache/catcache.c | 21 | ||||
-rw-r--r-- | src/backend/utils/cache/inval.c | 7 | ||||
-rw-r--r-- | src/backend/utils/cache/relcache.c | 17 | ||||
-rw-r--r-- | src/backend/utils/cache/syscache.c | 4 |
4 files changed, 30 insertions, 19 deletions
diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index a4f05a7d117..21f1e01dabb 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 02a6d8f8ddc..c2929262381 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 532c68f7b3a..d7fd83775b1 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 5f0be16b75a..9966a8d881f 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; } |