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

Function plpgsql_param_eval_generic_ro

src/pl/plpgsql/src/pl_exec.c:6626–6663  ·  view source on GitHub ↗

* plpgsql_param_eval_generic_ro evaluation of EEOP_PARAM_CALLBACK step * * This handles all variable types, but assumes we need to invoke * MakeExpandedObjectReadOnly (hence, variable must be of a varlena type). */

Source from the content-addressed store, hash-verified

6624 * MakeExpandedObjectReadOnly (hence, variable must be of a varlena type).
6625 */
6626static void
6627plpgsql_param_eval_generic_ro(ExprState *state, ExprEvalStep *op,
6628 ExprContext *econtext)
6629{
6630 ParamListInfo params;
6631 PLpgSQL_execstate *estate;
6632 int dno = op->d.cparam.paramid - 1;
6633 PLpgSQL_datum *datum;
6634 Oid datumtype;
6635 int32 datumtypmod;
6636
6637 /* fetch back the hook data */
6638 params = econtext->ecxt_param_list_info;
6639 estate = (PLpgSQL_execstate *) params->paramFetchArg;
6640 Assert(dno >= 0 && dno < estate->ndatums);
6641
6642 /* now we can access the target datum */
6643 datum = estate->datums[dno];
6644
6645 /* fetch datum's value */
6646 exec_eval_datum(estate, datum,
6647 &datumtype, &datumtypmod,
6648 op->resvalue, op->resnull);
6649
6650 /* safety check -- needed for, eg, record fields */
6651 if (unlikely(datumtype != op->d.cparam.paramtype))
6652 ereport(ERROR,
6653 (errcode(ERRCODE_DATATYPE_MISMATCH),
6654 errmsg("type of parameter %d (%s) does not match that when preparing the plan (%s)",
6655 op->d.cparam.paramid,
6656 format_type_be(datumtype),
6657 format_type_be(op->d.cparam.paramtype))));
6658
6659 /* force the value to read-only */
6660 *op->resvalue = MakeExpandedObjectReadOnly(*op->resvalue,
6661 *op->resnull,
6662 -1);
6663}
6664
6665
6666/*

Callers

nothing calls this directly

Calls 4

exec_eval_datumFunction · 0.85
format_type_beFunction · 0.85
errcodeFunction · 0.50
errmsgFunction · 0.50

Tested by

no test coverage detected