pg_upgrade: Fix inconsistency in memory freeing
authorMichael Paquier <michael@paquier.xyz>
Fri, 28 Feb 2025 01:15:34 +0000 (10:15 +0900)
committerMichael Paquier <michael@paquier.xyz>
Fri, 28 Feb 2025 01:15:34 +0000 (10:15 +0900)
commit9ca2145b00fb5d6272e87f274b0f40df77d81a51
tree0ddb19a6734559e1a167b1da5d6b4520635cf074
parent816149dc6bf9dfc1fa6bdb03ef52e1453fef736a
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@paquier.xyz>
Co-authored-by: Ranier Vilela <ranier.vf@gmail.com>
Discussion: https://postgr.es/m/Z601RQxTmIUohdkV@paquier.xyz
Backpatch-through: 16
src/bin/pg_upgrade/pg_upgrade.c