Re: Small memory fixes for pg_createsubcriber

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andres Freund <andres(at)anarazel(dot)de>, Euler Taveira <euler(at)eulerto(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Small memory fixes for pg_createsubcriber
Date: 2025-02-25 11:54:31
Message-ID: CAEudQAqsjfhfJYp8CWTJk3u-7h4C2LL38StJgcrFvcnc6+cOCA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Em ter., 25 de fev. de 2025 às 03:02, Michael Paquier <michael(at)paquier(dot)xyz>
escreveu:

> On Thu, Feb 13, 2025 at 01:50:29PM +0900, Michael Paquier wrote:
> > On Wed, Feb 12, 2025 at 07:08:31PM -0500, Tom Lane wrote:
> >> I spent a little time earlier today seeing what I could do with the
> >> use-dmalloc patch I posted earlier. It turns out you can get through
> >> initdb after s/free/PQfreemem/ in just two places, and then the
> >> backend works fine. But psql is a frickin' disaster --- there's
> >> free's of strings made with PQExpBuffer all over its backslash-command
> >> handling, and no easy way to clean it up. Maybe other clients will
> >> be less of a mess, but I'm not betting on that.
> >
> > Hmm. Okay. It sounds like it would be better to group everything
> > that has been pointed together towards what should be a more generic
> > solution than what I have posted. So I am holding on touching
> > anything.
>
> Two weeks later. Would there be any objections for doing something in
> the lines of [1] for pg_upgrade and pg_amcheck?

I prefer not to mix api.

We already have a branch for decision.
Let's use it then.

diff --git a/src/bin/pg_upgrade/pg_upgrade.c
b/src/bin/pg_upgrade/pg_upgrade.c
index d95c491fb5..b2c8e8e420 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -455,7 +455,9 @@ set_locale_and_encoding(void)
locale->db_locale,
strlen(locale->db_locale));
else
- datlocale_literal = pg_strdup("NULL");
+ datlocale_literal = PQescapeLiteral(conn_new_template1,
+ "NULL",
+ strlen("NULL"));

best regards,
Ranier Vilela

Attachment Content-Type Size
avoid-mix-api-pg_upgrade.patch application/octet-stream 571 bytes

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2025-02-25 12:21:00 Re: Index AM API cleanup
Previous Message Ilia Evdokimov 2025-02-25 11:42:17 Re: describe special values in GUC descriptions more consistently