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

Commit5656683

Browse files
author
Etsuro Fujita
committed
postgres_fdw: Minor cleanup for pgfdw_abort_cleanup().
Commit85c6961 introduced this function to deduplicate code in thetransaction callback functions, but the SQL command passed as anargument to it was useless when it returned before aborting a remotetransaction using the command. Modify pgfdw_abort_cleanup() so that itconstructs the command when/if necessary, as before, removing theargument from it. Also update comments in pgfdw_abort_cleanup() and oneof the calling functions.Etsuro Fujita, reviewed by David Zhang.Discussion:https://postgr.es/m/CAPmGK158hrd%3DZfXmgkmNFHivgh18e4oE2Gz151C2Q4OBDjZ08A%40mail.gmail.com
1 parentad8759b commit5656683

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

‎contrib/postgres_fdw/connection.c

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ static bool pgfdw_exec_cleanup_query(PGconn *conn, const char *query,
110110
boolignore_errors);
111111
staticboolpgfdw_get_cleanup_result(PGconn*conn,TimestampTzendtime,
112112
PGresult**result,bool*timed_out);
113-
staticvoidpgfdw_abort_cleanup(ConnCacheEntry*entry,constchar*sql,
114-
booltoplevel);
113+
staticvoidpgfdw_abort_cleanup(ConnCacheEntry*entry,booltoplevel);
115114
staticvoidpgfdw_finish_pre_commit_cleanup(List*pending_entries);
116115
staticvoidpgfdw_finish_pre_subcommit_cleanup(List*pending_entries,
117116
intcurlevel);
@@ -1015,8 +1014,8 @@ pgfdw_xact_callback(XactEvent event, void *arg)
10151014
break;
10161015
caseXACT_EVENT_PARALLEL_ABORT:
10171016
caseXACT_EVENT_ABORT:
1018-
1019-
pgfdw_abort_cleanup(entry,"ABORT TRANSACTION",true);
1017+
/* Rollback all remote transactions during abort */
1018+
pgfdw_abort_cleanup(entry, true);
10201019
break;
10211020
}
10221021
}
@@ -1109,10 +1108,7 @@ pgfdw_subxact_callback(SubXactEvent event, SubTransactionId mySubid,
11091108
else
11101109
{
11111110
/* Rollback all remote subtransactions during abort */
1112-
snprintf(sql,sizeof(sql),
1113-
"ROLLBACK TO SAVEPOINT s%d; RELEASE SAVEPOINT s%d",
1114-
curlevel,curlevel);
1115-
pgfdw_abort_cleanup(entry,sql, false);
1111+
pgfdw_abort_cleanup(entry, false);
11161112
}
11171113

11181114
/* OK, we're outta that level of subtransaction */
@@ -1465,19 +1461,18 @@ exit:;
14651461
}
14661462

14671463
/*
1468-
* Abort remote transaction.
1469-
*
1470-
* The statement specified in "sql" is sent to the remote server,
1471-
* in order to rollback the remote transaction.
1464+
* Abort remote transaction or subtransaction.
14721465
*
14731466
* "toplevel" should be set to true if toplevel (main) transaction is
14741467
* rollbacked, false otherwise.
14751468
*
14761469
* Set entry->changing_xact_state to false on success, true on failure.
14771470
*/
14781471
staticvoid
1479-
pgfdw_abort_cleanup(ConnCacheEntry*entry,constchar*sql,booltoplevel)
1472+
pgfdw_abort_cleanup(ConnCacheEntry*entry,booltoplevel)
14801473
{
1474+
charsql[100];
1475+
14811476
/*
14821477
* Don't try to clean up the connection if we're already in error
14831478
* recursion trouble.
@@ -1509,8 +1504,14 @@ pgfdw_abort_cleanup(ConnCacheEntry *entry, const char *sql, bool toplevel)
15091504
!pgfdw_cancel_query(entry->conn))
15101505
return;/* Unable to cancel running query */
15111506

1507+
if (toplevel)
1508+
snprintf(sql,sizeof(sql),"ABORT TRANSACTION");
1509+
else
1510+
snprintf(sql,sizeof(sql),
1511+
"ROLLBACK TO SAVEPOINT s%d; RELEASE SAVEPOINT s%d",
1512+
entry->xact_depth,entry->xact_depth);
15121513
if (!pgfdw_exec_cleanup_query(entry->conn,sql, false))
1513-
return;/* Unable to abort remote transaction */
1514+
return;/* Unable to abort remote(sub)transaction */
15141515

15151516
if (toplevel)
15161517
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp