Fix unintentional 'NULL' string literal in pg_upgrade.

Introduced in 2a083ab807.

Note: backport of commit 945126234b, which was missed at the time.

Discussion: https://postgr.es/m/e852442da35b4f31acc600ed98bbee0f12e65e0c.camel@j-davis.com
Reviewed-by: Michael Paquier <michael@paquier.xyz>
Backpatch-through: 16
This commit is contained in:
Jeff Davis 2025-04-06 09:14:42 -07:00
parent 1980ec2bc9
commit 57467ec7b3

View File

@ -383,7 +383,6 @@ set_locale_and_encoding(void)
char *datcollate_literal;
char *datctype_literal;
char *daticulocale_literal = NULL;
char *daticulocale_src;
DbLocaleInfo *locale = old_cluster.template0;
prep_status("Setting locale and encoding for new cluster");
@ -397,10 +396,13 @@ set_locale_and_encoding(void)
datctype_literal = PQescapeLiteral(conn_new_template1,
locale->db_ctype,
strlen(locale->db_ctype));
daticulocale_src = locale->db_iculocale ? locale->db_iculocale : "NULL";
daticulocale_literal = PQescapeLiteral(conn_new_template1,
daticulocale_src,
strlen(daticulocale_src));
if (locale->db_iculocale)
daticulocale_literal = PQescapeLiteral(conn_new_template1,
locale->db_iculocale,
strlen(locale->db_iculocale));
else
daticulocale_literal = "NULL";
/* update template0 in new cluster */
if (GET_MAJOR_VERSION(new_cluster.major_version) >= 1500)
@ -430,7 +432,8 @@ set_locale_and_encoding(void)
PQfreemem(datcollate_literal);
PQfreemem(datctype_literal);
PQfreemem(daticulocale_literal);
if (locale->db_iculocale)
PQfreemem(daticulocale_literal);
PQfinish(conn_new_template1);