Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 26 additions & 4 deletions src/backend/distributed/utils/citus_depended_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,24 @@ HideCitusDependentObjectsOnQueriesOfPgMetaTables(Node *node, void *context)

if (OidIsValid(metaTableOid))
{
bool mergeJoinCondition = false;
#if PG_VERSION_NUM >= PG_VERSION_17

/*
* In Postgres 17, the query tree has a specific field for the merge condition.
* So we shouldn't modify the jointree, but rather the mergeJoinCondition here
* Relevant PG17 commit: 0294df2f1
*/
mergeJoinCondition = query->mergeJoinCondition;
#endif

/*
* We found a valid pg meta class in query,
* so we assert below conditions.
*/
Assert(query->jointree != NULL);
Assert(query->jointree->fromlist != NULL);
Assert(mergeJoinCondition ||
(query->jointree != NULL &&
query->jointree->fromlist != NULL));

Node *citusDependentObjExpr =
CreateCitusDependentObjectExpr(varno, metaTableOid);
Expand All @@ -257,8 +269,18 @@ HideCitusDependentObjectsOnQueriesOfPgMetaTables(Node *node, void *context)
* We do not use security quals because a postgres vanilla test fails
* with a change of order for its result.
*/
query->jointree->quals = make_and_qual(
query->jointree->quals, citusDependentObjExpr);
if (!mergeJoinCondition)
{
query->jointree->quals = make_and_qual(
query->jointree->quals, citusDependentObjExpr);
}
else
{
#if PG_VERSION_NUM >= PG_VERSION_17
query->mergeJoinCondition = make_and_qual(
query->mergeJoinCondition, citusDependentObjExpr);
#endif
}
}

MemoryContextSwitchTo(originalContext);
Expand Down