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

Function exec_assign_expr

src/pl/plpgsql/src/pl_exec.c:4938–4970  ·  view source on GitHub ↗

---------- * exec_assign_expr Put an expression's result into a variable. * ---------- */

Source from the content-addressed store, hash-verified

4936 * ----------
4937 */
4938static void
4939exec_assign_expr(PLpgSQL_execstate *estate, PLpgSQL_datum *target,
4940 PLpgSQL_expr *expr)
4941{
4942 Datum value;
4943 bool isnull;
4944 Oid valtype;
4945 int32 valtypmod;
4946
4947 /*
4948 * If first time through, create a plan for this expression.
4949 */
4950 if (expr->plan == NULL)
4951 {
4952 /*
4953 * Mark the expression as being an assignment source, if target is a
4954 * simple variable. (This is a bit messy, but it seems cleaner than
4955 * modifying the API of exec_prepare_plan for the purpose. We need to
4956 * stash the target dno into the expr anyway, so that it will be
4957 * available if we have to replan.)
4958 */
4959 if (target->dtype == PLPGSQL_DTYPE_VAR)
4960 expr->target_param = target->dno;
4961 else
4962 expr->target_param = -1; /* should be that already */
4963
4964 exec_prepare_plan(estate, expr, 0);
4965 }
4966
4967 value = exec_eval_expr(estate, expr, &isnull, &valtype, &valtypmod);
4968 exec_assign_value(estate, target, value, isnull, valtype, valtypmod);
4969 exec_eval_cleanup(estate);
4970}
4971
4972
4973/* ----------

Callers 2

exec_stmt_blockFunction · 0.85
exec_stmt_assignFunction · 0.85

Calls 4

exec_prepare_planFunction · 0.85
exec_eval_exprFunction · 0.85
exec_assign_valueFunction · 0.85
exec_eval_cleanupFunction · 0.85

Tested by

no test coverage detected