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

Commitee78823

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 parentf903d4d commitee78823

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
@@ -408,6 +408,7 @@ set_locale_and_encoding(void)
408408
char*datcollate_literal;
409409
char*datctype_literal;
410410
char*datlocale_literal=NULL;
411+
char*datlocale_src;
411412
DbLocaleInfo*locale=old_cluster.template0;
412413

413414
prep_status("Setting locale and encoding for new cluster");
@@ -421,12 +422,10 @@ set_locale_and_encoding(void)
421422
datctype_literal=PQescapeLiteral(conn_new_template1,
422423
locale->db_ctype,
423424
strlen(locale->db_ctype));
424-
if (locale->db_locale)
425-
datlocale_literal=PQescapeLiteral(conn_new_template1,
426-
locale->db_locale,
427-
strlen(locale->db_locale));
428-
else
429-
datlocale_literal=pg_strdup("NULL");
425+
datlocale_src=locale->db_locale ?locale->db_locale :"NULL";
426+
datlocale_literal=PQescapeLiteral(conn_new_template1,
427+
datlocale_src,
428+
strlen(datlocale_src));
430429

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp