Remove unnecessary VerifyMultiPlanValidity and use RaiseDeferredError directly

pull/1288/head
Metin Doslu 2017-03-10 12:09:10 +02:00
parent 9fcf42d5cd
commit 243ff736c4
3 changed files with 6 additions and 33 deletions

View File

@ -173,24 +173,18 @@ RouterCreateScan(CustomScan *scan)
* CreateDistributedPlan() couldn't find a plan due to unresolved prepared * CreateDistributedPlan() couldn't find a plan due to unresolved prepared
* statement parameters, but didn't error out, because we expect custom plans * statement parameters, but didn't error out, because we expect custom plans
* to come to our rescue. But sql (not plpgsql) functions unfortunately don't * to come to our rescue. But sql (not plpgsql) functions unfortunately don't
* go through a codepath supporting custom plans. We call VerifyMultiPlanValidity() * go through a codepath supporting custom plans. Here, we error out with this
* to do this check and provide a meaningfull error message. * delayed error message.
*/ */
Node * Node *
DelayedErrorCreateScan(CustomScan *scan) DelayedErrorCreateScan(CustomScan *scan)
{ {
CitusScanState *scanState = palloc0(sizeof(CitusScanState)); MultiPlan *multiPlan = GetMultiPlan(scan);
scanState->executorType = MULTI_EXECUTOR_INVALID_FIRST; /* raise the deferred error */
scanState->customScanState.ss.ps.type = T_CustomScanState; RaiseDeferredError(multiPlan->planningError, ERROR);
scanState->multiPlan = GetMultiPlan(scan);
Assert(IsA(scanState, CustomScanState)); return NULL;
/* ensure plan is executable */
VerifyMultiPlanValidity(scanState->multiPlan);
return (Node *) scanState;
} }

View File

@ -180,26 +180,6 @@ IsModifyMultiPlan(MultiPlan *multiPlan)
} }
/*
* VerifyMultiPlanValidity verifies that multiPlan is ready for execution, or
* errors out if not.
*
* A plan may e.g. not be ready for execution because CreateDistributedPlan()
* couldn't find a plan due to unresolved prepared statement parameters, but
* didn't error out, because we expect custom plans to come to our rescue.
* But sql (not plpgsql) functions unfortunately don't go through a codepath
* supporting custom plans.
*/
void
VerifyMultiPlanValidity(MultiPlan *multiPlan)
{
if (multiPlan->planningError)
{
RaiseDeferredError(multiPlan->planningError, ERROR);
}
}
/* /*
* CreateDistributedPlan encapsulates the logic needed to transform a particular * CreateDistributedPlan encapsulates the logic needed to transform a particular
* query into a distributed plan. * query into a distributed plan.

View File

@ -57,7 +57,6 @@ extern void multi_relation_restriction_hook(PlannerInfo *root, RelOptInfo *relOp
Index index, RangeTblEntry *rte); Index index, RangeTblEntry *rte);
extern bool IsModifyCommand(Query *query); extern bool IsModifyCommand(Query *query);
extern bool IsModifyMultiPlan(struct MultiPlan *multiPlan); extern bool IsModifyMultiPlan(struct MultiPlan *multiPlan);
extern void VerifyMultiPlanValidity(struct MultiPlan *multiPlan);
extern RangeTblEntry * RemoteScanRangeTableEntry(List *columnNameList); extern RangeTblEntry * RemoteScanRangeTableEntry(List *columnNameList);