Remember original targetlist in MultiQueryContainerNode().

The old targetlist wasn't used so far, but the upcoming RETURNING
support relies on it.

This also allows to get rid of some crufty code in
multi_executor.c:multi_ExecutorStart(), which used the worker query's
targetlist instead of the main statement's (which didn't have one up to
now).
pull/578/head
Andres Freund 2016-06-22 14:36:36 -07:00
parent f78c135e63
commit e1282b6d70
2 changed files with 5 additions and 2 deletions

View File

@ -59,9 +59,9 @@ multi_ExecutorStart(QueryDesc *queryDesc, int eflags)
{
Task *task = NULL;
List *taskList = workerJob->taskList;
TupleDesc tupleDescriptor = ExecCleanTypeFromTL(
planStatement->planTree->targetlist, false);
List *dependendJobList PG_USED_FOR_ASSERTS_ONLY = workerJob->dependedJobList;
List *workerTargetList = multiPlan->workerJob->jobQuery->targetList;
TupleDesc tupleDescriptor = ExecCleanTypeFromTL(workerTargetList, false);
/* router executor can only execute distributed plans with a single task */
Assert(list_length(taskList) == 1);

View File

@ -185,6 +185,9 @@ MultiQueryContainerNode(PlannedStmt *result, MultiPlan *multiPlan)
fauxFunctionScan = makeNode(FunctionScan);
fauxFunctionScan->functions = lappend(fauxFunctionScan->functions, fauxFunction);
/* copy original targetlist, accessed for RETURNING queries */
fauxFunctionScan->scan.plan.targetlist = copyObject(result->planTree->targetlist);
/*
* Add set returning function to target list if the original (postgres
* created) plan doesn't support backward scans; doing so prevents