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
pull/5209/head
Halil Ozan Akgul 2021-08-11 16:34:35 +03:00 committed by Sait Talha Nisanci
parent 54ee93885a
commit 347ae2928f
3 changed files with 11 additions and 2 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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