* Prepare targetlist SRF function call for execution. * * This is used by nodeProjectSet.c. */
| 445 | * This is used by nodeProjectSet.c. |
| 446 | */ |
| 447 | SetExprState * |
| 448 | ExecInitFunctionResultSet(Expr *expr, |
| 449 | ExprContext *econtext, PlanState *parent) |
| 450 | { |
| 451 | SetExprState *state = makeNode(SetExprState); |
| 452 | |
| 453 | state->funcReturnsSet = true; |
| 454 | state->expr = expr; |
| 455 | state->func.fn_oid = InvalidOid; |
| 456 | |
| 457 | /* |
| 458 | * Initialize metadata. The expression node could be either a FuncExpr or |
| 459 | * an OpExpr. |
| 460 | */ |
| 461 | if (IsA(expr, FuncExpr)) |
| 462 | { |
| 463 | FuncExpr *func = (FuncExpr *) expr; |
| 464 | |
| 465 | state->args = ExecInitExprList(func->args, parent); |
| 466 | init_sexpr(func->funcid, func->inputcollid, expr, state, parent, |
| 467 | econtext->ecxt_per_query_memory, true, true); |
| 468 | } |
| 469 | else if (IsA(expr, OpExpr)) |
| 470 | { |
| 471 | OpExpr *op = (OpExpr *) expr; |
| 472 | |
| 473 | state->args = ExecInitExprList(op->args, parent); |
| 474 | init_sexpr(op->opfuncid, op->inputcollid, expr, state, parent, |
| 475 | econtext->ecxt_per_query_memory, true, true); |
| 476 | } |
| 477 | else |
| 478 | elog(ERROR, "unrecognized node type: %d", |
| 479 | (int) nodeTag(expr)); |
| 480 | |
| 481 | /* shouldn't get here unless the selected function returns set */ |
| 482 | Assert(state->func.fn_retset); |
| 483 | |
| 484 | return state; |
| 485 | } |
| 486 | |
| 487 | /* |
| 488 | * ExecMakeFunctionResultSet |
no test coverage detected