public inbox for [email protected]
help / color / mirror / Atom feed[PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
50+ messages / 3 participants
[nested] [flat]
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-12 01:02 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-12 01:02 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--LQksG6bCIzRHxTLp
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit
@ 2021-03-15 14:20 Bruce Momjian <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Bruce Momjian @ 2021-03-15 14:20 UTC (permalink / raw)
---
src/backend/access/gist/gistutil.c | 2 +-
src/backend/access/heap/heapam_handler.c | 2 +-
src/backend/catalog/pg_publication.c | 2 +-
src/backend/commands/tablecmds.c | 10 +++++-----
src/backend/optimizer/util/plancat.c | 3 +--
src/backend/utils/cache/relcache.c | 2 +-
src/include/utils/rel.h | 10 ++++++++--
src/include/utils/snapmgr.h | 3 +--
8 files changed, 19 insertions(+), 15 deletions(-)
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index a3ec9f2cfe..1ff1bf816f 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -1036,7 +1036,7 @@ gistGetFakeLSN(Relation rel)
return counter++;
}
- else if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ else if (RelationIsPermanent(rel))
{
/*
* WAL-logging on this relation will start after commit, so its LSNs
diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c
index bd5faf0c1f..0da8f00443 100644
--- a/src/backend/access/heap/heapam_handler.c
+++ b/src/backend/access/heap/heapam_handler.c
@@ -660,7 +660,7 @@ heapam_relation_copy_data(Relation rel, const RelFileNode *newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(newrnode, forkNum);
diff --git a/src/backend/catalog/pg_publication.c b/src/backend/catalog/pg_publication.c
index 84d2efcfd2..86e415af89 100644
--- a/src/backend/catalog/pg_publication.c
+++ b/src/backend/catalog/pg_publication.c
@@ -67,7 +67,7 @@ check_publication_add_relation(Relation targetrel)
errdetail("System tables cannot be added to publications.")));
/* UNLOGGED and TEMP relations cannot be part of publication. */
- if (targetrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(targetrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("table \"%s\" cannot be replicated",
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 559fa1d2e5..3dcd797cae 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8553,13 +8553,13 @@ ATAddForeignKeyConstraint(List **wqueue, AlteredTableInfo *tab, Relation rel,
switch (rel->rd_rel->relpersistence)
{
case RELPERSISTENCE_PERMANENT:
- if (pkrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(pkrel))
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
+ if (!RelationIsPermanent(pkrel)
&& pkrel->rd_rel->relpersistence != RELPERSISTENCE_UNLOGGED)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
@@ -13598,7 +13598,7 @@ index_copy_data(Relation rel, RelFileNode newrnode)
* WAL log creation if the relation is persistent, or this is the
* init fork of an unlogged relation.
*/
- if (rel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT ||
+ if (RelationIsPermanent(rel) ||
(rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED &&
forkNum == INIT_FORKNUM))
log_smgrcreate(&newrnode, forkNum);
@@ -15035,7 +15035,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
if (toLogged)
{
- if (foreignrel->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT)
+ if (!RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to logged because it references unlogged table \"%s\"",
@@ -15045,7 +15045,7 @@ ATPrepChangePersistence(Relation rel, bool toLogged)
}
else
{
- if (foreignrel->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT)
+ if (RelationIsPermanent(foreignrel))
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("could not change table \"%s\" to unlogged because it references logged table \"%s\"",
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index c5947fa418..7f2e40ae39 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -126,8 +126,7 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
relation = table_open(relationObjectId, NoLock);
/* Temporary and unlogged relations are inaccessible during recovery. */
- if (relation->rd_rel->relpersistence != RELPERSISTENCE_PERMANENT &&
- RecoveryInProgress())
+ if (!RelationIsPermanent(relation) && RecoveryInProgress())
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("cannot access temporary or unlogged relations during recovery")));
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 7ef510cd01..a4dbc286cb 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -2989,7 +2989,7 @@ static void
AssertPendingSyncConsistency(Relation relation)
{
bool relcache_verdict =
- relation->rd_rel->relpersistence == RELPERSISTENCE_PERMANENT &&
+ RelationIsPermanent(relation) &&
((relation->rd_createSubid != InvalidSubTransactionId &&
RELKIND_HAS_STORAGE(relation->rd_rel->relkind)) ||
relation->rd_firstRelfilenodeSubid != InvalidSubTransactionId);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 10b63982c0..9a3a03e520 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -552,6 +552,13 @@ typedef struct ViewOptions
(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.
@@ -561,8 +568,7 @@ typedef struct ViewOptions
* 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 2c8b881a09..f66ac58188 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) \
)
--
2.20.1
--AhhlLboLdkugWU4S
Content-Type: text/x-diff; charset=us-ascii
Content-Disposition: attachment;
filename="cfe-12-gist_over_cfe-11-persistent.diff"
^ permalink raw reply [nested|flat] 50+ messages in thread
* Re: Add WALRCV_CONNECTING state to walreceiver
@ 2026-01-11 12:56 Xuneng Zhou <[email protected]>
2026-01-19 00:13 ` Re: Add WALRCV_CONNECTING state to walreceiver Michael Paquier <[email protected]>
0 siblings, 1 reply; 50+ messages in thread
From: Xuneng Zhou @ 2026-01-11 12:56 UTC (permalink / raw)
To: Rahila Syed <[email protected]>; +Cc: Noah Misch <[email protected]>; pgsql-hackers <[email protected]>; Michael Paquier <[email protected]>
Hi,
On Mon, Dec 15, 2025 at 11:38 PM Xuneng Zhou <[email protected]> wrote:
>
> Hi Rahila,
>
> Thanks for looking into this.
>
> On Mon, Dec 15, 2025 at 9:48 PM Rahila Syed <[email protected]> wrote:
> >
> >
> > Hi,
> >
> > On Mon, Dec 15, 2025 at 9:44 AM Noah Misch <[email protected]> wrote:
> >>
> >> On Sun, Dec 14, 2025 at 06:17:34PM +0800, Xuneng Zhou wrote:
> >> > On Sun, Dec 14, 2025 at 4:55 PM Xuneng Zhou <[email protected]> wrote:
> >> > > On Sun, Dec 14, 2025 at 1:14 PM Noah Misch <[email protected]> wrote:
> >> > > > > V2 makes the transition from WALRCV_CONNECTING to STREAMING only when
> >> > > > > the first valid WAL record is processed by the startup process. A new
> >> > > > > function WalRcvSetStreaming is introduced to enable the transition.
> >> > > >
> >> > > > The original patch set STREAMING in XLogWalRcvFlush(). XLogWalRcvFlush()
> >> > > > callee XLogWalRcvSendReply() already fetches applyPtr to send a status
> >> > > > message. So I would try the following before involving the startup process
> >> > > > like v2 does:
> >> > > >
> >> > > > 1. store the applyPtr when we enter CONNECTING
> >> > > > 2. force a status message as long as we remain in CONNECTING
> >> > > > 3. become STREAMING when applyPtr differs from the one stored at (1)
> >> > >
> >> > > Thanks for the suggestion. Using XLogWalRcvSendReply() for the
> >> > > transition could make sense. My concern before is about latency in a
> >> > > rare case: if the first flush completes but applyPtr hasn't advanced
> >> > > yet at the time of check and then the flush stalls after that, we
> >> > > might wait up to wal_receiver_status_interval (default 10s) before the
> >> > > next check or indefinitely if (wal_receiver_status_interval <= 0).
> >> > > This could be mitigated by shortening the wakeup interval while in
> >> > > CONNECTING (step 2), which reduces worst-case latency to ~1 second.
> >> > > Given that monitoring typically doesn't require sub-second precision,
> >> > > this approach could be feasible.
> >> > >
> >> > > case WALRCV_WAKEUP_REPLY:
> >> > > if (WalRcv->walRcvState == WALRCV_CONNECTING)
> >> > > {
> >> > > /* Poll frequently while CONNECTING to avoid long latency */
> >> > > wakeup[reason] = TimestampTzPlusMilliseconds(now, 1000);
> >> > > }
> >> > >
> >> > > > A possible issue with all patch versions: when the primary is writing no WAL
> >> > > > and the standby was caught up before this walreceiver started, CONNECTING
> >> > > > could persist for an unbounded amount of time. Only actual primary WAL
> >> > > > generation would move the walreceiver to STREAMING. This relates to your
> >> > > > above point about high latency. If that's a concern, perhaps this change
> >> > > > deserves a total of two new states, CONNECTING and a state that represents
> >> > > > "connection exists, no WAL yet applied"?
> >> > >
> >> > > Yes, this could be an issue. Using two states would help address it.
> >> > > That said, when the primary is idle in this case, we might end up
> >> > > repeatedly polling the apply status in the state before streaming if
> >> > > we implement the 1s short-interval checking like above, which could be
> >> > > costful. However, If we do not implement it &&
> >> > > wal_receiver_status_interval is set to < 0 && flush stalls, the
> >> > > walreceiver could stay in the pre-streaming state indefinitely even if
> >> > > streaming did occur, which violates the semantics. Do you think this
> >> > > is a valid concern or just an artificial edge case?
> >> >
> >> > After looking more closely, I found that true indefinite waiting
> >> > requires ALL of:
> >> >
> >> > wal_receiver_status_interval <= 0 (disables status updates)
> >> > wal_receiver_timeout <= 0
> >> > Primary sends no keepalives
> >> > No more WAL arrives after the first failed-check flush
> >> > Startup never sets force_reply
> >> >
> >> > which is quite impossible and artificial, sorry for the noise here.
> >>
> >> Even if indefinite wait is a negligible concern, you identified a lot of
> >> intricacy that I hadn't pictured. That makes your startup-process-driven
> >> version potentially more attractive. Forcing status messages like I was
> >> thinking may also yield an unwanted flurry of them if the startup process is
> >> slow. Let's see what the patch reviewer thinks.
> >
> >
> > FWIW, I think doing it in startup might be slightly better.
> > It seems more logical to make the state change near the point where the status
> > is updated, as this helps prevent reading the status from shared memory and
> > reduces related delays.
> >
> > The current proposal is to advance the state to STREAMING after applyPtr has
> > been updated.
> > IIUC, the rationale is to avoid having a short-lived streaming state if applying WAL fails.
> > However, this approach can be confusing because the receiver may already be receiving
> > WAL from the primary, yet its state remains CONNECTING until the WAL is flushed.
> >
> > Would it be better to advance the state to streaming after the connection
> > is successfully established and the following LOG message is emitted?
> >
> > if (walrcv_startstreaming(wrconn, &options))
> > {
> > if (first_stream)
> > ereport(LOG,
> > errmsg("started streaming WAL from primary at %X/%08X on timeline %u",
> > LSN_FORMAT_ARGS(startpoint), startpointTLI));
>
> AFAICS, this may depend on how we define the streaming status. If
> streaming is defined simply as “the connection has been established
> and walreceiver is ready to operate,” then this approach fits well and
> keeps the model simple. However, if streaming is meant to indicate
> that WAL has actually started flowing and replay is in progress, then
> this approach could fall short, particularly for the short-lived
> streaming cases you mentioned. Introducing finer-grained states can
> handle these edge cases more accurately, but it also makes the state
> transitions more complex. That said, I’m not well positioned to fully
> evaluate the trade-offs here, as I’m not a day-to-day end user.
>
After some thoughts, I’m more inclined toward a startup-process–driven
approach. Marking the status as streaming immediately after the
connection is established seems not provide sufficient accuracy for
monitoring purposes. Introducing an intermediate state, such as
connected, would help reduce confusion when the startup process is
stalled and would make it easier for users to detect and diagnose
anomalies.
V4 whitelisted CONNECTED and CONNECTING in WalRcvWaitForStartPosition
to handle valid stream termination scenarios without triggering a
FATAL error.
Specifically, the walreceiver may need to transition to WAITING (idle) if:
1. 'CONNECTED': The handshake succeeded (COPY_BOTH started), but
the stream ended before any WAL was applied (e.g., timeline divergence
detected mid-stream).
2. 'CONNECTING': The handshake completed (START_REPLICATION
acknowledged), but the primary declined to stream (e.g., no WAL
available on the requested timeline).
In both cases, the receiver should pause and await a new timeline or
restart position from the startup process.
Both approaches have been updated.
--
Best,
Xuneng
Attachments:
[application/octet-stream] v4-0001-Add-WALRCV_CONNECTING-and-WALRCV_CONNECTED-states.patch (7.8K, ../../CABPTF7WEqEcLqOS_ytAEWfwV8AZhNsMZwSpdJxtEacQ--xu1TA@mail.gmail.com/2-v4-0001-Add-WALRCV_CONNECTING-and-WALRCV_CONNECTED-states.patch)
download | inline diff:
From bfa242f68ebdbab65c3ff196b3285f643b0cb96a Mon Sep 17 00:00:00 2001
From: alterego655 <[email protected]>
Date: Sun, 11 Jan 2026 15:57:16 +0800
Subject: [PATCH v4] Add WALRCV_CONNECTING and WALRCV_CONNECTED states to
walreceiver
Previously, walreceiver set status='streaming' early in startup before
receiving any WAL, making it unreliable for health monitoring.
Introduce two intermediate states:
- WALRCV_CONNECTING: Walreceiver enters CONNECTING on startup
- WALRCV_CONNECTED: Walreceiver transitions from CONNECTING to
CONNECTED after START_REPLICATION succeeded, awaiting first WAL record
The final transition from CONNECTED to STREAMING occurs when startup
successfully applies the first record, confirming end-to-end data flow.
This allows monitoring tools to distinguish connection establishment
from active WAL streaming.
---
src/backend/access/transam/xlogrecovery.c | 18 ++++++++++++++
src/backend/replication/walreceiver.c | 20 ++++++++++++---
src/backend/replication/walreceiverfuncs.c | 29 +++++++++++++++++++++-
src/include/replication/walreceiver.h | 4 +++
4 files changed, 67 insertions(+), 4 deletions(-)
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 0b5f871abe7..e56585f3f29 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -250,6 +250,9 @@ static XLogSource currentSource = XLOG_FROM_ANY;
static bool lastSourceFailed = false;
static bool pendingWalRcvRestart = false;
+/* Guard to update walreceiver state only once per streaming session. */
+static bool walrcv_streaming_set = false;
+
/*
* These variables track when we last obtained some WAL data to process,
* and where we got it from. (XLogReceiptSource is initially the same as
@@ -1842,6 +1845,18 @@ PerformWalRecovery(void)
*/
ApplyWalRecord(xlogreader, record, &replayTLI);
+ /*
+ * If we are reading from the stream and successfully applied
+ * the first WAL record, transition to STREAMING state. This
+ * confirms end-to-end data flow: the record was received,
+ * parsed, and applied without error.
+ */
+ if (!walrcv_streaming_set && readSource == XLOG_FROM_STREAM)
+ {
+ if (WalRcvSetStreaming())
+ walrcv_streaming_set = true;
+ }
+
/* Exit loop if we reached inclusive recovery target */
if (recoveryStopsAfter(xlogreader))
{
@@ -3702,6 +3717,9 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
* one can hope...
*/
+ /* Reset our "streaming active" guard flag */
+ walrcv_streaming_set = false;
+
/*
* We should be able to move to XLOG_FROM_STREAM only in
* standby mode.
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index a41453530a1..b97dafa4a44 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -206,6 +206,8 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
break;
case WALRCV_WAITING:
+ case WALRCV_CONNECTING:
+ case WALRCV_CONNECTED:
case WALRCV_STREAMING:
case WALRCV_RESTARTING:
default:
@@ -215,7 +217,7 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
}
/* Advertise our PID so that the startup process can kill us */
walrcv->pid = MyProcPid;
- walrcv->walRcvState = WALRCV_STREAMING;
+ walrcv->walRcvState = WALRCV_CONNECTING;
/* Fetch information required to start streaming */
walrcv->ready_to_display = false;
@@ -395,6 +397,11 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
LSN_FORMAT_ARGS(startpoint), startpointTLI));
first_stream = false;
+ SpinLockAcquire(&walrcv->mutex);
+ if (walrcv->walRcvState == WALRCV_CONNECTING)
+ walrcv->walRcvState = WALRCV_CONNECTED;
+ SpinLockRelease(&walrcv->mutex);
+
/* Initialize LogstreamResult and buffers for processing messages */
LogstreamResult.Write = LogstreamResult.Flush = GetXLogReplayRecPtr(NULL);
initStringInfo(&reply_message);
@@ -650,7 +657,8 @@ WalRcvWaitForStartPosition(XLogRecPtr *startpoint, TimeLineID *startpointTLI)
SpinLockAcquire(&walrcv->mutex);
state = walrcv->walRcvState;
- if (state != WALRCV_STREAMING)
+ if (state != WALRCV_STREAMING && state != WALRCV_CONNECTED &&
+ state != WALRCV_CONNECTING)
{
SpinLockRelease(&walrcv->mutex);
if (state == WALRCV_STOPPING)
@@ -689,7 +697,7 @@ WalRcvWaitForStartPosition(XLogRecPtr *startpoint, TimeLineID *startpointTLI)
*/
*startpoint = walrcv->receiveStart;
*startpointTLI = walrcv->receiveStartTLI;
- walrcv->walRcvState = WALRCV_STREAMING;
+ walrcv->walRcvState = WALRCV_CONNECTING;
SpinLockRelease(&walrcv->mutex);
break;
}
@@ -792,6 +800,8 @@ WalRcvDie(int code, Datum arg)
/* Mark ourselves inactive in shared memory */
SpinLockAcquire(&walrcv->mutex);
Assert(walrcv->walRcvState == WALRCV_STREAMING ||
+ walrcv->walRcvState == WALRCV_CONNECTING ||
+ walrcv->walRcvState == WALRCV_CONNECTED ||
walrcv->walRcvState == WALRCV_RESTARTING ||
walrcv->walRcvState == WALRCV_STARTING ||
walrcv->walRcvState == WALRCV_WAITING ||
@@ -1391,6 +1401,10 @@ WalRcvGetStateString(WalRcvState state)
return "stopped";
case WALRCV_STARTING:
return "starting";
+ case WALRCV_CONNECTING:
+ return "connecting";
+ case WALRCV_CONNECTED:
+ return "connected";
case WALRCV_STREAMING:
return "streaming";
case WALRCV_WAITING:
diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c
index da8794cba7c..c9b6ed6e874 100644
--- a/src/backend/replication/walreceiverfuncs.c
+++ b/src/backend/replication/walreceiverfuncs.c
@@ -179,12 +179,37 @@ WalRcvStreaming(void)
}
if (state == WALRCV_STREAMING || state == WALRCV_STARTING ||
- state == WALRCV_RESTARTING)
+ state == WALRCV_RESTARTING || state == WALRCV_CONNECTING ||
+ state == WALRCV_CONNECTED)
return true;
else
return false;
}
+/*
+ * Transition from CONNECTED to STREAMING state.
+ *
+ * This is called by the startup process after the first WAL record from
+ * the walreceiver is successfully applied, confirming end-to-end data
+ * flow: the record was received, parsed, and applied without error.
+ */
+bool
+WalRcvSetStreaming(void)
+{
+ WalRcvData *walrcv = WalRcv;
+ bool set = false;
+
+ SpinLockAcquire(&walrcv->mutex);
+ if (walrcv->walRcvState == WALRCV_CONNECTED)
+ {
+ walrcv->walRcvState = WALRCV_STREAMING;
+ set = true;
+ }
+ SpinLockRelease(&walrcv->mutex);
+
+ return set;
+}
+
/*
* Stop walreceiver (if running) and wait for it to die.
* Executed by the Startup process.
@@ -211,6 +236,8 @@ ShutdownWalRcv(void)
stopped = true;
break;
+ case WALRCV_CONNECTING:
+ case WALRCV_CONNECTED:
case WALRCV_STREAMING:
case WALRCV_WAITING:
case WALRCV_RESTARTING:
diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h
index f3ad00fb6f3..70159ceb032 100644
--- a/src/include/replication/walreceiver.h
+++ b/src/include/replication/walreceiver.h
@@ -47,6 +47,9 @@ typedef enum
WALRCV_STOPPED, /* stopped and mustn't start up again */
WALRCV_STARTING, /* launched, but the process hasn't
* initialized yet */
+ WALRCV_CONNECTING, /* connection starting, but not established yet */
+ WALRCV_CONNECTED, /* replication connection established, but no WAL
+ * streamed yet */
WALRCV_STREAMING, /* walreceiver is streaming */
WALRCV_WAITING, /* stopped streaming, waiting for orders */
WALRCV_RESTARTING, /* asked to restart streaming */
@@ -492,6 +495,7 @@ extern void WalRcvForceReply(void);
/* prototypes for functions in walreceiverfuncs.c */
extern Size WalRcvShmemSize(void);
extern void WalRcvShmemInit(void);
+extern bool WalRcvSetStreaming(void);
extern void ShutdownWalRcv(void);
extern bool WalRcvStreaming(void);
extern bool WalRcvRunning(void);
--
2.51.0
[application/octet-stream] v4-0001-Add-CONNECTING-CONNECTED-states-to-walreceiver.patch (7.4K, ../../CABPTF7WEqEcLqOS_ytAEWfwV8AZhNsMZwSpdJxtEacQ--xu1TA@mail.gmail.com/3-v4-0001-Add-CONNECTING-CONNECTED-states-to-walreceiver.patch)
download | inline diff:
From 1c44174d1ad60cede082f6dffe193c027ac46da4 Mon Sep 17 00:00:00 2001
From: alterego655 <[email protected]>
Date: Mon, 15 Dec 2025 16:37:07 +0800
Subject: [PATCH v4] Add CONNECTING/CONNECTED states to walreceiver
Previously, walreceiver reported WALRCV_STREAMING immediately after startup,
before it had demonstrated end-to-end WAL flow. This could confuse monitoring
in some cases.
Introduce two intermediate states:
- WALRCV_CONNECTING: walreceiver is starting up
- WALRCV_CONNECTED: START_REPLICATION succeeded, but replay progress has not
yet been observed
Capture a baseline apply pointer when START_REPLICATION succeeds, and promote
to WALRCV_STREAMING once applyPtr advances beyond that baseline.
---
src/backend/replication/walreceiver.c | 49 +++++++++++++++++++---
src/backend/replication/walreceiverfuncs.c | 5 ++-
src/include/replication/walreceiver.h | 3 ++
3 files changed, 51 insertions(+), 6 deletions(-)
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index ac802ae85b4..134359fa08c 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -130,6 +130,7 @@ typedef enum WalRcvWakeupReason
static TimestampTz wakeup[NUM_WALRCV_WAKEUPS];
static StringInfoData reply_message;
+static XLogRecPtr initialApplyPtr = InvalidXLogRecPtr;
/* Prototypes for private functions */
static void WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last);
@@ -204,6 +205,8 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
/* The usual case */
break;
+ case WALRCV_CONNECTING:
+ case WALRCV_CONNECTED:
case WALRCV_WAITING:
case WALRCV_STREAMING:
case WALRCV_RESTARTING:
@@ -214,7 +217,7 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
}
/* Advertise our PID so that the startup process can kill us */
walrcv->pid = MyProcPid;
- walrcv->walRcvState = WALRCV_STREAMING;
+ walrcv->walRcvState = WALRCV_CONNECTING;
/* Fetch information required to start streaming */
walrcv->ready_to_display = false;
@@ -398,6 +401,13 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len)
LogstreamResult.Write = LogstreamResult.Flush = GetXLogReplayRecPtr(NULL);
initStringInfo(&reply_message);
+ /* We are connected, but have not yet applied WAL from this stream */
+ initialApplyPtr = LogstreamResult.Write;
+ SpinLockAcquire(&walrcv->mutex);
+ if (walrcv->walRcvState == WALRCV_CONNECTING)
+ walrcv->walRcvState = WALRCV_CONNECTED;
+ SpinLockRelease(&walrcv->mutex);
+
/* Initialize nap wakeup times. */
now = GetCurrentTimestamp();
for (int i = 0; i < NUM_WALRCV_WAKEUPS; ++i)
@@ -649,7 +659,8 @@ WalRcvWaitForStartPosition(XLogRecPtr *startpoint, TimeLineID *startpointTLI)
SpinLockAcquire(&walrcv->mutex);
state = walrcv->walRcvState;
- if (state != WALRCV_STREAMING)
+ if (state != WALRCV_STREAMING && state != WALRCV_CONNECTED
+ && state != WALRCV_CONNECTING)
{
SpinLockRelease(&walrcv->mutex);
if (state == WALRCV_STOPPING)
@@ -688,8 +699,9 @@ WalRcvWaitForStartPosition(XLogRecPtr *startpoint, TimeLineID *startpointTLI)
*/
*startpoint = walrcv->receiveStart;
*startpointTLI = walrcv->receiveStartTLI;
- walrcv->walRcvState = WALRCV_STREAMING;
+ walrcv->walRcvState = WALRCV_CONNECTING;
SpinLockRelease(&walrcv->mutex);
+ initialApplyPtr = InvalidXLogRecPtr;
break;
}
if (walrcv->walRcvState == WALRCV_STOPPING)
@@ -790,7 +802,9 @@ WalRcvDie(int code, Datum arg)
/* Mark ourselves inactive in shared memory */
SpinLockAcquire(&walrcv->mutex);
- Assert(walrcv->walRcvState == WALRCV_STREAMING ||
+ Assert(walrcv->walRcvState == WALRCV_CONNECTING ||
+ walrcv->walRcvState == WALRCV_CONNECTED ||
+ walrcv->walRcvState == WALRCV_STREAMING ||
walrcv->walRcvState == WALRCV_RESTARTING ||
walrcv->walRcvState == WALRCV_STARTING ||
walrcv->walRcvState == WALRCV_WAITING ||
@@ -989,6 +1003,7 @@ XLogWalRcvFlush(bool dying, TimeLineID tli)
if (LogstreamResult.Flush < LogstreamResult.Write)
{
WalRcvData *walrcv = WalRcv;
+ bool force_reply = false;
issue_xlog_fsync(recvFile, recvSegNo, tli);
@@ -1001,6 +1016,8 @@ XLogWalRcvFlush(bool dying, TimeLineID tli)
walrcv->latestChunkStart = walrcv->flushedUpto;
walrcv->flushedUpto = LogstreamResult.Flush;
walrcv->receivedTLI = tli;
+ if (walrcv->walRcvState == WALRCV_CONNECTED)
+ force_reply = true;
}
SpinLockRelease(&walrcv->mutex);
@@ -1022,7 +1039,7 @@ XLogWalRcvFlush(bool dying, TimeLineID tli)
/* Also let the primary know that we made some progress */
if (!dying)
{
- XLogWalRcvSendReply(false, false);
+ XLogWalRcvSendReply(force_reply, false);
XLogWalRcvSendHSFeedback(false);
}
}
@@ -1129,6 +1146,24 @@ XLogWalRcvSendReply(bool force, bool requestReply)
flushPtr = LogstreamResult.Flush;
applyPtr = GetXLogReplayRecPtr(NULL);
+ /*
+ * If we've established the replication connection but have not yet proven
+ * WAL is flowing end-to-end, flip to STREAMING once applyPtr advances
+ * beyond the baseline captured when START_REPLICATION succeeded.
+ *
+ * We use a volatile pointer for the speculative unlocked read to avoid
+ * compiler caching; the authoritative check is done under the spinlock.
+ */
+ if (((volatile WalRcvData *) WalRcv)->walRcvState == WALRCV_CONNECTED &&
+ XLogRecPtrIsValid(initialApplyPtr) &&
+ applyPtr != initialApplyPtr)
+ {
+ SpinLockAcquire(&WalRcv->mutex);
+ if (WalRcv->walRcvState == WALRCV_CONNECTED)
+ WalRcv->walRcvState = WALRCV_STREAMING;
+ SpinLockRelease(&WalRcv->mutex);
+ }
+
resetStringInfo(&reply_message);
pq_sendbyte(&reply_message, PqReplMsg_StandbyStatusUpdate);
pq_sendint64(&reply_message, writePtr);
@@ -1373,6 +1408,10 @@ WalRcvGetStateString(WalRcvState state)
return "stopped";
case WALRCV_STARTING:
return "starting";
+ case WALRCV_CONNECTING:
+ return "connecting";
+ case WALRCV_CONNECTED:
+ return "connected";
case WALRCV_STREAMING:
return "streaming";
case WALRCV_WAITING:
diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c
index 822645748a7..b0b6e8314b5 100644
--- a/src/backend/replication/walreceiverfuncs.c
+++ b/src/backend/replication/walreceiverfuncs.c
@@ -179,7 +179,8 @@ WalRcvStreaming(void)
}
if (state == WALRCV_STREAMING || state == WALRCV_STARTING ||
- state == WALRCV_RESTARTING)
+ state == WALRCV_RESTARTING || state == WALRCV_CONNECTING ||
+ state == WALRCV_CONNECTED)
return true;
else
return false;
@@ -211,6 +212,8 @@ ShutdownWalRcv(void)
stopped = true;
break;
+ case WALRCV_CONNECTING:
+ case WALRCV_CONNECTED:
case WALRCV_STREAMING:
case WALRCV_WAITING:
case WALRCV_RESTARTING:
diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h
index e5557d21fa8..70b2947f2b4 100644
--- a/src/include/replication/walreceiver.h
+++ b/src/include/replication/walreceiver.h
@@ -47,6 +47,9 @@ typedef enum
WALRCV_STOPPED, /* stopped and mustn't start up again */
WALRCV_STARTING, /* launched, but the process hasn't
* initialized yet */
+ WALRCV_CONNECTING, /* connection starting, but not established yet */
+ WALRCV_CONNECTED, /* replication connection established, but no WAL
+ * streamed yet */
WALRCV_STREAMING, /* walreceiver is streaming */
WALRCV_WAITING, /* stopped streaming, waiting for orders */
WALRCV_RESTARTING, /* asked to restart streaming */
--
2.51.0
^ permalink raw reply [nested|flat] 50+ messages in thread
* Re: Add WALRCV_CONNECTING state to walreceiver
2026-01-11 12:56 Re: Add WALRCV_CONNECTING state to walreceiver Xuneng Zhou <[email protected]>
@ 2026-01-19 00:13 ` Michael Paquier <[email protected]>
0 siblings, 0 replies; 50+ messages in thread
From: Michael Paquier @ 2026-01-19 00:13 UTC (permalink / raw)
To: Xuneng Zhou <[email protected]>; +Cc: Rahila Syed <[email protected]>; Noah Misch <[email protected]>; pgsql-hackers <[email protected]>
On Sun, Jan 11, 2026 at 08:56:57PM +0800, Xuneng Zhou wrote:
> After some thoughts, I’m more inclined toward a startup-process–driven
> approach. Marking the status as streaming immediately after the
> connection is established seems not provide sufficient accuracy for
> monitoring purposes. Introducing an intermediate state, such as
> connected, would help reduce confusion when the startup process is
> stalled and would make it easier for users to detect and diagnose
> anomalies.
>
> V4 whitelisted CONNECTED and CONNECTING in WalRcvWaitForStartPosition
> to handle valid stream termination scenarios without triggering a
> FATAL error.
>
> Specifically, the walreceiver may need to transition to WAITING (idle) if:
> 1. 'CONNECTED': The handshake succeeded (COPY_BOTH started), but
> the stream ended before any WAL was applied (e.g., timeline divergence
> detected mid-stream).
> 2. 'CONNECTING': The handshake completed (START_REPLICATION
> acknowledged), but the primary declined to stream (e.g., no WAL
> available on the requested timeline).
>
> In both cases, the receiver should pause and await a new timeline or
> restart position from the startup process.
This stuff depends on the philosophical difference you want to put
behind "connecting" and "streaming". My own opinion is that it is a
non-starter to introduce more states that can be set by the startup
process, and that a new state should reflect what we do in the code.
We already have some of that for in the start and stop phases because
we want some ordering when the WAL receiver process is spawned and at
shutdown. That's just a simple way to say that we should not rely on
more static variables to control how to set one or more states, and I
don't see why that's actually required here? initialApplyPtr and
force_reply are what I see as potential recipes for more bugs in the
long term, as showed in the first approach. The second patch,
introducing a similar new complexity with walrcv_streaming_set, is no
better in terms of complexity added.
The main take that I can retrieve from this thread is that it may take
time between the moment we begin a WAL receiver in WalReceiverMain(),
where walRcvState is switched to WALRCV_STREAMING, and the moment we
actually have established a connection, location where "first_stream =
false" (which is just to track if a WAL receiver is restarting,
actually) after walrcv_startstreaming() has returned true, so as far
as I can see you would be happy enough with the addition of a single
state called CONNECTING, set at the beginning of WalReceiverMain()
instead of where STREAMING is set now. The same would sound kind of
true for WalRcvWaitForStartPosition(), because we are not actively
streaming yet, still we are marking the WAL receiver as streaming, so
the current code feels like we are cheating as if we define
"streaming" as a WAL receiver that has already done an active
connection. We also want the WAL receiver to be killable by the
startup process while in "connecting" or "streaming" more.
Hence I would suggest something like the following guidelines:
- Add only a CONNECTING state. Set this state where we switch the
state to "streaming" now, aka the two locations in the tree now.
- Switch to STREAMING once the connection has been established, as
returned by walrcv_startstreaming(), because we are acknowledging *in
the code* that we have started streaming successfully.
- Update the docs to reflect the new state, because this state can
show up in the system view pg_stat_wal_receiver.
- I am not convinved by what we gain with a CONNECTED state, either.
Drop it.
- The fact that we'd want to switch the state once the startup process
has acknowleged the reception of the first byte from the stream is
already something we track in the WAL receiver, AFAIK. I think that
there would be a point in expanding the SQL functions to report more
states of the startup process, including the data received by the
startup process, but we should not link that to the state of the WAL
receiver. An extra reason to not do that: WAL receivers are not the
only source feeding data to the startup process, we could have data
pushed to pg_wal/, or archive commands/modules doing this job.
--
Michael
Attachments:
[application/pgp-signature] signature.asc (833B, ../../[email protected]/2-signature.asc)
download
^ permalink raw reply [nested|flat] 50+ messages in thread
end of thread, other threads:[~2026-01-19 00:13 UTC | newest]
Thread overview: 50+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-12 01:02 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2021-03-15 14:20 [PATCH] cfe-11-persistent_over_cfe-10-hint squash commit Bruce Momjian <[email protected]>
2026-01-11 12:56 Re: Add WALRCV_CONNECTING state to walreceiver Xuneng Zhou <[email protected]>
2026-01-19 00:13 ` Re: Add WALRCV_CONNECTING state to walreceiver Michael Paquier <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox