summaryrefslogtreecommitdiff
path: root/src/bin/pg_rewind/libpq_fetch.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_rewind/libpq_fetch.c')
-rw-r--r--src/bin/pg_rewind/libpq_fetch.c29
1 files changed, 2 insertions, 27 deletions
diff --git a/src/bin/pg_rewind/libpq_fetch.c b/src/bin/pg_rewind/libpq_fetch.c
index 0cdff55cab..79bec40b02 100644
--- a/src/bin/pg_rewind/libpq_fetch.c
+++ b/src/bin/pg_rewind/libpq_fetch.c
@@ -14,10 +14,6 @@
#include <fcntl.h>
#include <unistd.h>
-/* for ntohl/htonl */
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
#include "pg_rewind.h"
#include "datapagemap.h"
#include "fetch.h"
@@ -28,6 +24,7 @@
#include "libpq-fe.h"
#include "catalog/catalog.h"
#include "catalog/pg_type.h"
+#include "port/pg_bswap.h"
static PGconn *conn = NULL;
@@ -220,28 +217,6 @@ libpqProcessFileList(void)
PQclear(res);
}
-/*
- * Converts an int64 from network byte order to native format.
- */
-static int64
-pg_recvint64(int64 value)
-{
- union
- {
- int64 i64;
- uint32 i32[2];
- } swap;
- int64 result;
-
- swap.i64 = value;
-
- result = (uint32) ntohl(swap.i32[0]);
- result <<= 32;
- result |= (uint32) ntohl(swap.i32[1]);
-
- return result;
-}
-
/*----
* Runs a query, which returns pieces of files from the remote source data
* directory, and overwrites the corresponding parts of target files with
@@ -318,7 +293,7 @@ receiveFileChunks(const char *sql)
/* Read result set to local variables */
memcpy(&chunkoff, PQgetvalue(res, 0, 1), sizeof(int64));
- chunkoff = pg_recvint64(chunkoff);
+ chunkoff = pg_ntoh64(chunkoff);
chunksize = PQgetlength(res, 0, 2);
filenamelen = PQgetlength(res, 0, 0);