Add IS_INDEX macro to brin and gist index

From: Japin Li <japinli(at)hotmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Add IS_INDEX macro to brin and gist index
Date: 2026-01-14 01:56:43
Message-ID: MEAPR01MB3031A889D4B3F610E9D2A3AFB68FA@MEAPR01MB3031.ausprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers


Hi, hackers,

While working on pageinspect [0], I noticed that brin_page_items() and
gist_page_items() only checked the access method (IS_BRIN/IS_GIST) but did
not verify that the passed relation is actually an index relation.

To make the check more robust and consistent with other pageinspect index
functions (like btreefuncs.c, hashfuncs.c, etc.), the attached patch:

1. Defines a local helper macro IS_INDEX(r) in both brinfuncs.c and gistfuncs.c.

2. Updates the error check to require both: the relation must be an index and
use the expected access method.

The change is very small, low-risk, and only affects two functions in
contrib/pageinspect.

[0]: https://www.postgresql.org/message-id/CALdSSPiN13n7feQcY0WCmq8jzxjwqhNrt1E=g=g6aZANyE_OoQ@mail.gmail.com

--
Regards,
Japin Li
ChengDu WenWu Information Technology Co., Ltd.

Attachment Content-Type Size
v1-0001-Add-IS_INDEX-macro-to-brin-and-gist-index.patch text/x-patch 1.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Smith 2026-01-14 02:05:21 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Andreas Karlsson 2026-01-14 01:53:28 Re: [RFC] SLIM Data Type - Compact JSON Alternative (17-62% smaller)