mirror of https://github.com/citusdata/citus.git
PG16 compatibility - one more outer join check (#7126)
PG16 compatibility - part 11 Check out part 1marcocitus/distributed-data-dump42d956888dpart 20d503dd5acpart 3907d72e60dpart 47c6b4ce103part 56056cb2c29part 6b36c431abbpart 7ee3153fe50part 82c50b5f7ffpart 9b2291374b4part 10a2315fdc67part 119fa72545e2This commit is in the series of PG16 compatibility commits. We already took care of the majority of necessary outer join checks in part 47c6b4ce103However, In RelationInfoContainsOnlyRecurringTuples, we need to add one more check of whether we are dealing with an outer join RTE using IsRelOptOuterJoin function. This prevents an outer join crash in sqlancer_failures.sql test. We expect one more commit of PG compatibility with Citus's current features are regression tests sanity.
parent
b10320be6f
commit
2d6cf8e79a
|
|
@ -1414,6 +1414,12 @@ RelationInfoContainsOnlyRecurringTuples(PlannerInfo *plannerInfo, Relids relids)
|
||||||
|
|
||||||
while ((relationId = bms_next_member(relids, relationId)) >= 0)
|
while ((relationId = bms_next_member(relids, relationId)) >= 0)
|
||||||
{
|
{
|
||||||
|
/* outer join RTE check in PG16 */
|
||||||
|
if (IsRelOptOuterJoin(plannerInfo, relationId))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
RangeTblEntry *rangeTableEntry = plannerInfo->simple_rte_array[relationId];
|
RangeTblEntry *rangeTableEntry = plannerInfo->simple_rte_array[relationId];
|
||||||
|
|
||||||
if (FindNodeMatchingCheckFunctionInRangeTableList(list_make1(rangeTableEntry),
|
if (FindNodeMatchingCheckFunctionInRangeTableList(list_make1(rangeTableEntry),
|
||||||
|
|
|
||||||
|
|
@ -171,8 +171,6 @@ static bool FindQueryContainingRTEIdentityInternal(Node *node,
|
||||||
|
|
||||||
static int ParentCountPriorToAppendRel(List *appendRelList, AppendRelInfo *appendRelInfo);
|
static int ParentCountPriorToAppendRel(List *appendRelList, AppendRelInfo *appendRelInfo);
|
||||||
|
|
||||||
static bool IsVarRelOptOuterJoin(PlannerInfo *root, Var *varToBeAdded);
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AllDistributionKeysInQueryAreEqual returns true if either
|
* AllDistributionKeysInQueryAreEqual returns true if either
|
||||||
|
|
@ -1241,7 +1239,7 @@ AddToAttributeEquivalenceClass(AttributeEquivalenceClass *attributeEquivalenceCl
|
||||||
}
|
}
|
||||||
|
|
||||||
/* outer join checks in PG16 */
|
/* outer join checks in PG16 */
|
||||||
if (IsVarRelOptOuterJoin(root, varToBeAdded))
|
if (IsRelOptOuterJoin(root, varToBeAdded->varno))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -1388,19 +1386,19 @@ GetTargetSubquery(PlannerInfo *root, RangeTblEntry *rangeTableEntry, Var *varToB
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IsVarRelOptOuterJoin returns true if the Var to be added
|
* IsRelOptOuterJoin returns true if the RelOpt referenced
|
||||||
* is an outer join, false otherwise.
|
* by varNo is an outer join, false otherwise.
|
||||||
*/
|
*/
|
||||||
static bool
|
bool
|
||||||
IsVarRelOptOuterJoin(PlannerInfo *root, Var *varToBeAdded)
|
IsRelOptOuterJoin(PlannerInfo *root, int varNo)
|
||||||
{
|
{
|
||||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
#if PG_VERSION_NUM >= PG_VERSION_16
|
||||||
if (root->simple_rel_array_size <= varToBeAdded->varno)
|
if (root->simple_rel_array_size <= varNo)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
RelOptInfo *rel = root->simple_rel_array[varToBeAdded->varno];
|
RelOptInfo *rel = root->simple_rel_array[varNo];
|
||||||
if (rel == NULL)
|
if (rel == NULL)
|
||||||
{
|
{
|
||||||
/* must be an outer join */
|
/* must be an outer join */
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
extern bool AllDistributionKeysInQueryAreEqual(Query *originalQuery,
|
extern bool AllDistributionKeysInQueryAreEqual(Query *originalQuery,
|
||||||
PlannerRestrictionContext *
|
PlannerRestrictionContext *
|
||||||
plannerRestrictionContext);
|
plannerRestrictionContext);
|
||||||
|
extern bool IsRelOptOuterJoin(PlannerInfo *root, int varNo);
|
||||||
extern bool SafeToPushdownUnionSubquery(Query *originalQuery, PlannerRestrictionContext *
|
extern bool SafeToPushdownUnionSubquery(Query *originalQuery, PlannerRestrictionContext *
|
||||||
plannerRestrictionContext);
|
plannerRestrictionContext);
|
||||||
extern bool ContainsUnionSubquery(Query *queryTree);
|
extern bool ContainsUnionSubquery(Query *queryTree);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue