Re: Use stack-allocated StringInfoData

From: Mats Kindahl <mats(dot)kindahl(at)gmail(dot)com>
To: David Rowley <dgrowleyml(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Use stack-allocated StringInfoData
Date: 2025-11-06 07:37:58
Message-ID: 71b9d87a-aa3f-4d5e-bc40-e9e4e60e1c82@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 11/5/25 12:01, David Rowley wrote:
> On Tue, 4 Nov 2025 at 21:25, Mats Kindahl<mats(dot)kindahl(at)gmail(dot)com> wrote:
>> Here is an updated patch that I checked manually for unnecessary
>> whitespace changes.
> Thanks for updating the patch.
>
>> There is one such case affected by this patch, and there the buffer
>> pointer is copied to another variable and then returned. This can
>> probably be improved by just returning the buffer pointer directly
>> without intermediate assignment to a variable, but I avoided this to
>> make reviewing the code easier. It is easy to add this change either now
>> or later and should not affect the generated code except at very low
>> optimization levels.
> Yeah, I think you must mean in build_backup_content(). I noticed that too.

Yes, that is the one I meant.

>> I also added fixes manually inside check_publications_origin_tables,
>> check_publications, and fetch_relation_list. In
>> check_publication_origin_table three StringInfo was dynamically
>> allocated but not released after. In check_publications and
>> fetch_relation_list there were extra cases of using a dynamically
>> allocated StringInfo that was not necessary.
> It's not your fault, but check_publications_origin_tables() looks like
> a mess. It seems like excessive use of additional code just to avoid
> two separate ereport() calls. Might be worth a follow-up patch to
> clean that up.

Yeah, I have noted that too, but I wanted to avoid making reviews more
complicated than necessary. I thought it might be better to do as a
separate effort.

I'll take a look at it.

> The patch looks good to me. The only thing I'd adjust is to get rid of
> the "data" variable from build_backup_content(), which I think you
> mentioned above. I can take care of that one.

Thanks David.

Best wishes,
Mats Kindahl

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ajin Cherian 2025-11-06 07:53:02 Re: Improve pg_sync_replication_slots() to wait for primary to advance
Previous Message Quan Zongliang 2025-11-06 07:20:25 Re: [PATCH] Add pg_get_role_ddl() functions for role recreation