MCPcopy Create free account
hub / github.com/apache/cloudberry / plpgsql_exec_function

Function plpgsql_exec_function

src/pl/plpgsql/src/pl_exec.c:469–784  ·  view source on GitHub ↗

---------- * 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

Source from the content-addressed store, hash-verified

467 * ----------
468 */
469Datum
470plpgsql_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

Callers 2

plpgsql_call_handlerFunction · 0.85
plpgsql_inline_handlerFunction · 0.85

Calls 15

plpgsql_estate_setupFunction · 0.85
copy_plpgsql_datumsFunction · 0.85
assign_simple_varFunction · 0.85
TransferExpandedObjectFunction · 0.85
expand_arrayFunction · 0.85
exec_move_row_from_datumFunction · 0.85
exec_move_rowFunction · 0.85
exec_eval_cleanupFunction · 0.85
exec_set_foundFunction · 0.85
exec_toplevel_blockFunction · 0.85
MemoryContextSwitchToFunction · 0.85
CreateTupleDescCopyFunction · 0.85

Tested by

no test coverage detected