summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorBruce Momjian2021-03-23 00:22:48 +0000
committerBruce Momjian2021-03-23 00:23:52 +0000
commit95d77149c53545a74e0c84717cf8f925b8f6d632 (patch)
treec7a2e9f91ac8b42b5c10684edcb597ede25d075d /src/include
parent8e4b332e88b8339408a3aa8c62bc93d96b67c808 (diff)
Add macro RelationIsPermanent() to report relation permanence
Previously, to check relation permanence, the Relation's Form_pg_class structure member relpersistence was compared to the value RELPERSISTENCE_PERMANENT ("p"). This commit adds the macro RelationIsPermanent() and is used in appropirate places to simplify the code. This matches other RelationIs* macros. This macro will be used in more places in future cluster file encryption patches. Discussion: https://postgr.es/m/20210318153134.GH20766@tamriel.snowman.net
Diffstat (limited to 'src/include')
-rw-r--r--src/include/utils/rel.h10
-rw-r--r--src/include/utils/snapmgr.h3
2 files changed, 9 insertions, 4 deletions
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 5375a37dd19..8eee1c1a835 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -578,6 +578,13 @@ typedef struct PartitionedTableRdOptions
} while (0)
/*
+ * RelationIsPermanent
+ * True if relation is permanent.
+ */
+#define RelationIsPermanent(relation) \
+ ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+
+/*
* RelationNeedsWAL
* True if relation needs WAL.
*
@@ -586,8 +593,7 @@ typedef struct PartitionedTableRdOptions
* RelFileNode" in src/backend/access/transam/README.
*/
#define RelationNeedsWAL(relation) \
- ((relation)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT && \
- (XLogIsNeeded() || \
+ (RelationIsPermanent(relation) && (XLogIsNeeded() || \
(relation->rd_createSubid == InvalidSubTransactionId && \
relation->rd_firstRelfilenodeSubid == InvalidSubTransactionId)))
diff --git a/src/include/utils/snapmgr.h b/src/include/utils/snapmgr.h
index 2c8b881a09d..f66ac581885 100644
--- a/src/include/utils/snapmgr.h
+++ b/src/include/utils/snapmgr.h
@@ -37,8 +37,7 @@
*/
#define RelationAllowsEarlyPruning(rel) \
( \
- (rel)->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT \
- && !IsCatalogRelation(rel) \
+ RelationIsPermanent(rel) && !IsCatalogRelation(rel) \
&& !RelationIsAccessibleInLogicalDecoding(rel) \
)