From fb3eb361798f129921d7a5ec147bc78838e210ee Mon Sep 17 00:00:00 2001 From: Marina Polyakova Date: Mon, 21 Nov 2022 17:38:20 +0300 Subject: [PATCH 1/3] Fix build due to changes in PostgreSQL 16 See the commit 3057465acfbea2f3dd7a914a1478064022c6eecd (Replace the sorted array of GUC variables with a hash table.) in PostgreSQL 16. --- compat.h | 15 +++++++++++++++ pg_wait_sampling.c | 3 +-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/compat.h b/compat.h index 3f471ce..32874f7 100644 --- a/compat.h +++ b/compat.h @@ -15,6 +15,7 @@ #include "access/tupdesc.h" #include "miscadmin.h" #include "storage/shm_mq.h" +#include "utils/guc_tables.h" static inline TupleDesc CreateTemplateTupleDescCompat(int nattrs, bool hasoid) @@ -65,4 +66,18 @@ InitPostgresCompat(const char *in_dbname, Oid dboid, #endif } +static inline void +get_guc_variables_compat(struct config_generic ***vars, int *num_vars) +{ + Assert(vars != NULL); + Assert(num_vars != NULL); + +#if PG_VERSION_NUM >= 160000 + *vars = get_guc_variables(num_vars); +#else + *vars = get_guc_variables(); + *num_vars = GetNumConfigOptions(); +#endif +} + #endif diff --git a/pg_wait_sampling.c b/pg_wait_sampling.c index 8017a6f..f31b869 100644 --- a/pg_wait_sampling.c +++ b/pg_wait_sampling.c @@ -198,8 +198,7 @@ setup_gucs() profile_pid_found = false, profile_queries_found = false; - guc_vars = get_guc_variables(); - numOpts = GetNumConfigOptions(); + get_guc_variables_compat(&guc_vars, &numOpts); for (i = 0; i < numOpts; i++) { From 0138dc7dad68d197ff6ab5f56c08f11b25dbeaac Mon Sep 17 00:00:00 2001 From: Marina Polyakova Date: Mon, 21 Nov 2022 17:41:45 +0300 Subject: [PATCH 2/3] Fix compiler warnings due to new checks in PostgreSQL 16 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit See the commit 0fe954c28584169938e5c0738cfaa9930ce77577 (Add -Wshadow=compatible-local to the standard compilation flags) in PostgreSQL 16. pg_wait_sampling.c: In function ‘pg_wait_sampling_get_current’: pg_wait_sampling.c:454:42: warning: declaration of ‘params’ shadows a previous local [-Wshadow=compatible-local] 454 | WaitCurrentContext *params; | ^~~~~~ pg_wait_sampling.c:446:34: note: shadowed declaration is here 446 | WaitCurrentContext *params; | ^~~~~~ --- pg_wait_sampling.c | 1 - 1 file changed, 1 deletion(-) diff --git a/pg_wait_sampling.c b/pg_wait_sampling.c index f31b869..eaa0327 100644 --- a/pg_wait_sampling.c +++ b/pg_wait_sampling.c @@ -451,7 +451,6 @@ pg_wait_sampling_get_current(PG_FUNCTION_ARGS) { MemoryContext oldcontext; TupleDesc tupdesc; - WaitCurrentContext *params; funcctx = SRF_FIRSTCALL_INIT(); From 95264289f6eec91a4ca2169fc1150c5f666020c8 Mon Sep 17 00:00:00 2001 From: Roman Zharkov Date: Wed, 23 Nov 2022 10:25:33 +0700 Subject: [PATCH 3/3] Replace AssertState() with Assert(). AssertArg and AssertState were removed in PostgreSQL by commit #b1099eca8f. --- collector.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/collector.c b/collector.c index e1e00cf..dcb9695 100644 --- a/collector.c +++ b/collector.c @@ -470,7 +470,7 @@ pgws_collector_main(Datum main_arg) send_profile(profile_hash, mqh); break; default: - AssertState(false); + Assert(false); } break; case SHM_MQ_DETACHED: @@ -480,7 +480,7 @@ pgws_collector_main(Datum main_arg) "detached"))); break; default: - AssertState(false); + Assert(false); } shm_mq_detach_compat(mqh, pgws_collector_mq); }