From 347ae2928f9d9b7328e08eec887324cfa5d335a0 Mon Sep 17 00:00:00 2001 From: Halil Ozan Akgul Date: Wed, 11 Aug 2021 16:34:35 +0300 Subject: [PATCH] Introduces stats_compat macro for MemoryContextMethods->stats stats function now have a new bool print_to_stderr parameter This new macro gives us the ability to use this new parameter for PG14 and it doesn't give the parameter for previous versions Existing print_to_stderr parameter is set to true to keep current behavior Relevant PG commit: 43620e328617c1f41a2a54c8cee01723064e3ffa --- src/backend/columnar/columnar_debug.c | 3 ++- src/backend/distributed/test/xact_stats.c | 4 +++- src/include/distributed/version_compat.h | 6 ++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/backend/columnar/columnar_debug.c b/src/backend/columnar/columnar_debug.c index 5b62a3b56..5525bb032 100644 --- a/src/backend/columnar/columnar_debug.c +++ b/src/backend/columnar/columnar_debug.c @@ -17,6 +17,7 @@ #include "catalog/pg_type.h" #include "distributed/pg_version_constants.h" #include "distributed/tuplestore.h" +#include "distributed/version_compat.h" #include "miscadmin.h" #include "storage/fd.h" #include "storage/smgr.h" @@ -161,5 +162,5 @@ MemoryContextTotals(MemoryContext context, MemoryContextCounters *counters) MemoryContextTotals(child, counters); } - context->methods->stats(context, NULL, NULL, counters); + context->methods->stats_compat(context, NULL, NULL, counters, true); } diff --git a/src/backend/distributed/test/xact_stats.c b/src/backend/distributed/test/xact_stats.c index 05723aa35..c31a17b7f 100644 --- a/src/backend/distributed/test/xact_stats.c +++ b/src/backend/distributed/test/xact_stats.c @@ -19,6 +19,7 @@ #include "pgstat.h" #include "distributed/transaction_management.h" +#include "distributed/version_compat.h" static Size MemoryContextTotalSpace(MemoryContext context); @@ -47,7 +48,8 @@ MemoryContextTotalSpace(MemoryContext context) Size totalSpace = 0; MemoryContextCounters totals = { 0 }; - TopTransactionContext->methods->stats(TopTransactionContext, NULL, NULL, &totals); + TopTransactionContext->methods->stats_compat(TopTransactionContext, NULL, NULL, + &totals, true); totalSpace += totals.totalspace; for (MemoryContext child = context->firstchild; diff --git a/src/include/distributed/version_compat.h b/src/include/distributed/version_compat.h index aa438ad0e..f4a036a01 100644 --- a/src/include/distributed/version_compat.h +++ b/src/include/distributed/version_compat.h @@ -37,6 +37,9 @@ #define STATUS_WAITING_COMPAT PROC_WAIT_STATUS_WAITING #define getObjectTypeDescription_compat(a, b) getObjectTypeDescription(a, b) #define getObjectIdentity_compat(a, b) getObjectIdentity(a, b) + +/* for MemoryContextMethods->stats */ +#define stats_compat(a, b, c, d, e) stats(a, b, c, d, e) #else #define AlterTableStmtObjType(a) ((a)->relkind) #define F_NEXTVAL_COMPAT F_NEXTVAL_OID @@ -44,6 +47,9 @@ #define STATUS_WAITING_COMPAT STATUS_WAITING #define getObjectTypeDescription_compat(a, b) getObjectTypeDescription(a) #define getObjectIdentity_compat(a, b) getObjectIdentity(a) + +/* for MemoryContextMethods->stats */ +#define stats_compat(a, b, c, d, e) stats(a, b, c, d) #endif #if PG_VERSION_NUM >= PG_VERSION_13