Skip to content

Commit

Permalink
Fix pg17 test (#7795)
Browse files Browse the repository at this point in the history
  • Loading branch information
naisila authored Dec 20, 2024
1 parent 8d4b53e commit c8c79ec
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 217 deletions.
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
Loading

0 comments on commit c8c79ec

Please sign in to comment.