v3-0001-Don-t-allow-no-storage-relation-to-get-FSM-info.patch
text/plain
Filename: v3-0001-Don-t-allow-no-storage-relation-to-get-FSM-info.patch
Type: text/plain
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v3-0001
Subject: Don't allow no storage relation to get FSM info.
| File | + | − |
|---|---|---|
| contrib/pg_freespacemap/pg_freespacemap.c | 8 | 0 |
From 55c9f72af7dd9c4b853cb79460bbaa5808cff8db Mon Sep 17 00:00:00 2001
From: Tender Wang <tndrwang@gmail.com>
Date: Wed, 26 Mar 2025 09:14:08 +0800
Subject: [PATCH v3] Don't allow no storage relation to get FSM info.
---
contrib/pg_freespacemap/pg_freespacemap.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/contrib/pg_freespacemap/pg_freespacemap.c b/contrib/pg_freespacemap/pg_freespacemap.c
index 565167aaef..3e726a64b0 100644
--- a/contrib/pg_freespacemap/pg_freespacemap.c
+++ b/contrib/pg_freespacemap/pg_freespacemap.c
@@ -11,6 +11,7 @@
#include "access/relation.h"
#include "fmgr.h"
#include "storage/freespace.h"
+#include "utils/rel.h"
PG_MODULE_MAGIC;
@@ -35,6 +36,13 @@ pg_freespace(PG_FUNCTION_ARGS)
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
errmsg("invalid block number")));
+ if ((!RELKIND_HAS_STORAGE(rel->rd_rel->relkind)))
+ ereport(ERROR,
+ (errcode(ERRCODE_WRONG_OBJECT_TYPE),
+ errmsg("relation \"%s\" does not have storage",
+ RelationGetRelationName(rel)),
+ errdetail_relkind_not_supported(rel->rd_rel->relkind)));
+
freespace = GetRecordedFreeSpace(rel, blkno);
relation_close(rel, AccessShareLock);
--
2.34.1