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

Function plpgsql_estate_setup

src/pl/plpgsql/src/pl_exec.c:3928–4067  ·  view source on GitHub ↗

---------- * Initialize a mostly empty execution state * ---------- */

Source from the content-addressed store, hash-verified

3926 * ----------
3927 */
3928static void
3929plpgsql_estate_setup(PLpgSQL_execstate *estate,
3930 PLpgSQL_function *func,
3931 ReturnSetInfo *rsi,
3932 EState *simple_eval_estate,
3933 ResourceOwner simple_eval_resowner)
3934{
3935 HASHCTL ctl;
3936
3937 /* this link will be restored at exit from plpgsql_call_handler */
3938 func->cur_estate = estate;
3939
3940 estate->func = func;
3941 estate->trigdata = NULL;
3942 estate->evtrigdata = NULL;
3943
3944 estate->retval = (Datum) 0;
3945 estate->retisnull = true;
3946 estate->rettype = InvalidOid;
3947
3948 estate->fn_rettype = func->fn_rettype;
3949 estate->retistuple = func->fn_retistuple;
3950 estate->retisset = func->fn_retset;
3951
3952 estate->readonly_func = func->fn_readonly;
3953 estate->atomic = true;
3954
3955 estate->exitlabel = NULL;
3956 estate->cur_error = NULL;
3957
3958 estate->tuple_store = NULL;
3959 estate->tuple_store_desc = NULL;
3960 if (rsi)
3961 {
3962 estate->tuple_store_cxt = rsi->econtext->ecxt_per_query_memory;
3963 estate->tuple_store_owner = CurrentResourceOwner;
3964 }
3965 else
3966 {
3967 estate->tuple_store_cxt = NULL;
3968 estate->tuple_store_owner = NULL;
3969 }
3970 estate->rsi = rsi;
3971
3972 estate->found_varno = func->found_varno;
3973 estate->ndatums = func->ndatums;
3974 estate->datums = NULL;
3975 /* the datums array will be filled by copy_plpgsql_datums() */
3976 estate->datum_context = CurrentMemoryContext;
3977
3978 /* initialize our ParamListInfo with appropriate hook functions */
3979 estate->paramLI = makeParamList(0);
3980 estate->paramLI->paramFetch = plpgsql_param_fetch;
3981 estate->paramLI->paramFetchArg = (void *) estate;
3982 estate->paramLI->paramCompile = plpgsql_param_compile;
3983 estate->paramLI->paramCompileArg = NULL; /* not needed */
3984 estate->paramLI->parserSetup = (ParserSetupHook) plpgsql_parser_setup;
3985 estate->paramLI->parserSetupArg = NULL; /* filled during use */

Callers 3

plpgsql_exec_functionFunction · 0.85
plpgsql_exec_triggerFunction · 0.85

Calls 3

makeParamListFunction · 0.85
hash_createFunction · 0.85
plpgsql_create_econtextFunction · 0.85

Tested by

no test coverage detected