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 }