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

Function list_join

src/backend/commands/exttablecmds.c:619–645  ·  view source on GitHub ↗

* Join the elements of the list separated by the specified delimiter and * return as a string. There will be no whitespace added for prettyprinting, * this is more intended for serializing. The caller is responsible for * managing the returned memory. */

Source from the content-addressed store, hash-verified

617 * managing the returned memory.
618 */
619static char *
620list_join(List *list, char delimiter)
621{
622 ListCell *cell;
623 StringInfoData buf;
624
625 if (list_length(list) == 0)
626 return pstrdup("");
627
628 initStringInfo(&buf);
629
630 foreach(cell, list)
631 {
632 const char *cellval;
633
634 cellval = strVal(lfirst(cell));
635 appendStringInfo(&buf, "%s%c", cellval, delimiter);
636 }
637
638 /*
639 * Rather than keeping track of when we're adding the last element, trim
640 * the final delimiter to keep it simple.
641 */
642 buf.data[buf.len - 1] = '\0';
643
644 return buf.data;
645}
646
647/*
648 * Transform the FORMAT options List into a new List suitable for storing in

Callers 1

transformFormatOptsFunction · 0.85

Calls 5

list_lengthFunction · 0.85
initStringInfoFunction · 0.85
appendStringInfoFunction · 0.85
pstrdupFunction · 0.50
foreachFunction · 0.50

Tested by

no test coverage detected