diff --git a/contrib/amcheck/verify_heapam.c b/contrib/amcheck/verify_heapam.c index 91ef09a8ca8..e84ecd1c981 100644 --- a/contrib/amcheck/verify_heapam.c +++ b/contrib/amcheck/verify_heapam.c @@ -323,6 +323,22 @@ verify_heapam(PG_FUNCTION_ARGS) (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("only heap AM is supported"))); + /* + * Early exit for unlogged relations during recovery. These will have no + * relation fork, so there won't be anything to check. We behave as if + * the relation is empty. + */ + if (ctx.rel->rd_rel->relpersistence == RELPERSISTENCE_UNLOGGED && + RecoveryInProgress()) + { + ereport(DEBUG1, + (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION), + errmsg("cannot verify unlogged relation \"%s\" during recovery, skipping", + RelationGetRelationName(ctx.rel)))); + relation_close(ctx.rel, AccessShareLock); + PG_RETURN_NULL(); + } + /* Early exit if the relation is empty */ nblocks = RelationGetNumberOfBlocks(ctx.rel); if (!nblocks) diff --git a/contrib/amcheck/verify_nbtree.c b/contrib/amcheck/verify_nbtree.c index d19f73127cd..42a830c33b5 100644 --- a/contrib/amcheck/verify_nbtree.c +++ b/contrib/amcheck/verify_nbtree.c @@ -372,7 +372,8 @@ btree_index_checkable(Relation rel) /* * Check if B-Tree index relation should have a file for its main relation * fork. Verification uses this to skip unlogged indexes when in hot standby - * mode, where there is simply nothing to verify. + * mode, where there is simply nothing to verify. We behave as if the + * relation is empty. * * NB: Caller should call btree_index_checkable() before calling here. */ @@ -383,7 +384,7 @@ btree_index_mainfork_expected(Relation rel) !RecoveryInProgress()) return true; - ereport(NOTICE, + ereport(DEBUG1, (errcode(ERRCODE_READ_ONLY_SQL_TRANSACTION), errmsg("cannot verify unlogged index \"%s\" during recovery, skipping", RelationGetRelationName(rel))));