From a7fe4a6c7be1dca09f32709a40aaa30bf86d9949 Mon Sep 17 00:00:00 2001 From: Julien Rouhaud Date: Mon, 22 Jun 2020 16:32:53 +0200 Subject: [PATCH] Fix compatibility with PG13. planner_hook now requires the input query_string, and tag_hash isn't automatically available anymore with the existing includes. --- collector.c | 3 +++ pg_wait_sampling.c | 21 ++++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/collector.c b/collector.c index ba97dda..06e4d9f 100644 --- a/collector.c +++ b/collector.c @@ -10,6 +10,9 @@ #include "postgres.h" #include "catalog/pg_type.h" +#if PG_VERSION_NUM >= 130000 +#include "common/hashfn.h" +#endif #include "funcapi.h" #include "miscadmin.h" #include "postmaster/bgworker.h" diff --git a/pg_wait_sampling.c b/pg_wait_sampling.c index 6b2a93e..1bd5c76 100644 --- a/pg_wait_sampling.c +++ b/pg_wait_sampling.c @@ -50,6 +50,9 @@ CollectorShmqHeader *collector_hdr = NULL; static shmem_startup_hook_type prev_shmem_startup_hook = NULL; static PGPROC * search_proc(int backendPid); static PlannedStmt *pgws_planner_hook(Query *parse, +#if PG_VERSION_NUM >= 130000 + const char *query_string, +#endif int cursorOptions, ParamListInfo boundParams); static void pgws_ExecutorEnd(QueryDesc *queryDesc); @@ -771,7 +774,11 @@ pg_wait_sampling_get_history(PG_FUNCTION_ARGS) * planner_hook hook, save queryId for collector */ static PlannedStmt * -pgws_planner_hook(Query *parse, int cursorOptions, +pgws_planner_hook(Query *parse, +#if PG_VERSION_NUM >= 130000 + const char *query_string, +#endif + int cursorOptions, ParamListInfo boundParams) { if (MyProc) @@ -795,9 +802,17 @@ pgws_planner_hook(Query *parse, int cursorOptions, /* Invoke original hook if needed */ if (planner_hook_next) - return planner_hook_next(parse, cursorOptions, boundParams); + return planner_hook_next(parse, +#if PG_VERSION_NUM >= 130000 + query_string, +#endif + cursorOptions, boundParams); - return standard_planner(parse, cursorOptions, boundParams); + return standard_planner(parse, +#if PG_VERSION_NUM >= 130000 + query_string, +#endif + cursorOptions, boundParams); } /*