Skip to content

Commit ee4ac46

Browse files
committed
Expose PQbackendPID() through walreceiver API
This will be used by a subsequent patch. Reviewed-by: Masahiko Sawada <masahiko.sawada@2ndquadrant.com> Discussion: https://www.postgresql.org/message-id/CA%2Bfd4k4dM0iEPLxyVyme2RAFsn8SUgrNtBJOu81YqTY4V%2BnqZA%40mail.gmail.com
1 parent f595117 commit ee4ac46

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/backend/replication/libpqwalreceiver/libpqwalreceiver.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static char *libpqrcv_create_slot(WalReceiverConn *conn,
7474
bool temporary,
7575
CRSSnapshotAction snapshot_action,
7676
XLogRecPtr *lsn);
77+
static pid_t libpqrcv_get_backend_pid(WalReceiverConn *conn);
7778
static WalRcvExecResult *libpqrcv_exec(WalReceiverConn *conn,
7879
const char *query,
7980
const int nRetTypes,
@@ -93,6 +94,7 @@ static WalReceiverFunctionsType PQWalReceiverFunctions = {
9394
libpqrcv_receive,
9495
libpqrcv_send,
9596
libpqrcv_create_slot,
97+
libpqrcv_get_backend_pid,
9698
libpqrcv_exec,
9799
libpqrcv_disconnect
98100
};
@@ -858,6 +860,15 @@ libpqrcv_create_slot(WalReceiverConn *conn, const char *slotname,
858860
return snapshot;
859861
}
860862

863+
/*
864+
* Return PID of remote backend process.
865+
*/
866+
static pid_t
867+
libpqrcv_get_backend_pid(WalReceiverConn *conn)
868+
{
869+
return PQbackendPID(conn->streamConn);
870+
}
871+
861872
/*
862873
* Convert tuple query result to tuplestore.
863874
*/

src/include/replication/walreceiver.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ typedef char *(*walrcv_create_slot_fn) (WalReceiverConn *conn,
226226
const char *slotname, bool temporary,
227227
CRSSnapshotAction snapshot_action,
228228
XLogRecPtr *lsn);
229+
typedef pid_t (*walrcv_get_backend_pid_fn) (WalReceiverConn *conn);
229230
typedef WalRcvExecResult *(*walrcv_exec_fn) (WalReceiverConn *conn,
230231
const char *query,
231232
const int nRetTypes,
@@ -246,6 +247,7 @@ typedef struct WalReceiverFunctionsType
246247
walrcv_receive_fn walrcv_receive;
247248
walrcv_send_fn walrcv_send;
248249
walrcv_create_slot_fn walrcv_create_slot;
250+
walrcv_get_backend_pid_fn walrcv_get_backend_pid;
249251
walrcv_exec_fn walrcv_exec;
250252
walrcv_disconnect_fn walrcv_disconnect;
251253
} WalReceiverFunctionsType;
@@ -276,6 +278,8 @@ extern PGDLLIMPORT WalReceiverFunctionsType *WalReceiverFunctions;
276278
WalReceiverFunctions->walrcv_send(conn, buffer, nbytes)
277279
#define walrcv_create_slot(conn, slotname, temporary, snapshot_action, lsn) \
278280
WalReceiverFunctions->walrcv_create_slot(conn, slotname, temporary, snapshot_action, lsn)
281+
#define walrcv_get_backend_pid(conn) \
282+
WalReceiverFunctions->walrcv_get_backend_pid(conn)
279283
#define walrcv_exec(conn, exec, nRetTypes, retTypes) \
280284
WalReceiverFunctions->walrcv_exec(conn, exec, nRetTypes, retTypes)
281285
#define walrcv_disconnect(conn) \

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy