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

Function exec_assign_c_string

src/pl/plpgsql/src/pl_exec.c:4982–4999  ·  view source on GitHub ↗

---------- * exec_assign_c_string Put a C string into a text variable. * * We take a NULL pointer as signifying empty string, not SQL null. * * As with the underlying exec_assign_value, caller is expected to do * exec_eval_cleanup later. * ---------- */

Source from the content-addressed store, hash-verified

4980 * ----------
4981 */
4982static void
4983exec_assign_c_string(PLpgSQL_execstate *estate, PLpgSQL_datum *target,
4984 const char *str)
4985{
4986 text *value;
4987 MemoryContext oldcontext;
4988
4989 /* Use eval_mcontext for short-lived text value */
4990 oldcontext = MemoryContextSwitchTo(get_eval_mcontext(estate));
4991 if (str != NULL)
4992 value = cstring_to_text(str);
4993 else
4994 value = cstring_to_text("");
4995 MemoryContextSwitchTo(oldcontext);
4996
4997 exec_assign_value(estate, target, PointerGetDatum(value), false,
4998 TEXTOID, -1);
4999}
5000
5001
5002/* ----------

Callers 1

exec_stmt_getdiagFunction · 0.85

Calls 3

MemoryContextSwitchToFunction · 0.85
cstring_to_textFunction · 0.85
exec_assign_valueFunction · 0.85

Tested by

no test coverage detected