Fix definition of faux targetlist element inserted to prevent backward scans.

The targetlist contains TargetEntrys containing expressions, not
expressions directly. That didn't matter so far, but with the upcoming
RETURNING support, the targetlist is inspected to build a TupleDesc.
ExecCleanTypeFromTL hits an assert when looking at something that's not
a TargetEntry.

Mark the entry as resjunk, so it's not actually used.
pull/578/head
Andres Freund 2016-06-22 14:36:36 -07:00
parent d5ad8d7db9
commit f78c135e63
1 changed files with 9 additions and 1 deletions

View File

@ -25,6 +25,8 @@
#include "executor/executor.h"
#include "nodes/makefuncs.h"
#include "optimizer/planner.h"
#include "utils/memutils.h"
@ -196,11 +198,17 @@ MultiQueryContainerNode(PlannedStmt *result, MultiPlan *multiPlan)
if (!ExecSupportsBackwardScan(result->planTree))
{
FuncExpr *funcExpr = makeNode(FuncExpr);
TargetEntry *targetEntry = NULL;
bool resjunkAttribute = true;
funcExpr->funcretset = true;
targetEntry = makeTargetEntry((Expr *) funcExpr, InvalidAttrNumber, NULL,
resjunkAttribute);
fauxFunctionScan->scan.plan.targetlist =
lappend(fauxFunctionScan->scan.plan.targetlist,
funcExpr);
targetEntry);
}
result->planTree = (Plan *) fauxFunctionScan;