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

Function format_expr_params

src/pl/plpgsql/src/pl_exec.c:8639–8689  ·  view source on GitHub ↗

* Return a formatted string with information about an expression's parameters, * or NULL if the expression does not take any parameters. * The result is in the eval_mcontext. */

Source from the content-addressed store, hash-verified

8637 * The result is in the eval_mcontext.
8638 */
8639static char *
8640format_expr_params(PLpgSQL_execstate *estate,
8641 const PLpgSQL_expr *expr)
8642{
8643 int paramno;
8644 int dno;
8645 StringInfoData paramstr;
8646 MemoryContext oldcontext;
8647
8648 if (!expr->paramnos)
8649 return NULL;
8650
8651 oldcontext = MemoryContextSwitchTo(get_eval_mcontext(estate));
8652
8653 initStringInfo(&paramstr);
8654 paramno = 0;
8655 dno = -1;
8656 while ((dno = bms_next_member(expr->paramnos, dno)) >= 0)
8657 {
8658 Datum paramdatum;
8659 Oid paramtypeid;
8660 bool paramisnull;
8661 int32 paramtypmod;
8662 PLpgSQL_var *curvar;
8663
8664 curvar = (PLpgSQL_var *) estate->datums[dno];
8665
8666 exec_eval_datum(estate, (PLpgSQL_datum *) curvar,
8667 &paramtypeid, &paramtypmod,
8668 &paramdatum, &paramisnull);
8669
8670 appendStringInfo(&paramstr, "%s%s = ",
8671 paramno > 0 ? ", " : "",
8672 curvar->refname);
8673
8674 if (paramisnull)
8675 appendStringInfoString(&paramstr, "NULL");
8676 else
8677 appendStringInfoStringQuoted(&paramstr,
8678 convert_value_to_string(estate,
8679 paramdatum,
8680 paramtypeid),
8681 -1);
8682
8683 paramno++;
8684 }
8685
8686 MemoryContextSwitchTo(oldcontext);
8687
8688 return paramstr.data;
8689}
8690
8691/*
8692 * Return a formatted string with information about the parameter values,

Callers 1

exec_stmt_execsqlFunction · 0.85

Calls 8

MemoryContextSwitchToFunction · 0.85
initStringInfoFunction · 0.85
bms_next_memberFunction · 0.85
exec_eval_datumFunction · 0.85
appendStringInfoFunction · 0.85
appendStringInfoStringFunction · 0.85
convert_value_to_stringFunction · 0.85

Tested by

no test coverage detected