Skip to content

Commit

Permalink
Compat for PG 14,15
Browse files Browse the repository at this point in the history
  • Loading branch information
Y-- committed Jan 17, 2025
1 parent 9afec02 commit 865c10b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/pgduckdb_background_worker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include "pgduckdb/utility/cpp_wrapper.hpp"
#include <string>
#include <unordered_map>
#include <sys/file.h>
#include <fcntl.h>

extern "C" {
#include "postgres.h"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 865c10b

Please sign in to comment.