fix crash

onder_pg16_outer_crash
onderkalaci 2023-08-16 17:01:12 +03:00
parent dbfcb69d57
commit b1b78f73a5
3 changed files with 14 additions and 6 deletions

View File

@ -1416,6 +1416,14 @@ RelationInfoContainsOnlyRecurringTuples(PlannerInfo *plannerInfo, Relids relids)
{ {
RangeTblEntry *rangeTableEntry = plannerInfo->simple_rte_array[relationId]; RangeTblEntry *rangeTableEntry = plannerInfo->simple_rte_array[relationId];
if (IsRelOptOuterJoin(plannerInfo, relationId))
{
/*
* TODO: add comment
*/
continue;
}
if (FindNodeMatchingCheckFunctionInRangeTableList(list_make1(rangeTableEntry), if (FindNodeMatchingCheckFunctionInRangeTableList(list_make1(rangeTableEntry),
IsDistributedTableRTE)) IsDistributedTableRTE))
{ {

View File

@ -171,7 +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);
/* /*
@ -1241,7 +1240,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;
} }
@ -1391,16 +1390,16 @@ GetTargetSubquery(PlannerInfo *root, RangeTblEntry *rangeTableEntry, Var *varToB
* IsVarRelOptOuterJoin returns true if the Var to be added * IsVarRelOptOuterJoin returns true if the Var to be added
* is an outer join, false otherwise. * 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 */

View File

@ -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);