From f56b5fb25a25edc1d5a7bba1f9b03665256dbd24 Mon Sep 17 00:00:00 2001 From: Ashwin Agrawal Date: Mon, 25 Jun 2018 16:07:25 -0700 Subject: [PATCH] Remove rd_issyscat from RelationData. Greenplum added rd_isyscat to Relation structure. Only usage of the same is in markDirty() to decide if buffer should be marked dirty or not. The setting of rd_issyscat is based in checking if relation name starts with "pg_" then set it else not. Which anyways is very loose. Modified instead to just make check based on if oid < FirstNormalObjectId or to cover for pg_aoseg tables RelationGetNamespace(relation) == PG_AOSEGMENT_NAMESPACE. So, this allows us to remove the extra variable. This patch is not trying to change the intent of GUC `gp_disable_tuple_hints`. That's all together different discussion. --- src/backend/utils/cache/relcache.c | 5 ----- src/backend/utils/time/tqual.c | 8 +++++--- src/include/utils/rel.h | 2 -- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 7a4b6e0300..9dc16988ef 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -866,7 +866,6 @@ RelationBuildDesc(Oid targetRelId, bool insertIt) relation->rd_isnailed = false; relation->rd_createSubid = InvalidSubTransactionId; relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; - relation->rd_issyscat = (strncmp(relation->rd_rel->relname.data, "pg_", 3) == 0); switch (relation->rd_rel->relpersistence) { @@ -1414,7 +1413,6 @@ formrdesc(const char *relationName, Oid relationReltype, relation->rd_createSubid = InvalidSubTransactionId; relation->rd_newRelfilenodeSubid = InvalidSubTransactionId; relation->rd_backend = InvalidBackendId; - relation->rd_issyscat = (strncmp(relationName, "pg_", 3) == 0); /* GP */ /* * initialize relation tuple form @@ -2636,9 +2634,6 @@ RelationBuildLocalRelation(const char *relname, /* must flag that we have rels created in this transaction */ need_eoxact_work = true; - /* is it a system catalog? */ - rel->rd_issyscat = (strncmp(relname, "pg_", 3) == 0); - /* * create a new tuple descriptor from the one passed in. We do this * partly to copy it into the cache context, and partly because the new diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index 922be515dd..db20497261 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -65,6 +65,7 @@ #include "storage/procarray.h" #include "utils/tqual.h" +#include "catalog/pg_namespace.h" #include "cdb/cdbtm.h" #include "cdb/cdbvars.h" @@ -100,12 +101,13 @@ markDirty(Buffer buffer, Relation relation, HeapTupleHeader tuple, bool isXmin) } /* - * The GUC gp_disable_tuple_hints is on. Do further evaluation whether we want to write out the - * buffer or not. + * The GUC gp_disable_tuple_hints is on. Do further evaluation whether we + * want to write out the buffer or not. */ Assert(relation != NULL); - if (relation->rd_issyscat) + if (RelationGetRelid(relation) < FirstNormalObjectId || + RelationGetNamespace(relation) == PG_AOSEGMENT_NAMESPACE) { /* Assume we want to always mark the buffer dirty */ MarkBufferDirtyHint(buffer); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index f7ce0660d6..629fca4c10 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -136,8 +136,6 @@ typedef struct RelationData struct SMgrRelationData *rd_smgr; /* cached file handle, or NULL */ int rd_refcnt; /* reference count */ BackendId rd_backend; /* owning backend id, if temporary relation */ - // GPDB_91_MERGE_FIXME: is rd_issyscat still needed? - bool rd_issyscat; /* GP: true => system catalog table (has "pg_" prefix) */ bool rd_isnailed; /* rel is nailed in cache */ bool rd_isvalid; /* relcache entry is valid */ char rd_indexvalid; /* state of rd_indexlist: 0 = not valid, 1 = -- GitLab