From 680c7fda428a5a618c4d4c325ded97f1ea3ba2a8 Mon Sep 17 00:00:00 2001 From: Ibrar Ahmed Date: Tue, 16 Nov 2021 11:23:59 +0000 Subject: [PATCH] PG-210: Add new column toplevel. --- pg_stat_monitor.c | 7 +++++-- pg_stat_monitor.h | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index d7d49a1..768fa8c 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -1499,8 +1499,11 @@ pgss_store(uint64 queryid, key.ip = pg_get_client_addr(); key.planid = planid; key.appid = appid; +#if PG_VERSION_NUM < 140000 + key.toplevel = 1; +#else key.toplevel = (nested_level == 0); - +#endif pgss_hash = pgsm_get_hash(); LWLockAcquire(pgss->lock, LW_SHARED); @@ -1695,7 +1698,7 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo, uint64 planid = entry->key.planid; unsigned char *buf = pgss_qbuf[bucketid]; #if PG_VERSION_NUM < 140000 - bool toplevel = true; + bool toplevel = 1; bool is_allowed_role = is_member_of_role(GetUserId(), DEFAULT_ROLE_READ_ALL_STATS); #else bool is_allowed_role = is_member_of_role(GetUserId(), ROLE_PG_READ_ALL_STATS); diff --git a/pg_stat_monitor.h b/pg_stat_monitor.h index 04b5c52..84ed936 100644 --- a/pg_stat_monitor.h +++ b/pg_stat_monitor.h @@ -203,7 +203,7 @@ typedef struct pgssHashKey uint64 ip; /* client ip address */ uint64 planid; /* plan identifier */ uint64 appid; /* hash of application name */ - bool toplevel; /* query executed at top level */ + uint64 toplevel; /* query executed at top level */ } pgssHashKey; typedef struct QueryInfo