* Return a formatted string with information about the parameter values, * or NULL if there are no parameters. * The result is in the eval_mcontext. */
| 8694 | * The result is in the eval_mcontext. |
| 8695 | */ |
| 8696 | static char * |
| 8697 | format_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(¶mstr); |
| 8710 | for (paramno = 0; paramno < paramLI->numParams; paramno++) |
| 8711 | { |
| 8712 | ParamExternData *prm = ¶mLI->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(¶mstr, "%s$%d = ", |
| 8720 | paramno > 0 ? ", " : "", |
| 8721 | paramno + 1); |
| 8722 | |
| 8723 | if (prm->isnull) |
| 8724 | appendStringInfoString(¶mstr, "NULL"); |
| 8725 | else |
| 8726 | appendStringInfoStringQuoted(¶mstr, |
| 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 | } |
no test coverage detected