pg_basebackup fails on databases with high OIDs

Peter Eisentraut <[email protected]>
Newsgroups gmane.comp.db.postgresql.devel.general
Organization 2ndQuadrant
Message-ID <[email protected]>
This is a new bug in PG12.  When you have a database with an OID above 
INT32_MAX (signed), then pg_basebackup fails thus:

pg_basebackup: error: could not get write-ahead log end position from 
server: ERROR:  value "3000000000" is out of range for type integer

The cause appears to be commit 6b9e875f7286d8535bff7955e5aa3602e188e436.

A possible fix is attached.  An alternative to using 
OidInputFunctionCall() would be exporting something like oidin_subr().

-- 
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
0001-Fix-base-backup-with-database-OIDs-larger-than-INT32.patch (text/plain, 1.2 KB)
From 19ee6b09568b4247c33c2920277dde2fbd3f0ac4 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.