---
src/backend/storage/buffer/bufmgr.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c
index e066a3f888f..1d3b31f5070 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -895,6 +895,17 @@ ExtendBufferedRelTo(BufferManagerRelation bmr,
bmr.relpersistence = bmr.rel->rd_rel->relpersistence;
}
+ /*
+ * Validate the contract between flags and bmr.rel.
+ *
+ * EB_CREATE_FORK_IF_NEEDED implies we need to take extension lock,
+ * which requires a valid relation. Conversely, if we're skipping
+ * the extension lock (e.g., in recovery), then we must not be creating
+ * a fork here.
+ */
+ Assert(!(flags & EB_CREATE_FORK_IF_NEEDED) || !(flags & EB_SKIP_EXTENSION_LOCK));
+ Assert(bmr.rel != NULL || (flags & EB_SKIP_EXTENSION_LOCK));
+
/*
* If desired, create the file if it doesn't exist. If
* smgr_cached_nblocks[fork] is positive then it must exist, no need for
--
2.42.4