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

Function csv_print_field

src/fe_utils/print.c:1741–1764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1739}
1740
1741static void
1742csv_print_field(const char *str, FILE *fout, char sep)
1743{
1744 /*----------------
1745 * Enclose and escape field contents when one of these conditions is met:
1746 * - the field separator is found in the contents.
1747 * - the field contains a CR or LF.
1748 * - the field contains a double quote.
1749 * - the field is exactly "\.".
1750 * - the field separator is either "\" or ".".
1751 * The last two cases prevent producing a line that the server's COPY
1752 * command would interpret as an end-of-data marker. We only really
1753 * need to ensure that the complete line isn't exactly "\.", but for
1754 * simplicity we apply stronger restrictions here.
1755 *----------------
1756 */
1757 if (strchr(str, sep) != NULL ||
1758 strcspn(str, "\r\n\"") != strlen(str) ||
1759 strcmp(str, "\\.") == 0 ||
1760 sep == '\\' || sep == '.')
1761 csv_escaped_print(str, fout);
1762 else
1763 fputs(str, fout);
1764}
1765
1766static void
1767print_csv_text(const printTableContent *cont, FILE *fout)

Callers 2

print_csv_textFunction · 0.85
print_csv_verticalFunction · 0.85

Calls 1

csv_escaped_printFunction · 0.85

Tested by

no test coverage detected