Description: Update cflags and includes to allow use of libbson-dev.
Author: Christoph Berg <myon@debian.org>
Forwarded: not-needed
Last-Update: 2026-02-20
---
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/
--- 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";
 
 
--- 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/
--- 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/
