Description: Update cflags and includes to allow use of libbson-dev.
Author: Christoph Berg <myon@debian.org>
Forwarded: not-needed
Last-Update: 2026-02-11
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/pg_documentdb_core/Makefile
+++ b/pg_documentdb_core/Makefile
@@ -35,9 +35,10 @@
   PG_CFLAGS += -ggdb -O0 -g
 endif
 
-SHLIB_LINK = $(libpq)
+SHLIB_LINK = $(libpq) $(shell pkg-config --libs bson2) -lbidgcc000
 
 include $(OSS_SRC_DIR)/Makefile.global
+override BITCODE_CFLAGS += $(shell pkg-config --cflags bson2)
 
 clean-sql:
 	rm -rf .deps/ build/
@@ -89,4 +90,4 @@
 	@# -undef is used to not predefine any system-specific or GCC-specific macros.
 	@# -imacros is used to specify a file that defines macros for the global context but its output is thrown away.
 	@# `man cpp` for further information
-	cpp -undef -w $(SQL_DEFINES) -imacros $(OSS_COMMON_SQL_HEADER) -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@
\ No newline at end of file
+	cpp -undef -w $(SQL_DEFINES) -imacros $(OSS_COMMON_SQL_HEADER) -P -MMD -MP -MF$(SQL_DEPDIR)/$(*F).Po -MT$@ $< > $@
--- a/pg_documentdb_core/include/io/pgbson.h
+++ b/pg_documentdb_core/include/io/pgbson.h
@@ -15,7 +15,7 @@
 #ifndef PG_BSON_H
 #define PG_BSON_H
 
-#include <bson.h>
+#include <bson/bson.h>
 
 #if PG_VERSION_NUM >= 160000
 #include <varatt.h>
--- a/pg_documentdb_core/src/bson_init.c
+++ b/pg_documentdb_core/src/bson_init.c
@@ -9,7 +9,7 @@
 #include <postgres.h>
 #include <miscadmin.h>
 #include <utils/guc.h>
-#include <bson.h>
+#include <bson/bson.h>
 
 #include "bson_init.h"
 
--- a/pg_documentdb/include/commands/commands_common.h
+++ b/pg_documentdb/include/commands/commands_common.h
@@ -102,6 +102,8 @@
 extern bool SimulateRecoveryState;
 extern bool DocumentDBPGReadOnlyForDiskFull;
 
+extern char *DistributedOperationsQuery;
+
 inline static void
 ThrowIfServerOrTransactionReadOnly(void)
 {
--- a/pg_documentdb/src/commands/current_op.c
+++ b/pg_documentdb/src/commands/current_op.c
@@ -151,7 +151,7 @@
 	"SELECT *, (10000000000 + pid)::int8 as global_pid, FALSE as worker_query, 0 AS groupid FROM pg_stat_activity";
 
 /* Similar in logic to the distributed node-id calculation */
-const char *FirstLockingPidQuery =
+static const char *FirstLockingPidQuery =
 	"SELECT array_agg( (($2 / 10000000000) * 10000000000) + pid::integer) FROM unnest(pg_blocking_pids($1::integer)) pid LIMIT 1";
 
 
@@ -482,7 +482,7 @@
 						   " pa.leader_pid::bigint AS leaderPid "
 						   " FROM (");
 
-	appendStringInfoString(queryInfo, DistributedOperationsQuery);
+        appendStringInfoString(queryInfo, DistributedOperationsQuery);
 
 	/* To get the collections associated with the command join with locks */
 	appendStringInfoString(queryInfo, ") pa LEFT JOIN lateral "
--- a/pg_documentdb/src/planner/documents_planner.c
+++ b/pg_documentdb/src/planner/documents_planner.c
@@ -12,7 +12,7 @@
 #include <float.h>
 #include <fmgr.h>
 #include <miscadmin.h>
-#include <bson.h>
+#include <bson/bson.h>
 
 #include <catalog/pg_am.h>
 #include <catalog/pg_class.h>
--- a/internal/pg_documentdb_distributed/src/documentdb_distributed.c
+++ b/internal/pg_documentdb_distributed/src/documentdb_distributed.c
@@ -9,7 +9,7 @@
 #include <postgres.h>
 #include <fmgr.h>
 #include <miscadmin.h>
-#include <bson.h>
+#include <bson/bson.h>
 #include <utils/guc.h>
 #include <access/xact.h>
 #include <utils/version_utils.h>
--- a/pg_documentdb/Makefile
+++ b/pg_documentdb/Makefile
@@ -52,6 +52,7 @@
 SHLIB_LINK = $(libpq)
 
 include $(OSS_SRC_DIR)/Makefile.global
+override BITCODE_CFLAGS += $(shell pkg-config --cflags bson2)
 
 clean-sql:
 	rm -rf .deps/ build/
@@ -98,4 +99,4 @@
 
 include $(OSS_SRC_DIR)/Makefile.versions
 
-src/documentdb_extension_version.o : build/include/metadata/documentdb_extension_version.h
\ No newline at end of file
+src/documentdb_extension_version.o : build/include/metadata/documentdb_extension_version.h
--- a/internal/pg_documentdb_distributed/Makefile
+++ b/internal/pg_documentdb_distributed/Makefile
@@ -54,6 +54,7 @@
 SHLIB_LINK = $(libpq)
 
 include $(OSS_SRC_DIR)/Makefile.global
+override BITCODE_CFLAGS += $(shell pkg-config --cflags bson2)
 
 clean-sql:
 	rm -rf .deps/ build/
@@ -93,4 +94,4 @@
 
 include $(OSS_SRC_DIR)/Makefile.versions
 
-src/documentdb_extension_version.o : build/include/metadata/documentdb_extension_version.h
\ No newline at end of file
+src/documentdb_extension_version.o : build/include/metadata/documentdb_extension_version.h
