git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d66997d)
Prevent assertion failure in contrib/pg_freespacemap.
2025年3月27日 17:20:23 +0000 (13:20 -0400)
2025年3月27日 17:20:23 +0000 (13:20 -0400)
Applying pg_freespacemap() to a relation lacking storage (such as a
view) caused an assertion failure, although there was no ill effect
in non-assert builds. Add an error check for that case.

Bug: #18866
Reported-by: Robins Tharakan <tharakan@gmail.com>
Author: Tender Wang <tndrwang@gmail.com>
Reviewed-by: Euler Taveira <euler@eulerto.com>
Discussion: https://postgr.es/m/18866-d68926d0f1c72d44@postgresql.org
Backpatch-through: 13


diff --git a/contrib/pg_freespacemap/pg_freespacemap.c b/contrib/pg_freespacemap/pg_freespacemap.c
index c0eac7a20167cff379a2089df3f29bf8490781e4..610fc90b5ba57ddff011b8e22a17b3326fb2b73c 100644 (file)
--- 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_EXT(
.name = "pg_freespacemap",
@@ -33,6 +34,13 @@ pg_freespace(PG_FUNCTION_ARGS)
rel = relation_open(relid, AccessShareLock);
+ 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)));
+
if (blkno < 0 || blkno > MaxBlockNumber)
ereport(ERROR,
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /