Re: Use allocation macros in the logical replication code

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Cc: Peter Smith <smithpb2250(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Use allocation macros in the logical replication code
Date: 2026-03-04 01:39:07
Message-ID: 4A6FD427-9886-4CB5-9539-D90B4FBF2BCF@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Mar 4, 2026, at 04:52, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> wrote:
>
> On Tue, Feb 3, 2026 at 9:40 PM Peter Smith <smithpb2250(at)gmail(dot)com> wrote:
>>
>> On Wed, Feb 4, 2026 at 1:47 PM Hayato Kuroda (Fujitsu)
>> <kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>>>
>>> Dear Peter,
>>>
>>> Thanks for the patch. I have one comment for the patch:
>>> ```
>>> @@ -836,8 +836,9 @@ SnapBuildAddCommittedTxn(SnapBuild *builder, TransactionId xid)
>>> elog(DEBUG1, "increasing space for committed transactions to %u",
>>> (uint32) builder->committed.xcnt_space);
>>>
>>> - builder->committed.xip = repalloc(builder->committed.xip,
>>> - builder->committed.xcnt_space * sizeof(TransactionId));
>>> + builder->committed.xip = repalloc_array(builder->committed.xip,
>>> + TransactionId,
>>> + builder->committed.xcnt_space);
>>> ```
>>>
>>> Number of tabs seems not to enough here. Other than that LGTM.
>>>
>>
>> Thanks for the feedback. Now I have run pg_indent on all the patched files.
>>
>> PSA v2
>
> Thank you for the patch!
>
> The patch looks good to me. I'll push it, barring objections.
>

Hi Masahiko-san, no objection at all. When you have a chance, could you also take a look at [1]? It is a similar patch that fixes an incorrect usage of palloc_object() by switching it to palloc_array(), and also replaces a few repalloc() calls with repalloc_array().

[1] https://postgr.es/m/CAEoWx2m1Vo97Jg9=K7JAZ0xdkg5D=GkgOxZR1=EW7mUfy008fw@mail.gmail.com

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Japin Li 2026-03-04 01:40:30 Re: Don't keep closed WAL segment in page cache after replay
Previous Message Chao Li 2026-03-04 01:31:14 Re: Trivial Fix: use palloc_array/repalloc_array for BufFile file arrays