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

Commit8427ce4

Browse files
committed
Fix handling of escape sequences in postgres_fdw.application_name
postgres_fdw.application_name relies on MyProcPort to define the datathat should be added to escape sequences %u (user name) or %d (databasename). However this code could be run in processes that lack aMyProcPort, like an autovacuum process, causing crashes.The code generating the application name is made more flexible with thiscommit, so as it now generates no data for %u and %d if MyProcPort ismissing, and a simple "unknown" if MyProcPort exists, but the expectedfields are not set.Reported-by: Alexander LakhinAuthor: Kyotaro Horiguchi, Michael PaquierReviewed-by: Hayato Kuroda, Masahiko SawadaDiscussion:https://postgr.es/m/17789-8b31c5a4672b74d9@postgresql.orgBackpatch-through: 15
1 parent038f586 commit8427ce4

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

‎contrib/postgres_fdw/option.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,6 @@ process_pgfdw_appname(const char *appname)
485485
constchar*p;
486486
StringInfoDatabuf;
487487

488-
Assert(MyProcPort!=NULL);
489-
490488
initStringInfo(&buf);
491489

492490
for (p=appname;*p!='\0';p++)
@@ -522,13 +520,29 @@ process_pgfdw_appname(const char *appname)
522520
appendStringInfoString(&buf,cluster_name);
523521
break;
524522
case'd':
525-
appendStringInfoString(&buf,MyProcPort->database_name);
523+
if (MyProcPort)
524+
{
525+
constchar*dbname=MyProcPort->database_name;
526+
527+
if (dbname)
528+
appendStringInfoString(&buf,dbname);
529+
else
530+
appendStringInfoString(&buf,"[unknown]");
531+
}
526532
break;
527533
case'p':
528534
appendStringInfo(&buf,"%d",MyProcPid);
529535
break;
530536
case'u':
531-
appendStringInfoString(&buf,MyProcPort->user_name);
537+
if (MyProcPort)
538+
{
539+
constchar*username=MyProcPort->user_name;
540+
541+
if (username)
542+
appendStringInfoString(&buf,username);
543+
else
544+
appendStringInfoString(&buf,"[unknown]");
545+
}
532546
break;
533547
default:
534548
/* format error - ignore it */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp