* 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. */
| 8637 | * The result is in the eval_mcontext. |
| 8638 | */ |
| 8639 | static char * |
| 8640 | format_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(¶mstr); |
| 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 | ¶mtypeid, ¶mtypmod, |
| 8668 | ¶mdatum, ¶misnull); |
| 8669 | |
| 8670 | appendStringInfo(¶mstr, "%s%s = ", |
| 8671 | paramno > 0 ? ", " : "", |
| 8672 | curvar->refname); |
| 8673 | |
| 8674 | if (paramisnull) |
| 8675 | appendStringInfoString(¶mstr, "NULL"); |
| 8676 | else |
| 8677 | appendStringInfoStringQuoted(¶mstr, |
| 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, |
no test coverage detected