From a4815c8852ee29ce460d90114c7b4b99080b954e Mon Sep 17 00:00:00 2001 From: Andrey Borodin Date: Wed, 24 Apr 2024 00:25:16 +0300 Subject: [PATCH] Attempt to fix PG16 compatibility (#105) --- src/binary.cc | 4 ++-- src/clickhouse_fdw.c | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/binary.cc b/src/binary.cc index 5f427f6..8f57451 100644 --- a/src/binary.cc +++ b/src/binary.cc @@ -58,7 +58,7 @@ static void * exc_palloc(Size size) void * ret; MemoryContext context = CurrentMemoryContext; - AssertArg(MemoryContextIsValid(context)); + Assert(MemoryContextIsValid(context)); if (!AllocSizeIsValid(size)) throw std::bad_alloc(); @@ -80,7 +80,7 @@ void * exc_palloc0(Size size) void * ret; MemoryContext context = CurrentMemoryContext; - AssertArg(MemoryContextIsValid(context)); + Assert(MemoryContextIsValid(context)); if (!AllocSizeIsValid(size)) throw std::bad_alloc(); diff --git a/src/clickhouse_fdw.c b/src/clickhouse_fdw.c index 9d5376c..1c2722e 100644 --- a/src/clickhouse_fdw.c +++ b/src/clickhouse_fdw.c @@ -768,7 +768,11 @@ clickhouseBeginForeignScan(ForeignScanState *node, int eflags) else rtindex = bms_next_member(fsplan->fs_relids, -1); rte = rt_fetch(rtindex, estate->es_range_table); +#if PG_VERSION_NUM >= 160000 + userid = OidIsValid(fsplan->checkAsUser) ? fsplan->checkAsUser : GetUserId(); +#else userid = rte->checkAsUser ? rte->checkAsUser : GetUserId(); +#endif /* Get info about foreign table. */ table = GetForeignTable(rte->relid); @@ -1377,7 +1381,11 @@ create_foreign_modify(EState *estate, * Identify which user to do the remote access as. This should match what * ExecCheckRTEPerms() does. */ +#if PG_VERSION_NUM >= 160000 + userid = ExecGetResultRelCheckAsUser(rri, estate); +#else userid = rte->checkAsUser ? rte->checkAsUser : GetUserId(); +#endif /* Get info about foreign table. */ table = GetForeignTable(RelationGetRelid(rel)); @@ -2171,6 +2179,9 @@ foreign_grouping_ok(PlannerInfo *root, RelOptInfo *grouped_rel, expr, true, false, +#if PG_VERSION_NUM >= 160000 + false, +#endif false, root->qual_security_level, grouped_rel->relids,