Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2a083ab

Browse files
michaelpqRanierV
andcommitted
pg_upgrade: Fix inconsistency in memory freeing
The function in charge of freeing the memory from a result created byPQescapeIdentifier() has to be PQfreemem(), to ensure that bothallocation and free come from libpq.One spot in pg_upgrade was not respecting that for pg_database'sdatlocale (daticulocale in v16) when the collation provider is libc (akadatlocale/daticulocale is NULL) with an allocation done usingpg_strdup() and a free with PQfreemem(). The code is changed to alwaysuse PQescapeLiteral() when processing the input.Oversight in9637bad. This commit is similar to48e4ae9 and5b94e27.Author: Michael Paquier <michael@paquier.xyz>Co-authored-by: Ranier Vilela <ranier.vf@gmail.com>Discussion:https://postgr.es/m/Z601RQxTmIUohdkV@paquier.xyzBackpatch-through: 16
1 parent2e4127b commit2a083ab

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

‎src/bin/pg_upgrade/pg_upgrade.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ set_locale_and_encoding(void)
437437
char*datcollate_literal;
438438
char*datctype_literal;
439439
char*datlocale_literal=NULL;
440+
char*datlocale_src;
440441
DbLocaleInfo*locale=old_cluster.template0;
441442

442443
prep_status("Setting locale and encoding for new cluster");
@@ -450,12 +451,10 @@ set_locale_and_encoding(void)
450451
datctype_literal=PQescapeLiteral(conn_new_template1,
451452
locale->db_ctype,
452453
strlen(locale->db_ctype));
453-
if (locale->db_locale)
454-
datlocale_literal=PQescapeLiteral(conn_new_template1,
455-
locale->db_locale,
456-
strlen(locale->db_locale));
457-
else
458-
datlocale_literal=pg_strdup("NULL");
454+
datlocale_src=locale->db_locale ?locale->db_locale :"NULL";
455+
datlocale_literal=PQescapeLiteral(conn_new_template1,
456+
datlocale_src,
457+
strlen(datlocale_src));
459458

460459
/* update template0 in new cluster */
461460
if (GET_MAJOR_VERSION(new_cluster.major_version) >=1700)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp