git: 9f3a6591c599 - main - databases/pg_citus: fix build with recent postgresql versions

From: Matthew Seaman <matthew_at_FreeBSD.org>
Date: Wed, 15 Feb 2023 11:40:29 UTC
The branch main has been updated by matthew:

URL: https://cgit.FreeBSD.org/ports/commit/?id=9f3a6591c599ae3deb72c5e02f29b4457f0fecc4

commit 9f3a6591c599ae3deb72c5e02f29b4457f0fecc4
Author:     Matthew Seaman <matthew@FreeBSD.org>
AuthorDate: 2023-02-15 11:35:58 +0000
Commit:     Matthew Seaman <matthew@FreeBSD.org>
CommitDate: 2023-02-15 11:40:25 +0000

    databases/pg_citus: fix build with recent postgresql versions
    
    Partially import commit
    https://github.com/citusdata/citus/commit/341fdb32fc07a3aea2dda2fa33a70d22819be37b
    from upstream (issue https://github.com/citusdata/citus/pull/6711)
    
    PG13 and PG14 have now backported the `RelationGetSmgr` function that
    Citus already backported, so on those PG versions use the function
    from the PG sources.
    
    Reported by:    pkg-fallout
---
 databases/pg_citus/Makefile                        |  1 +
 ...-src_backend_distributed_commands_multi__copy.c |  4 ++--
 .../files/patch-src_include_pg__version__compat.h  | 28 ++++++++++++++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/databases/pg_citus/Makefile b/databases/pg_citus/Makefile
index e178094273e7..b45d5a4d83fd 100644
--- a/databases/pg_citus/Makefile
+++ b/databases/pg_citus/Makefile
@@ -1,5 +1,6 @@
 PORTNAME=	citus
 PORTVERSION=	11.2.0
+PORTREVISION=	1
 DISTVERSIONPREFIX=	v
 CATEGORIES=	databases
 PKGNAMEPREFIX=	pg_
diff --git a/databases/pg_citus/files/patch-src_backend_distributed_commands_multi__copy.c b/databases/pg_citus/files/patch-src_backend_distributed_commands_multi__copy.c
index 790a9981cf97..01041d008b54 100644
--- a/databases/pg_citus/files/patch-src_backend_distributed_commands_multi__copy.c
+++ b/databases/pg_citus/files/patch-src_backend_distributed_commands_multi__copy.c
@@ -1,6 +1,6 @@
---- src/backend/distributed/commands/multi_copy.c.orig	2021-03-09 08:26:53 UTC
+--- src/backend/distributed/commands/multi_copy.c.orig	2023-02-03 08:13:35 UTC
 +++ src/backend/distributed/commands/multi_copy.c
-@@ -53,6 +53,7 @@
+@@ -50,6 +50,7 @@
  
  #include <arpa/inet.h> /* for htons */
  #include <netinet/in.h> /* for htons */
diff --git a/databases/pg_citus/files/patch-src_include_pg__version__compat.h b/databases/pg_citus/files/patch-src_include_pg__version__compat.h
new file mode 100644
index 000000000000..a421c728c951
--- /dev/null
+++ b/databases/pg_citus/files/patch-src_include_pg__version__compat.h
@@ -0,0 +1,28 @@
+--- src/include/pg_version_compat.h.orig	2023-02-15 11:30:17 UTC
++++ src/include/pg_version_compat.h
+@@ -54,7 +54,14 @@ pg_strtoint64(char *s)
+ 	return result;
+ }
+ 
+-
++/*
++ * RelationGetSmgr got backported in 13.10 and 14.7 so redefining it for any
++ * version higher causes compilation errors due to redefining of the function.
++ * We want to use it in all versions. So we backport it ourselves in earlier
++ * versions, and rely on the Postgres provided version in the later versions.
++ */
++#if PG_VERSION_NUM >= PG_VERSION_13 && PG_VERSION_NUM < 130010 \
++	|| PG_VERSION_NUM >= PG_VERSION_14 && PG_VERSION_NUM < 140007
+ static inline SMgrRelation
+ RelationGetSmgr(Relation rel)
+ {
+@@ -64,6 +71,9 @@ RelationGetSmgr(Relation rel)
+ 	}
+ 	return rel->rd_smgr;
+ }
++
++
++#endif
+ 
+ 
+ #define CREATE_SEQUENCE_COMMAND \