* Explain a property, such as sort keys or targets, that takes the form of * a list of unlabeled items. "data" is a list of C strings. */
| 5365 | * a list of unlabeled items. "data" is a list of C strings. |
| 5366 | */ |
| 5367 | void |
| 5368 | ExplainPropertyList(const char *qlabel, List *data, ExplainState *es) |
| 5369 | { |
| 5370 | ListCell *lc; |
| 5371 | bool first = true; |
| 5372 | |
| 5373 | switch (es->format) |
| 5374 | { |
| 5375 | case EXPLAIN_FORMAT_TEXT: |
| 5376 | ExplainIndentText(es); |
| 5377 | appendStringInfo(es->str, "%s: ", qlabel); |
| 5378 | foreach(lc, data) |
| 5379 | { |
| 5380 | if (!first) |
| 5381 | appendStringInfoString(es->str, ", "); |
| 5382 | appendStringInfoString(es->str, (const char *) lfirst(lc)); |
| 5383 | first = false; |
| 5384 | } |
| 5385 | appendStringInfoChar(es->str, '\n'); |
| 5386 | break; |
| 5387 | |
| 5388 | case EXPLAIN_FORMAT_XML: |
| 5389 | ExplainXMLTag(qlabel, X_OPENING, es); |
| 5390 | foreach(lc, data) |
| 5391 | { |
| 5392 | char *str; |
| 5393 | |
| 5394 | appendStringInfoSpaces(es->str, es->indent * 2 + 2); |
| 5395 | appendStringInfoString(es->str, "<Item>"); |
| 5396 | str = escape_xml((const char *) lfirst(lc)); |
| 5397 | appendStringInfoString(es->str, str); |
| 5398 | pfree(str); |
| 5399 | appendStringInfoString(es->str, "</Item>\n"); |
| 5400 | } |
| 5401 | ExplainXMLTag(qlabel, X_CLOSING, es); |
| 5402 | break; |
| 5403 | |
| 5404 | case EXPLAIN_FORMAT_JSON: |
| 5405 | ExplainJSONLineEnding(es); |
| 5406 | appendStringInfoSpaces(es->str, es->indent * 2); |
| 5407 | escape_json(es->str, qlabel); |
| 5408 | appendStringInfoString(es->str, ": ["); |
| 5409 | foreach(lc, data) |
| 5410 | { |
| 5411 | if (!first) |
| 5412 | appendStringInfoString(es->str, ", "); |
| 5413 | escape_json(es->str, (const char *) lfirst(lc)); |
| 5414 | first = false; |
| 5415 | } |
| 5416 | appendStringInfoChar(es->str, ']'); |
| 5417 | break; |
| 5418 | |
| 5419 | case EXPLAIN_FORMAT_YAML: |
| 5420 | ExplainYAMLLineStarting(es); |
| 5421 | appendStringInfo(es->str, "%s: ", qlabel); |
| 5422 | foreach(lc, data) |
| 5423 | { |
| 5424 | appendStringInfoChar(es->str, '\n'); |
no test coverage detected