Re: Small memory fixes for pg_createsubcriber
Noah Misch <noah@leadboat.com>
From: Noah Misch <noah@leadboat.com>
To: Ranier Vilela <ranier.vf@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>, Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, Euler Taveira <euler@eulerto.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-04-01T20:14:03Z
Lists: pgsql-hackers
On Tue, Apr 01, 2025 at 04:28:34PM -0300, Ranier Vilela wrote:
> Em ter., 1 de abr. de 2025 às 15:39, Noah Misch <noah@leadboat.com>
> escreveu:
>
> > On Thu, Feb 27, 2025 at 10:23:31AM -0300, Ranier Vilela wrote:
> > > Em qui., 27 de fev. de 2025 às 02:51, Michael Paquier <
> > michael@paquier.xyz>
> > > escreveu:
> > >
> > > > On Tue, Feb 25, 2025 at 08:54:31AM -0300, Ranier Vilela wrote:
> > > > > @@ -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"));
> > This became 2a083ab "pg_upgrade: Fix inconsistency in memory
> > freeing".
> > PQescapeLiteral("NULL") is "'NULL'", so this causes pg_database.datlocale
> > to
> > contain datlocale='NULL'::text instead of datlocale IS NULL.
> >
> I believe the intention of the query is:
> For example:
> UPDATE pg_catalog.pg_database
> SET encoding = 6,
> datlocprovider = 'c',
> datlocale = NULL
> WHERE datname = 'template0';
>
> Where datlocale with NULL is correct no?
Right. Commit 2a083ab changed it to:
UPDATE pg_catalog.pg_database
SET encoding = 6,
datlocprovider = 'c',
datlocale = 'NULL'
WHERE datname = 'template0';
> Because:
> UPDATE pg_catalog.pg_database
> SET encoding = 6,
> datlocprovider = 'c',
> datlocale IS NULL
> WHERE datname = 'template0';
>
> ERROR: syntax error at or near "IS"
> LINE 4: datlocale IS NULL
Yes, pg_upgrade should not do that. I was trying to explain the difference
between NULL and 'NULL'. I didn't mean pg_upgrade should emit "IS NULL".
Commits
-
pg_upgrade: Fix inconsistency in memory freeing
- 9ca2145b00fb 16.9 landed
- ee78823ff5f6 17.5 landed
- 2a083ab807db 18.0 landed
-
pg_amcheck: Fix inconsistency in memory freeing
- 35a591a0486f 14.18 landed
- ec741d48036a 15.13 landed
- 816149dc6bf9 16.9 landed
- f903d4da9276 17.5 landed
- 48e4ae9a0707 18.0 landed
-
Fix some inconsistencies with memory freeing in pg_createsubscriber
- ff6d9cfcb17e 17.4 landed
- 5b94e2753439 18.0 landed
-
Drop pre-existing subscriptions from the converted subscriber.
- 4867f8a555ce 18.0 cited