From 865c10b358b76c966914755c1f842b0dac06f44b Mon Sep 17 00:00:00 2001 From: Yves Date: Fri, 17 Jan 2025 10:59:54 +0100 Subject: [PATCH] Compat for PG 14,15 --- src/pgduckdb_background_worker.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pgduckdb_background_worker.cpp b/src/pgduckdb_background_worker.cpp index 5dfda9f1..627b7428 100644 --- a/src/pgduckdb_background_worker.cpp +++ b/src/pgduckdb_background_worker.cpp @@ -17,6 +17,8 @@ #include "pgduckdb/utility/cpp_wrapper.hpp" #include #include +#include +#include extern "C" { #include "postgres.h" @@ -138,8 +140,12 @@ bool HasBgwRunningForMyDatabase() { const auto num_backends = pgstat_fetch_stat_numbackends(); for (int backend_idx = 1; backend_idx <= num_backends; ++backend_idx) { +#if PG_VERSION_NUM >= 140000 && PG_VERSION_NUM < 160000 + PgBackendStatus *beentry = pgstat_fetch_stat_beentry(backend_idx); +#else LocalPgBackendStatus *local_beentry = pgstat_get_local_beentry_by_index(backend_idx); PgBackendStatus *beentry = &local_beentry->backendStatus; +#endif if (beentry->st_databaseid == InvalidOid) { continue; // backend is not connected to a database }