Liking cljdoc? Tell your friends :D

datahike.pg.sql.copy.out

Field encoders for COPY ... TO, transcribed from PostgreSQL's copyto.c (CopyAttributeOutText / CopyAttributeOutCSV).

The decoders in this package's sibling namespaces answer "what did the client mean"; these answer "what does PostgreSQL write", and the two are not mirror images. Text output escapes six control characters by C notation and passes the other ASCII control characters through literally, while the reader accepts far more than the writer ever emits. CSV output quotes only when it must, and what counts as must includes a value that merely looks like the NULL marker -- otherwise the file would not read back.

A NULL is the null marker itself, written raw: in CSV it is deliberately NOT quoted, which is exactly how an unquoted empty field stays distinguishable from a quoted empty string.

Field encoders for `COPY ... TO`, transcribed from PostgreSQL's
`copyto.c` (`CopyAttributeOutText` / `CopyAttributeOutCSV`).

The decoders in this package's sibling namespaces answer "what did
the client mean"; these answer "what does PostgreSQL write", and
the two are not mirror images. Text output escapes six control
characters by C notation and passes the other ASCII control
characters through literally, while the reader accepts far more than
the writer ever emits. CSV output quotes only when it must, and what
counts as must includes a value that merely *looks* like the NULL
marker -- otherwise the file would not read back.

A NULL is the null marker itself, written raw: in CSV it is
deliberately NOT quoted, which is exactly how an unquoted empty
field stays distinguishable from a quoted empty string.
raw docstring

csv-fieldclj

(csv-field s
           delimiter
           quote
           escape
           null-marker
           {:keys [force-quote? single-attr?]})

Encode one rendered field for COPY's CSV format. nil is NULL and becomes null-marker verbatim -- unquoted, which is what keeps an empty unquoted field distinct from a quoted empty string.

Encode one rendered field for COPY's CSV format. `nil` is NULL and
becomes `null-marker` verbatim -- unquoted, which is what keeps an
empty unquoted field distinct from a quoted empty string.
sourceraw docstring

csv-needs-quote?clj

(csv-needs-quote? s delimiter quote null-marker single-attr?)

PostgreSQL's preliminary pass in CopyAttributeOutCSV.

\. alone in a single-column file is quoted so an older reader cannot mistake it for the end-of-data marker, and a value equal to the NULL marker is quoted so it reads back as data rather than NULL.

PostgreSQL's preliminary pass in `CopyAttributeOutCSV`.

`\.` alone in a single-column file is quoted so an older reader
cannot mistake it for the end-of-data marker, and a value equal to
the NULL marker is quoted so it reads back as data rather than NULL.
sourceraw docstring

row-lineclj

(row-line fields
          columns
          {:keys [format delimiter null-marker quote escape force-quote]})

Encode one row -- a vector of rendered field strings, nil for NULL -- as the line COPY writes, without its terminating newline.

columns names the fields positionally, which is what FORCE_QUOTE selects on; it is only consulted in CSV mode.

Encode one row -- a vector of rendered field strings, `nil` for NULL
-- as the line COPY writes, without its terminating newline.

`columns` names the fields positionally, which is what FORCE_QUOTE
selects on; it is only consulted in CSV mode.
sourceraw docstring

text-fieldclj

(text-field s delimiter null-marker)

Encode one rendered field for COPY's text format. nil is NULL and becomes null-marker verbatim.

Encode one rendered field for COPY's text format. `nil` is NULL and
becomes `null-marker` verbatim.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close