Thread

Commits

  1. Use palloc_object() and palloc_array() in more areas of the logical replication.

  1. Use allocation macros in the logical replication code

    Peter Smith <smithpb2250@gmail.com> — 2026-02-04T00:14:53Z

    Hi,
    
    Here is a patch that modifies some allocation code to make use of the
    appropriate macros.
    
    Scope: src/backend/replication/logical/*
    
    PSA v1
    
    ======
    Kind Regards,
    Peter Smith.
    Fujitsu Australia
    
  2. Re: Use allocation macros in the logical replication code

    Chao Li <li.evan.chao@gmail.com> — 2026-02-04T01:04:57Z

    
    > On Feb 4, 2026, at 08:14, Peter Smith <smithpb2250@gmail.com> wrote:
    > 
    > Hi,
    > 
    > Here is a patch that modifies some allocation code to make use of the
    > appropriate macros.
    > 
    > Scope: src/backend/replication/logical/*
    > 
    > PSA v1
    > 
    > ======
    > Kind Regards,
    > Peter Smith.
    > Fujitsu Australia
    > <v1-0001-use-alloc-macros-in-logical-replication-code.patch>
    
    LGTM.
    
    BTW, I have a similar patch [1] there more than a month.
    
    [1] https://www.postgresql.org/message-id/CAEoWx2m1Vo97Jg9%3DK7JAZ0xdkg5D%3DGkgOxZR1%3DEW7mUfy008fw%40mail.gmail.com
    
    Best regards,
    --
    Chao Li (Evan)
    HighGo Software Co., Ltd.
    https://www.highgo.com/
    
    
    
    
    
    
    
    
  3. RE: Use allocation macros in the logical replication code

    Hayato Kuroda (Fujitsu) <kuroda.hayato@fujitsu.com> — 2026-02-04T02:47:16Z

    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.
    
    Best regards,
    Hayato Kuroda
    FUJITSU LIMITED
    
    
  4. Re: Use allocation macros in the logical replication code

    Peter Smith <smithpb2250@gmail.com> — 2026-02-04T05:40:12Z

    On Wed, Feb 4, 2026 at 1:47 PM Hayato Kuroda (Fujitsu)
    <kuroda.hayato@fujitsu.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
    
    ======
    Kind Regards,
    Peter Smith.
    Fujitsu Australia
    
  5. Re: Use allocation macros in the logical replication code

    Masahiko Sawada <sawada.mshk@gmail.com> — 2026-03-03T20:52:26Z

    On Tue, Feb 3, 2026 at 9:40 PM Peter Smith <smithpb2250@gmail.com> wrote:
    >
    > On Wed, Feb 4, 2026 at 1:47 PM Hayato Kuroda (Fujitsu)
    > <kuroda.hayato@fujitsu.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.
    
    Regards,
    
    -- 
    Masahiko Sawada
    Amazon Web Services: https://aws.amazon.com
    
    
    
    
  6. Re: Use allocation macros in the logical replication code

    Chao Li <li.evan.chao@gmail.com> — 2026-03-04T01:39:07Z

    
    > On Mar 4, 2026, at 04:52, Masahiko Sawada <sawada.mshk@gmail.com> wrote:
    > 
    > On Tue, Feb 3, 2026 at 9:40 PM Peter Smith <smithpb2250@gmail.com> wrote:
    >> 
    >> On Wed, Feb 4, 2026 at 1:47 PM Hayato Kuroda (Fujitsu)
    >> <kuroda.hayato@fujitsu.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/
    
    
    
    
    
    
    
    
  7. Re: Use allocation macros in the logical replication code

    Peter Smith <smithpb2250@gmail.com> — 2026-03-09T05:22:36Z

    Thanks for pushing!
    
    I have marked the corresponding CF entry as "Committed".
    
    ======
    Kind Regards,
    Peter Smith.
    Fujitsu Australia.
    
    
    
    
  8. Re: Use allocation macros in the logical replication code

    Masahiko Sawada <sawada.mshk@gmail.com> — 2026-03-10T20:55:44Z

    On Sun, Mar 8, 2026 at 10:23 PM Peter Smith <smithpb2250@gmail.com> wrote:
    >
    > Thanks for pushing!
    >
    > I have marked the corresponding CF entry as "Committed".
    
    I noticed I forgot to mention the patch has been pushed.
    
    Thanks for the report and the patch!
    
    Regards,
    
    -- 
    Masahiko Sawada
    Amazon Web Services: https://aws.amazon.com