Re: Fix memory leak in gist_page_items() of pageinspect

From: Japin Li <japinli(at)hotmail(dot)com>
To: Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Fix memory leak in gist_page_items() of pageinspect
Date: 2025-12-19 06:21:40
Message-ID: MEAPR01MB3031F286277587B4686B1181B6A9A@MEAPR01MB3031.ausprd01.prod.outlook.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 19 Dec 2025 at 04:29, Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
> Hi,
>
> On Fri, Dec 19, 2025 at 08:01:54AM +0900, Michael Paquier wrote:
>> On Wed, Dec 17, 2025 at 11:57:13AM +0000, Bertrand Drouvot wrote:
>> > Please note that for hash_bitmap_info() and pgstathashindex() the open calls are
>> > changed instead. For those we keep the IS_INDEX() checks to reject partitioned
>> > indexes (which index_open() accepts via validate_relation_kind()). So, that also
>> > changes the error messages in some tests. If we do prefer the previous error
>> > messages we could change the close calls instead (I prefer the way it's done
>> > in the attached though).
>>
>> I have noticed that the two surrounding relation_close() calls for the
>> parent tables did not get the notice of the change for brin.c of what
>> you are doing for the indexes, while we use table_open(). I have
>> fixed these.
>
> Nice catch, thanks!
>
>> It would be nicer if IS_INDEX() could be removed in the other code
>> paths you are suggesting to change, but the partitioned index argument
>> also means that we would have two code paths in charge of a relkind
>> check instead of one. Just using relation_*() may be cleaner.
>
> Yeah, and removing IS_INDEX() and adding a check for partitioned indexes would
> still mean 2 code paths. So, v2 changes the close calls (and that's consistent
> with what pgstatginindex_internal() is doing.
>

It would be reasonable to add a comment explaining the choice of
relation_open()/relation_close() instead of the index-specific
index_open()/index_close().

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2025-12-19 06:22:12 Re: Proposal: Conflict log history table for Logical Replication
Previous Message Amit Kapila 2025-12-19 06:19:35 Re: Proposal: Conflict log history table for Logical Replication