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

Function do_cast_value

src/pl/plpgsql/src/pl_exec.c:7671–7703  ·  view source on GitHub ↗

---------- * do_cast_value Slow path for exec_cast_value. * ---------- */

Source from the content-addressed store, hash-verified

7669 * ----------
7670 */
7671static Datum
7672do_cast_value(PLpgSQL_execstate *estate,
7673 Datum value, bool *isnull,
7674 Oid valtype, int32 valtypmod,
7675 Oid reqtype, int32 reqtypmod)
7676{
7677 plpgsql_CastHashEntry *cast_entry;
7678
7679 cast_entry = get_cast_hashentry(estate,
7680 valtype, valtypmod,
7681 reqtype, reqtypmod);
7682 if (cast_entry)
7683 {
7684 ExprContext *econtext = estate->eval_econtext;
7685 MemoryContext oldcontext;
7686
7687 oldcontext = MemoryContextSwitchTo(get_eval_mcontext(estate));
7688
7689 econtext->caseValue_datum = value;
7690 econtext->caseValue_isNull = *isnull;
7691
7692 cast_entry->cast_in_use = true;
7693
7694 value = ExecEvalExpr(cast_entry->cast_exprstate, econtext,
7695 isnull);
7696
7697 cast_entry->cast_in_use = false;
7698
7699 MemoryContextSwitchTo(oldcontext);
7700 }
7701
7702 return value;
7703}
7704
7705/* ----------
7706 * get_cast_hashentry Look up how to perform a type cast

Callers 1

exec_cast_valueFunction · 0.85

Calls 3

get_cast_hashentryFunction · 0.85
MemoryContextSwitchToFunction · 0.85
ExecEvalExprFunction · 0.85

Tested by

no test coverage detected