Skip to content

Commit

Permalink
fix: compatibility for differing BEENTRY macros
Browse files Browse the repository at this point in the history
  • Loading branch information
pgguru committed Feb 5, 2024
1 parent 13a1fae commit 380c88e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions pg_kaboom.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@

#define PG_KABOOM_DISCLAIMER "I can afford to lose this data and server"

#define PG_MAJOR_VERSION (PG_VERSION_NUM / 100)

/* compatibility macros */
#if PG_MAJOR_VERSION < 16
#define GET_BEENTRY(i) pgstat_fetch_stat_beentry(i);
#else
#define GET_BEENTRY(i) pgstat_get_beentry_by_backend_id(i);
#endif


#define WPN_ARGS Jsonb *payload, char *arg

/* function signature for the weapon implementation; "payload" is for weapon customization; "arg" is
Expand Down Expand Up @@ -489,8 +499,7 @@ static pid_t find_random_pid_of_type(char *type) {

/* do a linear wrapping search through the array starting at the random offset */
for (i = startIdx; i != startIdx || is_first; i = ((i + 1) >= num_procs ? 0 : i + 1), is_first = false) {
PgBackendStatus *st = pgstat_fetch_stat_beentry(i);

PgBackendStatus *st = GET_BEENTRY(i);
if (st && st->st_procpid > 0 && st->st_procpid != MyProcPid) {
/* check for correct backend type and exit loop if so */
if (st->st_backendType == backend_type) {
Expand Down

0 comments on commit 380c88e

Please sign in to comment.