|
34 | 34 |
|
35 | 35 |
|
36 | 36 | /* static function decls */
|
37 |
| -static void init_sexpr(Oid foid, Oid input_collation, SetExprState *sexpr, |
| 37 | +static void init_sexpr(Oid foid, Oid input_collation, Expr *node, |
| 38 | + SetExprState *sexpr, PlanState *parent, |
38 | 39 | MemoryContext sexprCxt, bool allowSRF, bool needDescForSRF);
|
39 | 40 | static void ShutdownSetExpr(Datum arg);
|
40 | 41 | static void ExecEvalFuncArgs(FunctionCallInfo fcinfo,
|
@@ -77,7 +78,7 @@ ExecInitTableFunctionResult(Expr *expr,
|
77 | 78 | state->funcReturnsSet = func->funcretset;
|
78 | 79 | state->args = ExecInitExprList(func->args, parent);
|
79 | 80 |
|
80 |
| - init_sexpr(func->funcid, func->inputcollid, state, |
| 81 | + init_sexpr(func->funcid, func->inputcollid, expr, state, parent, |
81 | 82 | econtext->ecxt_per_query_memory, func->funcretset, false);
|
82 | 83 | }
|
83 | 84 | else
|
@@ -438,15 +439,15 @@ ExecInitFunctionResultSet(Expr *expr,
|
438 | 439 | FuncExpr *func = (FuncExpr *) expr;
|
439 | 440 |
|
440 | 441 | state->args = ExecInitExprList(func->args, parent);
|
441 |
| - init_sexpr(func->funcid, func->inputcollid, state, |
| 442 | + init_sexpr(func->funcid, func->inputcollid, expr, state, parent, |
442 | 443 | econtext->ecxt_per_query_memory, true, true);
|
443 | 444 | }
|
444 | 445 | else if (IsA(expr, OpExpr))
|
445 | 446 | {
|
446 | 447 | OpExpr *op = (OpExpr *) expr;
|
447 | 448 |
|
448 | 449 | state->args = ExecInitExprList(op->args, parent);
|
449 |
| - init_sexpr(op->opfuncid, op->inputcollid, state, |
| 450 | + init_sexpr(op->opfuncid, op->inputcollid, expr, state, parent, |
450 | 451 | econtext->ecxt_per_query_memory, true, true);
|
451 | 452 | }
|
452 | 453 | else
|
@@ -645,7 +646,8 @@ ExecMakeFunctionResultSet(SetExprState *fcache,
|
645 | 646 | * init_sexpr - initialize a SetExprState node during first use
|
646 | 647 | */
|
647 | 648 | static void
|
648 |
| -init_sexpr(Oid foid, Oid input_collation, SetExprState *sexpr, |
| 649 | +init_sexpr(Oid foid, Oid input_collation, Expr *node, |
| 650 | + SetExprState *sexpr, PlanState *parent, |
649 | 651 | MemoryContext sexprCxt, bool allowSRF, bool needDescForSRF)
|
650 | 652 | {
|
651 | 653 | AclResult aclresult;
|
@@ -683,7 +685,9 @@ init_sexpr(Oid foid, Oid input_collation, SetExprState *sexpr,
|
683 | 685 | if (sexpr->func.fn_retset && !allowSRF)
|
684 | 686 | ereport(ERROR,
|
685 | 687 | (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
686 |
| - errmsg("set-valued function called in context that cannot accept a set"))); |
| 688 | + errmsg("set-valued function called in context that cannot accept a set"), |
| 689 | + parent ? executor_errposition(parent->state, |
| 690 | + exprLocation((Node *) node)) : 0)); |
687 | 691 |
|
688 | 692 | /* Otherwise, caller should have marked the sexpr correctly */
|
689 | 693 | Assert(sexpr->func.fn_retset == sexpr->funcReturnsSet);
|
|
0 commit comments