0001-Fix-base-backup-with-database-OIDs-larger-than-INT32.patch

text/plain

Filename: 0001-Fix-base-backup-with-database-OIDs-larger-than-INT32.patch
Type: text/plain
Part: 0
Message: pg_basebackup fails on databases with high OIDs

Patch

Format: format-patch
Series: patch 0001
Subject: Fix base backup with database OIDs larger than INT32_MAX
File+
src/backend/replication/basebackup.c 2 1
From 19ee6b09568b4247c33c2920277dde2fbd3f0ac4 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Sun, 29 Dec 2019 20:15:50 +0100
Subject: [PATCH] Fix base backup with database OIDs larger than INT32_MAX

---
 src/backend/replication/basebackup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index a73893237a..0e3e0c7a38 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -38,6 +38,7 @@
 #include "storage/ipc.h"
 #include "storage/reinit.h"
 #include "utils/builtins.h"
+#include "utils/fmgroids.h"
 #include "utils/ps_status.h"
 #include "utils/relcache.h"
 #include "utils/timestamp.h"
@@ -1316,7 +1317,7 @@ sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces,
 
 			if (!sizeonly)
 				sent = sendFile(pathbuf, pathbuf + basepathlen + 1, &statbuf,
-								true, isDbDir ? pg_atoi(lastDir + 1, sizeof(Oid), 0) : InvalidOid);
+								true, isDbDir ? DatumGetObjectId(OidInputFunctionCall(F_OIDIN, unconstify(char *, lastDir + 1), 0, -1)) : InvalidOid);
 
 			if (sent || sizeonly)
 			{
-- 
2.24.1