---------- * 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. * ---------- */
| 4980 | * ---------- |
| 4981 | */ |
| 4982 | static void |
| 4983 | exec_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 | /* ---------- |
no test coverage detected