pgsql: pg_upgrade: Fix inconsistency in memory freeing

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: pg_upgrade: Fix inconsistency in memory freeing
Date: 2025-02-28 01:16:34
Message-ID: E1tnozS-000424-2y@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

pg_upgrade: Fix inconsistency in memory freeing

The function in charge of freeing the memory from a result created by
PQescapeIdentifier() has to be PQfreemem(), to ensure that both
allocation and free come from libpq.

One spot in pg_upgrade was not respecting that for pg_database's
datlocale (daticulocale in v16) when the collation provider is libc (aka
datlocale/daticulocale is NULL) with an allocation done using
pg_strdup() and a free with PQfreemem(). The code is changed to always
use PQescapeLiteral() when processing the input.

Oversight in 9637badd9f92. This commit is similar to 48e4ae9a0707 and
5b94e2753439.

Author: Michael Paquier <michael(at)paquier(dot)xyz>
Co-authored-by: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
Discussion: https://postgr.es/m/Z601RQxTmIUohdkV@paquier.xyz
Backpatch-through: 16

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2a083ab807db6d9e2e0e3aa82ee8f6ff9fc44c8d

Modified Files
--------------
src/bin/pg_upgrade/pg_upgrade.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Michael Paquier 2025-02-28 02:21:54 pgsql: Invent pgstat_fetch_stat_backend_by_pid()
Previous Message Masahiko Sawada 2025-02-27 23:04:08 pgsql: Refactor COPY TO to use format callback functions.