Refactor StringInfo usage in subscriptioncmds.c

From: Mats Kindahl <mats(dot)kindahl(at)gmail(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>
Subject: Refactor StringInfo usage in subscriptioncmds.c
Date: 2025-11-06 11:38:07
Message-ID: 0b381b02-cab9-41f9-a900-ad6c8d26c1fc@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all,

As discussed in [1] the functions check_publications_origin_tables() and
check_publications_origin_sequences() are building error messages using
dynamically allocated StringInfo instances only to avoid duplicating a
call of ereport().

Attached is a proposal that instead of building error message and hints
dynamically, it will use ereport() directly and as a result does not
have to allocate the error message strings and error message hints
dynamically and these can be removed.

This also means that a previous use of gettext() (in the form of the "_"
macro) is not needed any more and we can use errmsg() and errhint()
rather than errmsg_internal() and errhint_internal() with ereport().

It also replaces the usage a dynamically allocated StringInfo of
pubnames containing the publication names with a stack allocated
StringInfoData, along the same line as in [2].

[1]:
https://www.postgresql.org/message-id/CAApHDvrZnM28wa2VY58cvtY0y9XbMhKJH4m%3Dga3c1wfsx%3DMF4Q%40mail.gmail.com

[2]:
https://www.postgresql.org/message-id/flat/CAApHDvrZnM28wa2VY58cvtY0y9XbMhKJH4m%3Dga3c1wfsx%3DMF4Q%40mail.gmail.com#ba34970e59f9fd847f1ab52777d57edc

Attachment Content-Type Size
0001-Refactor-StringInfo-usage-in-subscriptioncmds.c.v1.patch text/x-patch 5.3 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2025-11-06 11:46:56 Some efforts to get rid of "long" in our codebase
Previous Message Heikki Linnakangas 2025-11-06 11:35:28 Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue