Expand description
v7.22 (mailrs round-13 / T2) — shared COPY text-format helpers.
PG’s COPY is not an engine statement in SPG: both consumers
lower it to per-row INSERTs. The wire path (spg-server pgwire)
has done this since v7.15 for COPY … FROM stdin CopyData
frames; the embed path (Database::execute_script /
spg import) gained it in v7.22 because default-format
pg_dump emits COPY blocks, and the zero-change import promise
covers the default format, not just --column-inserts.
This module is the single home for the pure pieces: text-row
decoding (tab-separated, \N nulls, backslash escapes) and
INSERT synthesis. The wire path delegates here; wire-specific
concerns (CopyData framing, SKIP/ON_ERROR/JSON options) stay in
pgwire.
Structs§
- Copy
From Spec - The head of an embed-path
COPY … FROM stdin;statement.
Functions§
- build_
copy_ insert - Build
INSERT INTO <table> [(cols)] VALUES (…)from a decoded row. Numeric-looking and boolean cells go in bare so the engine sees typed literals; everything else is single-quoted with SQL escaping. - decode_
copy_ text_ row - Decode one COPY text-format data row: tab-separated cells,
\N= NULL, C-style backslash escapes. - parse_
copy_ from_ stdin_ head - Parse the head of a
COPY <table> [(cols)] FROM stdinstatement (text format). ReturnsNonewhen the statement is not that shape — includingCOPY … TO stdoutand file endpoints. A trailingWITH (…)options tail is accepted and ignored except that a non-textFORMATmakes this returnNone(the embed path only lowers the text format; callers surface a clear error).