mirror of
https://github.com/postgres/postgres.git
synced 2025-07-07 00:36:50 +03:00
Add walreceiver API to get remote server version
Add a separate walreceiver API function walrcv_server_version() to get the version of the remote server, instead of doing it as part of walrcv_identify_system(). This allows the server version to be available even for uses that don't call IDENTIFY_SYSTEM, and it seems cleaner anyway. This is for an upcoming patch, not currently used. Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://www.postgresql.org/message-id/20190115071359.GF1433@paquier.xyz
This commit is contained in:
@ -56,8 +56,8 @@ static char *libpqrcv_get_conninfo(WalReceiverConn *conn);
|
||||
static void libpqrcv_get_senderinfo(WalReceiverConn *conn,
|
||||
char **sender_host, int *sender_port);
|
||||
static char *libpqrcv_identify_system(WalReceiverConn *conn,
|
||||
TimeLineID *primary_tli,
|
||||
int *server_version);
|
||||
TimeLineID *primary_tli);
|
||||
static int libpqrcv_server_version(WalReceiverConn *conn);
|
||||
static void libpqrcv_readtimelinehistoryfile(WalReceiverConn *conn,
|
||||
TimeLineID tli, char **filename,
|
||||
char **content, int *len);
|
||||
@ -86,6 +86,7 @@ static WalReceiverFunctionsType PQWalReceiverFunctions = {
|
||||
libpqrcv_get_conninfo,
|
||||
libpqrcv_get_senderinfo,
|
||||
libpqrcv_identify_system,
|
||||
libpqrcv_server_version,
|
||||
libpqrcv_readtimelinehistoryfile,
|
||||
libpqrcv_startstreaming,
|
||||
libpqrcv_endstreaming,
|
||||
@ -309,8 +310,7 @@ libpqrcv_get_senderinfo(WalReceiverConn *conn, char **sender_host,
|
||||
* timeline ID of the primary.
|
||||
*/
|
||||
static char *
|
||||
libpqrcv_identify_system(WalReceiverConn *conn, TimeLineID *primary_tli,
|
||||
int *server_version)
|
||||
libpqrcv_identify_system(WalReceiverConn *conn, TimeLineID *primary_tli)
|
||||
{
|
||||
PGresult *res;
|
||||
char *primary_sysid;
|
||||
@ -343,11 +343,18 @@ libpqrcv_identify_system(WalReceiverConn *conn, TimeLineID *primary_tli,
|
||||
*primary_tli = pg_strtoint32(PQgetvalue(res, 0, 1));
|
||||
PQclear(res);
|
||||
|
||||
*server_version = PQserverVersion(conn->streamConn);
|
||||
|
||||
return primary_sysid;
|
||||
}
|
||||
|
||||
/*
|
||||
* Thin wrapper around libpq to obtain server version.
|
||||
*/
|
||||
static int
|
||||
libpqrcv_server_version(WalReceiverConn *conn)
|
||||
{
|
||||
return PQserverVersion(conn->streamConn);
|
||||
}
|
||||
|
||||
/*
|
||||
* Start streaming WAL data from given streaming options.
|
||||
*
|
||||
|
@ -1674,7 +1674,6 @@ ApplyWorkerMain(Datum main_arg)
|
||||
RepOriginId originid;
|
||||
TimeLineID startpointTLI;
|
||||
char *err;
|
||||
int server_version;
|
||||
|
||||
myslotname = MySubscription->slotname;
|
||||
|
||||
@ -1708,8 +1707,7 @@ ApplyWorkerMain(Datum main_arg)
|
||||
* We don't really use the output identify_system for anything but it
|
||||
* does some initializations on the upstream so let's still call it.
|
||||
*/
|
||||
(void) walrcv_identify_system(wrconn, &startpointTLI,
|
||||
&server_version);
|
||||
(void) walrcv_identify_system(wrconn, &startpointTLI);
|
||||
|
||||
}
|
||||
|
||||
|
@ -330,7 +330,6 @@ WalReceiverMain(void)
|
||||
{
|
||||
char *primary_sysid;
|
||||
char standby_sysid[32];
|
||||
int server_version;
|
||||
WalRcvStreamOptions options;
|
||||
|
||||
/*
|
||||
@ -338,8 +337,7 @@ WalReceiverMain(void)
|
||||
* IDENTIFY_SYSTEM replication command.
|
||||
*/
|
||||
EnableWalRcvImmediateExit();
|
||||
primary_sysid = walrcv_identify_system(wrconn, &primaryTLI,
|
||||
&server_version);
|
||||
primary_sysid = walrcv_identify_system(wrconn, &primaryTLI);
|
||||
|
||||
snprintf(standby_sysid, sizeof(standby_sysid), UINT64_FORMAT,
|
||||
GetSystemIdentifier());
|
||||
|
Reference in New Issue
Block a user