pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH v1] Add IS_INDEX macro to brin and gist index
1+ messages / 1 participants
[nested] [flat]

* [PATCH v1] Add IS_INDEX macro to brin and gist index
@ 2026-01-14 01:55  Japin Li <japinli@hotmail.com>
  0 siblings, 0 replies; 1+ messages in thread

From: Japin Li @ 2026-01-14 01:55 UTC (permalink / raw)

---
 contrib/pageinspect/brinfuncs.c | 3 ++-
 contrib/pageinspect/gistfuncs.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

inline patch 1: contrib/pageinspect/brinfuncs.c, contrib/pageinspect/gistfuncs.c (+4/-2 lines) download inline-1.patchdiff --git a/contrib/pageinspect/brinfuncs.c b/contrib/pageinspect/brinfuncs.c index 26cf78252ed..4be2225e429 100644 --- a/contrib/pageinspect/brinfuncs.c +++ b/contrib/pageinspect/brinfuncs.c @@ -28,6 +28,7 @@ PG_FUNCTION_INFO_V1(brin_page_items); PG_FUNCTION_INFO_V1(brin_metapage_info); PG_FUNCTION_INFO_V1(brin_revmap_data); +#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX) #define IS_BRIN(r) ((r)->rd_rel->relam == BRIN_AM_OID) typedef struct brin_column_state @@ -164,7 +165,7 @@ brin_page_items(PG_FUNCTION_ARGS) indexRel = index_open(indexRelid, AccessShareLock); - if (!IS_BRIN(indexRel)) + if (!IS_INDEX(indexRel) || !IS_BRIN(indexRel)) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("\"%s\" is not a %s index", diff --git a/contrib/pageinspect/gistfuncs.c b/contrib/pageinspect/gistfuncs.c index e7759488c36..7062b7b423f 100644 --- a/contrib/pageinspect/gistfuncs.c +++ b/contrib/pageinspect/gistfuncs.c @@ -30,6 +30,7 @@ PG_FUNCTION_INFO_V1(gist_page_opaque_info); PG_FUNCTION_INFO_V1(gist_page_items); PG_FUNCTION_INFO_V1(gist_page_items_bytea); +#define IS_INDEX(r) ((r)->rd_rel->relkind == RELKIND_INDEX) #define IS_GIST(r) ((r)->rd_rel->relam == GIST_AM_OID) @@ -217,7 +218,7 @@ gist_page_items(PG_FUNCTION_ARGS) /* Open the relation */ indexRel = index_open(indexRelid, AccessShareLock); - if (!IS_GIST(indexRel)) + if (!IS_INDEX(indexRel) || !IS_GIST(indexRel)) ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), errmsg("\"%s\" is not a %s index", -- 2.43.0
--=-=-=-- ^ permalink raw reply [nested|flat] 1+ messages in thread


only message in thread

Thread overview: 1+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-01-14 01:55 [PATCH v1] Add IS_INDEX macro to brin and gist index Japin Li <japinli@hotmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox