---------- * plpgsql_exec_function Called by the call handler for * function execution. * * This is also used to execute inline code blocks (DO blocks). The only * difference that this code is aware of is that for a DO block, we want * to use a private simple_eval_estate and a private simple_eval_resowner, * which are created and passed in by the caller. For regular functions, * pass
| 467 | * ---------- |
| 468 | */ |
| 469 | Datum |
| 470 | plpgsql_exec_function(PLpgSQL_function *func, FunctionCallInfo fcinfo, |
| 471 | EState *simple_eval_estate, |
| 472 | ResourceOwner simple_eval_resowner, |
| 473 | ResourceOwner procedure_resowner, |
| 474 | bool atomic) |
| 475 | { |
| 476 | PLpgSQL_execstate estate; |
| 477 | ErrorContextCallback plerrcontext; |
| 478 | int i; |
| 479 | int rc; |
| 480 | |
| 481 | /* |
| 482 | * Setup the execution state |
| 483 | */ |
| 484 | plpgsql_estate_setup(&estate, func, (ReturnSetInfo *) fcinfo->resultinfo, |
| 485 | simple_eval_estate, simple_eval_resowner); |
| 486 | estate.procedure_resowner = procedure_resowner; |
| 487 | estate.atomic = atomic; |
| 488 | |
| 489 | /* |
| 490 | * Setup error traceback support for ereport() |
| 491 | */ |
| 492 | plerrcontext.callback = plpgsql_exec_error_callback; |
| 493 | plerrcontext.arg = &estate; |
| 494 | plerrcontext.previous = error_context_stack; |
| 495 | error_context_stack = &plerrcontext; |
| 496 | |
| 497 | /* |
| 498 | * Make local execution copies of all the datums |
| 499 | */ |
| 500 | estate.err_text = gettext_noop("during initialization of execution state"); |
| 501 | copy_plpgsql_datums(&estate, func); |
| 502 | |
| 503 | /* |
| 504 | * Store the actual call argument values into the appropriate variables |
| 505 | */ |
| 506 | estate.err_text = gettext_noop("while storing call arguments into local variables"); |
| 507 | for (i = 0; i < func->fn_nargs; i++) |
| 508 | { |
| 509 | int n = func->fn_argvarnos[i]; |
| 510 | |
| 511 | switch (estate.datums[n]->dtype) |
| 512 | { |
| 513 | case PLPGSQL_DTYPE_VAR: |
| 514 | { |
| 515 | PLpgSQL_var *var = (PLpgSQL_var *) estate.datums[n]; |
| 516 | |
| 517 | assign_simple_var(&estate, var, |
| 518 | fcinfo->args[i].value, |
| 519 | fcinfo->args[i].isnull, |
| 520 | false); |
| 521 | |
| 522 | /* |
| 523 | * Force any array-valued parameter to be stored in |
| 524 | * expanded form in our local variable, in hopes of |
| 525 | * improving efficiency of uses of the variable. (This is |
| 526 | * a hack, really: why only arrays? Need more thought |
no test coverage detected