Skip to content

Commit

Permalink
Attempt to fix PG16 compatibility (ildus#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
x4m authored and Jesús Botella committed Sep 19, 2024
1 parent 5646baf commit a4815c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/binary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
11 changes: 11 additions & 0 deletions src/clickhouse_fdw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit a4815c8

Please sign in to comment.