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

Function format_preparedparamsdata

src/pl/plpgsql/src/pl_exec.c:8696–8736  ·  view source on GitHub ↗

* Return a formatted string with information about the parameter values, * or NULL if there are no parameters. * The result is in the eval_mcontext. */

Source from the content-addressed store, hash-verified

8694 * The result is in the eval_mcontext.
8695 */
8696static char *
8697format_preparedparamsdata(PLpgSQL_execstate *estate,
8698 ParamListInfo paramLI)
8699{
8700 int paramno;
8701 StringInfoData paramstr;
8702 MemoryContext oldcontext;
8703
8704 if (!paramLI)
8705 return NULL;
8706
8707 oldcontext = MemoryContextSwitchTo(get_eval_mcontext(estate));
8708
8709 initStringInfo(&paramstr);
8710 for (paramno = 0; paramno < paramLI->numParams; paramno++)
8711 {
8712 ParamExternData *prm = &paramLI->params[paramno];
8713
8714 /*
8715 * Note: for now, this is only used on ParamListInfos produced by
8716 * exec_eval_using_params(), so we don't worry about invoking the
8717 * paramFetch hook or skipping unused parameters.
8718 */
8719 appendStringInfo(&paramstr, "%s$%d = ",
8720 paramno > 0 ? ", " : "",
8721 paramno + 1);
8722
8723 if (prm->isnull)
8724 appendStringInfoString(&paramstr, "NULL");
8725 else
8726 appendStringInfoStringQuoted(&paramstr,
8727 convert_value_to_string(estate,
8728 prm->value,
8729 prm->ptype),
8730 -1);
8731 }
8732
8733 MemoryContextSwitchTo(oldcontext);
8734
8735 return paramstr.data;
8736}

Callers 1

exec_stmt_dynexecuteFunction · 0.85

Calls 6

MemoryContextSwitchToFunction · 0.85
initStringInfoFunction · 0.85
appendStringInfoFunction · 0.85
appendStringInfoStringFunction · 0.85
convert_value_to_stringFunction · 0.85

Tested by

no test coverage detected