mirror of https://github.com/citusdata/citus.git
Fix HideCitusDependentObjectsOnQueriesOfPgMetaTables function
The function should take into account the new entry for MERGE joins that is introduced in PG17 -> mergeJoinConditionpull/7796/head
parent
e4d48dc5da
commit
bd1fbff2c4
|
@ -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);
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue