* Explain a simple property. * * If "numeric" is true, the value is a number (or other value that * doesn't need quoting in JSON). * * If unit is non-NULL the text format will display it after the value. * * This usually should not be invoked directly, but via one of the datatype * specific routines ExplainPropertyText, ExplainPropertyInteger, etc. */
| 5488 | * specific routines ExplainPropertyText, ExplainPropertyInteger, etc. |
| 5489 | */ |
| 5490 | static void |
| 5491 | ExplainProperty(const char *qlabel, const char *unit, const char *value, |
| 5492 | bool numeric, ExplainState *es) |
| 5493 | { |
| 5494 | switch (es->format) |
| 5495 | { |
| 5496 | case EXPLAIN_FORMAT_TEXT: |
| 5497 | ExplainIndentText(es); |
| 5498 | if (unit) |
| 5499 | appendStringInfo(es->str, "%s: %s %s\n", qlabel, value, unit); |
| 5500 | else |
| 5501 | appendStringInfo(es->str, "%s: %s\n", qlabel, value); |
| 5502 | break; |
| 5503 | |
| 5504 | case EXPLAIN_FORMAT_XML: |
| 5505 | { |
| 5506 | char *str; |
| 5507 | |
| 5508 | appendStringInfoSpaces(es->str, es->indent * 2); |
| 5509 | ExplainXMLTag(qlabel, X_OPENING | X_NOWHITESPACE, es); |
| 5510 | str = escape_xml(value); |
| 5511 | appendStringInfoString(es->str, str); |
| 5512 | pfree(str); |
| 5513 | ExplainXMLTag(qlabel, X_CLOSING | X_NOWHITESPACE, es); |
| 5514 | appendStringInfoChar(es->str, '\n'); |
| 5515 | } |
| 5516 | break; |
| 5517 | |
| 5518 | case EXPLAIN_FORMAT_JSON: |
| 5519 | ExplainJSONLineEnding(es); |
| 5520 | appendStringInfoSpaces(es->str, es->indent * 2); |
| 5521 | escape_json(es->str, qlabel); |
| 5522 | appendStringInfoString(es->str, ": "); |
| 5523 | if (numeric) |
| 5524 | appendStringInfoString(es->str, value); |
| 5525 | else |
| 5526 | escape_json(es->str, value); |
| 5527 | break; |
| 5528 | |
| 5529 | case EXPLAIN_FORMAT_YAML: |
| 5530 | ExplainYAMLLineStarting(es); |
| 5531 | appendStringInfo(es->str, "%s: ", qlabel); |
| 5532 | if (numeric) |
| 5533 | appendStringInfoString(es->str, value); |
| 5534 | else |
| 5535 | escape_yaml(es->str, value); |
| 5536 | break; |
| 5537 | } |
| 5538 | } |
| 5539 | |
| 5540 | static void |
| 5541 | ExplainPropertyStringInfo(const char *qlabel, ExplainState *es, const char *fmt,...) |
no test coverage detected