diff --git a/src/backend/distributed/planner/distributed_planner.c b/src/backend/distributed/planner/distributed_planner.c index 21de545e2..ec73567bc 100644 --- a/src/backend/distributed/planner/distributed_planner.c +++ b/src/backend/distributed/planner/distributed_planner.c @@ -75,6 +75,7 @@ static uint64 NextPlanId = 1; int PlannerLevel = 0; static bool ListContainsDistributedTableRTE(List *rangeTableList); +static bool IsFastPathRouterQuery(PlannerRestrictionContext *plannerRestrictionContext); static bool IsUpdateOrDelete(Query *query); static PlannedStmt * CreateDistributedPlannedStmt( DistributedPlanningContext *planContext); @@ -125,7 +126,6 @@ static PlannedStmt * PlanDistributedStmt(DistributedPlanningContext *planContext int rteIdCounter); static RTEListProperties * GetRTEListProperties(List *rangeTableList); - /* Distributed planner hook */ PlannedStmt * distributed_planner(Query *parse, @@ -959,6 +959,13 @@ CreateDistributedPlan(uint64 planId, Query *originalQuery, Query *query, ParamLi return NULL; } + if (distributedPlan->planningError && IsFastPathRouterQuery( + plannerRestrictionContext)) + { + /* we don't need to continue with fast path router query */ + RaiseDeferredErrorInternal(distributedPlan->planningError, ERROR); + } + /* force evaluation of bound params */ boundParams = copyParamList(boundParams); @@ -1075,6 +1082,22 @@ CreateDistributedPlan(uint64 planId, Query *originalQuery, Query *query, ParamLi } +/* + * IsFastPathRouterQuery returns true if we are processing a fast path router query. + */ +static bool +IsFastPathRouterQuery(PlannerRestrictionContext *plannerRestrictionContext) +{ + if (plannerRestrictionContext && + plannerRestrictionContext->fastPathRestrictionContext && + plannerRestrictionContext->fastPathRestrictionContext->fastPathRouterQuery) + { + return true; + } + return false; +} + + /* * EnsurePartitionTableNotReplicated errors out if the infput relation is * a partition table and the table has a replication factor greater than