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

Commita6c926a

Browse files
committed
Set application name in postgres_fdw to allow distributed deadlock detection
1 parenta92b783 commita6c926a

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

‎contrib/postgres_fdw/connection.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -501,22 +501,18 @@ begin_remote_xact(ConnCacheEntry *entry)
501501
{
502502
intcurlevel=GetCurrentTransactionNestLevel();
503503
PGresult*res;
504+
charsql[128];
504505

505506

506507
/* Start main transaction if we haven't yet */
507508
if (entry->xact_depth <=0)
508509
{
509-
constchar*sql;
510-
511510
elog(DEBUG3,"starting remote transaction on connection %p",
512511
entry->conn);
513512

514-
if (IsolationIsSerializable())
515-
sql="START TRANSACTION ISOLATION LEVEL SERIALIZABLE";
516-
elseif (UseRepeatableRead)
517-
sql="START TRANSACTION ISOLATION LEVEL REPEATABLE READ";
518-
else
519-
sql="START TRANSACTION";
513+
sprintf(sql,"START TRANSACTION %s; set application_name='pgfdw:%lld:%d';",
514+
IsolationIsSerializable() ?"ISOLATION LEVEL SERIALIZABLE" :UseRepeatableRead ?"ISOLATION LEVEL REPEATABLE READ" :"",
515+
(long long)GetSystemIdentifier(),MyProcPid);
520516
entry->changing_xact_state= true;
521517
do_sql_command(entry->conn,sql);
522518
entry->xact_depth=1;
@@ -568,8 +564,6 @@ begin_remote_xact(ConnCacheEntry *entry)
568564
*/
569565
while (entry->xact_depth<curlevel)
570566
{
571-
charsql[64];
572-
573567
snprintf(sql,sizeof(sql),"SAVEPOINT s%d",entry->xact_depth+1);
574568
entry->changing_xact_state= true;
575569
do_sql_command(entry->conn,sql);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp