diff --git a/src/backend/distributed/operations/delete_protocol.c b/src/backend/distributed/operations/delete_protocol.c index 9fa7015ef..e53353b69 100644 --- a/src/backend/distributed/operations/delete_protocol.c +++ b/src/backend/distributed/operations/delete_protocol.c @@ -657,6 +657,8 @@ ShardsMatchingDeleteCriteria(Oid relationId, List *shardIntervalList, Assert(deleteCriteria != NULL); List *deleteCriteriaList = list_make1(deleteCriteria); + + /* walk over shard list and check if shards can be dropped */ ShardInterval *shardInterval = NULL; foreach_ptr(shardInterval, shardIntervalList) @@ -672,6 +674,13 @@ ShardsMatchingDeleteCriteria(Oid relationId, List *shardIntervalList, Expr *lessThanExpr = (Expr *) linitial(andExpr->args); Expr *greaterThanExpr = (Expr *) lsecond(andExpr->args); + /* + * passing NULL for plannerInfo will be problematic if we have placeholder + * vars. However, it won't be the case here because we are building + * the expression from shard intervals which don't have placeholder vars. + * Note that this is only the case with PG14 as the parameter doesn't exist + * prior to that. + */ RestrictInfo *lessThanRestrictInfo = make_simple_restrictinfo_compat(NULL, lessThanExpr); RestrictInfo *greaterThanRestrictInfo = make_simple_restrictinfo_compat(NULL, diff --git a/src/backend/distributed/planner/insert_select_planner.c b/src/backend/distributed/planner/insert_select_planner.c index 7975b6ec3..2b2bf1139 100644 --- a/src/backend/distributed/planner/insert_select_planner.c +++ b/src/backend/distributed/planner/insert_select_planner.c @@ -747,7 +747,7 @@ RouterModifyTaskForShardInterval(Query *originalQuery, continue; } - shardRestrictionList = make_simple_restrictinfo_compat(NULL, + shardRestrictionList = make_simple_restrictinfo_compat(restriction->plannerInfo, (Expr *) shardOpExpressions); extendedBaseRestrictInfo = lappend(extendedBaseRestrictInfo, shardRestrictionList);