Re: Fix memory leak in gist_page_items() of pageinspect

Chao Li <li.evan.chao@gmail.com>

From: Chao Li <li.evan.chao@gmail.com>
To: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Cc: Japin Li <japinli@hotmail.com>, Michael Paquier <michael@paquier.xyz>, Daniel Gustafsson <daniel@yesql.se>, Heikki Linnakangas <hlinnaka@iki.fi>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-12-22T02:41:44Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Use relation_close() more consistently in contrib/

  2. Use table/index_close() more consistently

  3. pageinspect: use index_close() for GiST index relation


> On Dec 19, 2025, at 18:26, Bertrand Drouvot <bertranddrouvot.pg@gmail.com> wrote:
> 
> Hi,
> 
> On Fri, Dec 19, 2025 at 05:36:51PM +0800, Japin Li wrote:
>> On Fri, 19 Dec 2025 at 08:23, Bertrand Drouvot <bertranddrouvot.pg@gmail.com> wrote:
>>> Yeah that would not hurt. What about before the relation_open() calls?
>>> 
>>> "
>>> Use relation_open() and not index_open() to avoid the validate_relation_kind()
>>> check as we handle relation validation separately below.
>>> "
>>> 
>> 
>> LGTM.
> 
> Thanks! Done that way in the attached.
> 
> Regards,
> 
> -- 
> Bertrand Drouvot
> PostgreSQL Contributors Team
> RDS Open Source Databases
> Amazon Web Services: https://aws.amazon.com
> <v3-0001-Use-relation_close-more-consistently.patch>

LGTM. As the immediately following statement is if (!IS_INDEX(rel)), adding a comment to relation_open() feels very necessary.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/