diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index f32e35a..4abba83 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -807,7 +807,7 @@ gistGetFakeLSN(Relation rel)
 {
 	static XLogRecPtr counter = 1;
 
-	if (rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
+	if (RelationGetPersistence(rel) == RELPERSISTENCE_TEMP)
 	{
 		/*
 		 * Temporary relations are only accessible in our session, so a simple
@@ -821,7 +821,7 @@ gistGetFakeLSN(Relation rel)
 		 * Unlogged relations are accessible from other backends, and survive
 		 * (clean) restarts. GetFakeLSNForUnloggedRel() handles that for us.
 		 */
-		Assert(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED);
+		Assert(RelationGetPersistence(rel) == RELPERSISTENCE_UNLOGGED);
 		return GetFakeLSNForUnloggedRel();
 	}
 }
diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c
index 01ed880..ba896f7 100644
--- a/src/backend/catalog/index.c
+++ b/src/backend/catalog/index.c
@@ -723,7 +723,7 @@ index_create(Relation heapRelation,
 	namespaceId = RelationGetNamespace(heapRelation);
 	shared_relation = heapRelation->rd_rel->relisshared;
 	mapped_relation = RelationIsMapped(heapRelation);
-	relpersistence = heapRelation->rd_rel->relpersistence;
+	relpersistence = RelationGetPersistence(heapRelation);
 
 	/*
 	 * check parameters
@@ -1965,7 +1965,7 @@ index_build(Relation heapRelation,
 	 * created it, or truncated twice in a subsequent transaction, the
 	 * relfilenode won't change, and nothing needs to be done here.
 	 */
-	if (heapRelation->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
+	if (RelationGetPersistence(heapRelation) == RELPERSISTENCE_UNLOGGED &&
 		!smgrexists(indexRelation->rd_smgr, INIT_FORKNUM))
 	{
 		RegProcedure ambuildempty = indexRelation->rd_am->ambuildempty;
diff --git a/src/backend/catalog/toasting.c b/src/backend/catalog/toasting.c
index 160f006..cf20fbb 100644
--- a/src/backend/catalog/toasting.c
+++ b/src/backend/catalog/toasting.c
@@ -280,7 +280,7 @@ create_toast_table(Relation rel, Oid toastOid, Oid toastIndexOid,
 										   tupdesc,
 										   NIL,
 										   RELKIND_TOASTVALUE,
-										   rel->rd_rel->relpersistence,
+										   RelationGetPersistence(rel),
 										   shared_relation,
 										   mapped_relation,
 										   true,
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index ff80b09..7bb68d7 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -575,7 +575,7 @@ rebuild_relation(Relation OldHeap, Oid indexOid, bool verbose)
 
 	/* Create the transient table that will receive the re-ordered data */
 	OIDNewHeap = make_new_heap(tableOid, tableSpace,
-							   OldHeap->rd_rel->relpersistence,
+							   RelationGetPersistence(OldHeap),
 							   AccessExclusiveLock);
 
 	/* Copy the heap data into the new table in the desired order */
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 3c1e90e..2aea20b 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -416,7 +416,7 @@ DefineIndex(Oid relationId,
 	}
 	else
 	{
-		tablespaceId = GetDefaultTablespace(rel->rd_rel->relpersistence);
+		tablespaceId = GetDefaultTablespace(RelationGetPersistence(rel));
 		/* note InvalidOid is OK in this case */
 	}
 
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c
index 30bd40d..605c9cd 100644
--- a/src/backend/commands/matview.c
+++ b/src/backend/commands/matview.c
@@ -258,7 +258,7 @@ ExecRefreshMatView(RefreshMatViewStmt *stmt, const char *queryString,
 	else
 	{
 		tableSpace = matviewRel->rd_rel->reltablespace;
-		relpersistence = matviewRel->rd_rel->relpersistence;
+		relpersistence = RelationGetPersistence(matviewRel);
 	}
 
 	/*
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index ecdff1e..21d11bc 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -1197,7 +1197,7 @@ ExecuteTruncate(TruncateStmt *stmt)
 			 * deletion at commit.
 			 */
 			RelationSetNewRelfilenode(rel, RecentXmin, minmulti);
-			if (rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED)
+			if (RelationGetPersistence(rel) == RELPERSISTENCE_UNLOGGED)
 				heap_create_init_fork(rel);
 
 			heap_relid = RelationGetRelid(rel);
@@ -1210,7 +1210,7 @@ ExecuteTruncate(TruncateStmt *stmt)
 			{
 				rel = relation_open(toast_relid, AccessExclusiveLock);
 				RelationSetNewRelfilenode(rel, RecentXmin, minmulti);
-				if (rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED)
+				if (RelationGetPersistence(rel) == RELPERSISTENCE_UNLOGGED)
 					heap_create_init_fork(rel);
 				heap_close(rel, NoLock);
 			}
@@ -1502,14 +1502,14 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
 							parent->relname)));
 		/* Permanent rels cannot inherit from temporary ones */
 		if (relpersistence != RELPERSISTENCE_TEMP &&
-			relation->rd_rel->relpersistence == RELPERSISTENCE_TEMP)
+			RelationGetPersistence(relation) == RELPERSISTENCE_TEMP)
 			ereport(ERROR,
 					(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 					 errmsg("cannot inherit from temporary relation \"%s\"",
 							parent->relname)));
 
 		/* If existing rel is temp, it must belong to this session */
-		if (relation->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
+		if (RelationGetPersistence(relation) == RELPERSISTENCE_TEMP &&
 			!relation->rd_islocaltemp)
 			ereport(ERROR,
 					(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -3704,7 +3704,7 @@ ATRewriteTables(List **wqueue, LOCKMODE lockmode)
 			 * user requested a change)
 			 */
 			persistence = tab->chgPersistence ?
-				tab->newrelpersistence : OldHeap->rd_rel->relpersistence;
+				tab->newrelpersistence : RelationGetPersistence(OldHeap);
 
 			heap_close(OldHeap, NoLock);
 
@@ -6051,23 +6051,23 @@ ATAddForeignKeyConstraint(AlteredTableInfo *tab, Relation rel,
 	 * backends might need to run the RI triggers on the perm table, but they
 	 * can't reliably see tuples in the local buffers of other backends.
 	 */
-	switch (rel->rd_rel->relpersistence)
+	switch (RelationGetPersistence(rel))
 	{
 		case RELPERSISTENCE_PERMANENT:
-			if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+			if (RelationGetPersistence(pkrel) != RELPERSISTENCE_PERMANENT)
 				ereport(ERROR,
 						(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
 						 errmsg("constraints on permanent tables may reference only permanent tables")));
 			break;
 		case RELPERSISTENCE_UNLOGGED:
-			if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT
-				&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
+			if (RelationGetPersistence(pkrel) != RELPERSISTENCE_PERMANENT
+				&& RelationGetPersistence(pkrel) != RELPERSISTENCE_UNLOGGED)
 				ereport(ERROR,
 						(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
 						 errmsg("constraints on unlogged tables may reference only permanent or unlogged tables")));
 			break;
 		case RELPERSISTENCE_TEMP:
-			if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_TEMP)
+			if (RelationGetPersistence(pkrel) != RELPERSISTENCE_TEMP)
 				ereport(ERROR,
 						(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
 						 errmsg("constraints on temporary tables may reference only temporary tables")));
@@ -9241,7 +9241,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
 	 * to allocate a new one in the new tablespace.
 	 */
 	newrelfilenode = GetNewRelFileNode(newTableSpace, NULL,
-									   rel->rd_rel->relpersistence);
+									   RelationGetPersistence(rel));
 
 	/* Open old and new relation */
 	newrnode = rel->rd_node;
@@ -9258,11 +9258,11 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
 	 * NOTE: any conflict in relfilenode value will be caught in
 	 * RelationCreateStorage().
 	 */
-	RelationCreateStorage(newrnode, rel->rd_rel->relpersistence);
+	RelationCreateStorage(newrnode, RelationGetPersistence(rel));
 
 	/* copy main fork */
 	copy_relation_data(rel->rd_smgr, dstrel, MAIN_FORKNUM,
-					   rel->rd_rel->relpersistence);
+					   RelationGetPersistence(rel));
 
 	/* copy those extra forks that exist */
 	for (forkNum = MAIN_FORKNUM + 1; forkNum <= MAX_FORKNUM; forkNum++)
@@ -9271,7 +9271,7 @@ ATExecSetTableSpace(Oid tableOid, Oid newTableSpace, LOCKMODE lockmode)
 		{
 			smgrcreate(dstrel, forkNum, false);
 			copy_relation_data(rel->rd_smgr, dstrel, forkNum,
-							   rel->rd_rel->relpersistence);
+							   RelationGetPersistence(rel));
 		}
 	}
 
@@ -9625,22 +9625,22 @@ ATExecAddInherit(Relation child_rel, RangeVar *parent, LOCKMODE lockmode)
 	ATSimplePermissions(parent_rel, ATT_TABLE);
 
 	/* Permanent rels cannot inherit from temporary ones */
-	if (parent_rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
-		child_rel->rd_rel->relpersistence != RELPERSISTENCE_TEMP)
+	if (RelationGetPersistence(parent_rel) == RELPERSISTENCE_TEMP &&
+		RelationGetPersistence(child_rel) != RELPERSISTENCE_TEMP)
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 				 errmsg("cannot inherit from temporary relation \"%s\"",
 						RelationGetRelationName(parent_rel))));
 
 	/* If parent rel is temp, it must belong to this session */
-	if (parent_rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
+	if (RelationGetPersistence(parent_rel) == RELPERSISTENCE_TEMP &&
 		!parent_rel->rd_islocaltemp)
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
 		errmsg("cannot inherit from temporary relation of another session")));
 
 	/* Ditto for the child */
-	if (child_rel->rd_rel->relpersistence == RELPERSISTENCE_TEMP &&
+	if (RelationGetPersistence(child_rel) == RELPERSISTENCE_TEMP &&
 		!child_rel->rd_islocaltemp)
 		ereport(ERROR,
 				(errcode(ERRCODE_WRONG_OBJECT_TYPE),
@@ -10781,7 +10781,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
 	 * get away with doing nothing; in such cases we don't need to run the
 	 * checks below, either.
 	 */
-	switch (rel->rd_rel->relpersistence)
+	switch (RelationGetPersistence(rel))
 	{
 		case RELPERSISTENCE_TEMP:
 			ereport(ERROR,
@@ -10844,7 +10844,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
 
 			if (toLogged)
 			{
-				if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+				if (RelationGetPersistence(foreignrel) != RELPERSISTENCE_PERMANENT)
 					ereport(ERROR,
 							(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
 						 errmsg("cannot change status of table %s to logged",
@@ -10856,7 +10856,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
 			}
 			else
 			{
-				if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+				if (RelationGetPersistence(foreignrel) == RELPERSISTENCE_PERMANENT)
 					ereport(ERROR,
 							(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
 					   errmsg("cannot change status of table %s to unlogged",
diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c
index 184bcd0..551858c 100644
--- a/src/backend/commands/view.c
+++ b/src/backend/commands/view.c
@@ -162,7 +162,7 @@ DefineVirtualRelation(RangeVar *relation, List *tlist, bool replace,
 		 * should only end up replacing a temporary view with another
 		 * temporary view, and similarly for permanent views.
 		 */
-		Assert(relation->relpersistence == rel->rd_rel->relpersistence);
+		Assert(relation->relpersistence == RelationGetPersistence(rel));
 
 		/*
 		 * Create a tuple descriptor to compare against the existing view, and
diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c
index 478584d..fe3de1f 100644
--- a/src/backend/parser/parse_relation.c
+++ b/src/backend/parser/parse_relation.c
@@ -2921,7 +2921,7 @@ isQueryUsingTempRelation_walker(Node *node, void *context)
 			if (rte->rtekind == RTE_RELATION)
 			{
 				Relation	rel = heap_open(rte->relid, AccessShareLock);
-				char		relpersistence = rel->rd_rel->relpersistence;
+				char		relpersistence = RelationGetPersistence(rel);
 
 				heap_close(rel, AccessShareLock);
 				if (relpersistence == RELPERSISTENCE_TEMP)
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index 57067ef..6106bb1 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -536,7 +536,7 @@ ReadBufferExtended(Relation reln, ForkNumber forkNum, BlockNumber blockNum,
 	 * miss.
 	 */
 	pgstat_count_buffer_read(reln);
-	buf = ReadBuffer_common(reln->rd_smgr, reln->rd_rel->relpersistence,
+	buf = ReadBuffer_common(reln->rd_smgr, RelationGetPersistence(reln),
 							forkNum, blockNum, mode, strategy, &hit);
 	if (hit)
 		pgstat_count_buffer_hit(reln);
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index c813779..3994b8c 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -987,7 +987,7 @@ RelationBuildDesc(Oid targetRelId, bool insertIt)
 	relation->rd_isnailed = false;
 	relation->rd_createSubid = InvalidSubTransactionId;
 	relation->rd_newRelfilenodeSubid = InvalidSubTransactionId;
-	switch (relation->rd_rel->relpersistence)
+	switch (RelationGetPersistence(relation))
 	{
 		case RELPERSISTENCE_UNLOGGED:
 		case RELPERSISTENCE_PERMANENT:
@@ -1023,7 +1023,7 @@ RelationBuildDesc(Oid targetRelId, bool insertIt)
 			break;
 		default:
 			elog(ERROR, "invalid relpersistence: %c",
-				 relation->rd_rel->relpersistence);
+				 RelationGetPersistence(relation));
 			break;
 	}
 
@@ -1612,7 +1612,7 @@ formrdesc(const char *relationName, Oid relationReltype,
 		relation->rd_rel->reltablespace = GLOBALTABLESPACE_OID;
 
 	/* formrdesc is used only for permanent relations */
-	relation->rd_rel->relpersistence = RELPERSISTENCE_PERMANENT;
+	RelationGetPersistence(relation) = RELPERSISTENCE_PERMANENT;
 
 	/* ... and they're always populated, too */
 	relation->rd_rel->relispopulated = true;
@@ -3023,7 +3023,7 @@ RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid,
 
 	/* Allocate a new relfilenode */
 	newrelfilenode = GetNewRelFileNode(relation->rd_rel->reltablespace, NULL,
-									   relation->rd_rel->relpersistence);
+									   RelationGetPersistence(relation));
 
 	/*
 	 * Get a writable copy of the pg_class tuple for the given relation.
@@ -3046,7 +3046,7 @@ RelationSetNewRelfilenode(Relation relation, TransactionId freezeXid,
 	newrnode.node = relation->rd_node;
 	newrnode.node.relNode = newrelfilenode;
 	newrnode.backend = relation->rd_backend;
-	RelationCreateStorage(newrnode.node, relation->rd_rel->relpersistence);
+	RelationCreateStorage(newrnode.node, RelationGetPersistence(relation));
 	smgrclosenode(newrnode);
 
 	/*
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 198b98f..24fd3b6 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -428,6 +428,13 @@ typedef struct ViewOptions
 	} while (0)
 
 /*
+ * RelationGetPersistence
+ *		Get relation persistence
+ */
+#define RelationGetPersistence(relation) \
+	((relation)->rd_rel->relpersistence)
+
+/*
  * RelationNeedsWAL
  *		True if relation needs WAL.
  */
