From 815e543bfe0a1e44d1cccff8270747d9dc01146a Mon Sep 17 00:00:00 2001 From: Ibrar Ahmed Date: Tue, 27 Jul 2021 12:57:29 +0000 Subject: [PATCH] PG-194: PostgreSQL 13.3 and 14 support. --- pg_stat_monitor.c | 75 +++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 32 deletions(-) diff --git a/pg_stat_monitor.c b/pg_stat_monitor.c index e74e415..b062fbd 100644 --- a/pg_stat_monitor.c +++ b/pg_stat_monitor.c @@ -126,11 +126,11 @@ static bool pgss_ExecutorCheckPerms(List *rt, bool abort); #if PG_VERSION_NUM >= 130000 static PlannedStmt * pgss_planner_hook(Query *parse, const char *query_string, int cursorOptions, ParamListInfo boundParams); static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString, - ProcessUtilityContext context, - ParamListInfo params, QueryEnvironment *queryEnv, - DestReceiver *dest, - QueryCompletion *qc - ); + bool readOnlyTree, + ProcessUtilityContext context, + ParamListInfo params, QueryEnvironment *queryEnv, + DestReceiver *dest, + QueryCompletion *qc); #else static void BufferUsageAccumDiff(BufferUsage* bufusage, BufferUsage* pgBufferUsage, BufferUsage* bufusage_start); static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString, @@ -742,15 +742,18 @@ pgss_planner_hook(Query *parse, const char *query_string, int cursorOptions, Par } #endif + /* * ProcessUtility hook */ #if PG_VERSION_NUM >= 130000 static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString, + bool readOnlyTree, ProcessUtilityContext context, ParamListInfo params, QueryEnvironment *queryEnv, DestReceiver *dest, QueryCompletion *qc) + #else static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString, ProcessUtilityContext context, ParamListInfo params, @@ -792,26 +795,30 @@ static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString, INSTR_TIME_SET_CURRENT(start); PG_TRY(); { +#if PG_VERSION_NUM >= 130000 + if (prev_ProcessUtility) + prev_ProcessUtility(pstmt, queryString, + readOnlyTree, + context, params, queryEnv, + dest, + qc); + else + standard_ProcessUtility(pstmt, queryString, + readOnlyTree, + context, params, queryEnv, + dest, + qc); +#else if (prev_ProcessUtility) prev_ProcessUtility(pstmt, queryString, context, params, queryEnv, - dest -#if PG_VERSION_NUM >= 130000 - ,qc -#else - ,completionTag -#endif - ); + dest, + completionTag); else standard_ProcessUtility(pstmt, queryString, context, params, queryEnv, - dest -#if PG_VERSION_NUM >= 130000 - ,qc -#else - ,completionTag + dest); #endif - ); } PG_CATCH(); { @@ -848,25 +855,29 @@ static void pgss_ProcessUtility(PlannedStmt *pstmt, const char *queryString, } else { +#if PG_VERSION_NUM >= 130000 + if (prev_ProcessUtility) + prev_ProcessUtility(pstmt, queryString, + readOnlyTree, + context, params, queryEnv, + dest, + qc); + standard_ProcessUtility(pstmt, queryString, + readOnlyTree, + context, params, queryEnv, + dest, + qc); +#else if (prev_ProcessUtility) prev_ProcessUtility(pstmt, queryString, context, params, queryEnv, - dest -#if PG_VERSION_NUM >= 130000 - ,qc -#else - ,completionTag -#endif - ); - standard_ProcessUtility(pstmt, queryString, + dest, + completionTag); + standard_ProcessUtility(pstmt, queryString, context, params, queryEnv, - dest -#if PG_VERSION_NUM >= 130000 - ,qc -#else - ,completionTag + dest, + completionTag); #endif - ); } }