1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-21 05:21:08 +03:00

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
This commit is contained in:
Bruce Momjian
2021-03-22 20:22:48 -04:00
parent 8e4b332e88
commit 95d77149c5
8 changed files with 19 additions and 15 deletions

View File

@@ -577,6 +577,13 @@ typedef struct PartitionedTableRdOptions
(relation)->rd_smgr->smgr_targblock = (targblock); \
} 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)))