Skip to main content

Module copy_in

Module copy_in 

Source
Expand description

PostgreSQL COPY ... FROM STDIN (copy-in) support.

The wire handshake is driven by pgwire: returning [Response::CopyIn] from a query handler makes the server send a CopyInResponse and enter the copy-in sub-protocol; subsequent CopyData messages from the client are dispatched to [CopyHandler], whose implementation below parses the data stream incrementally and flushes it into the query handler as [RowInsertRequests] batches.

Β§Formats

The supported formats are the explicit codec::CopyFormat enum β€” csv (table-bound, incremental row parsing) and influxdb (table-less, one bounded whole-payload request). Each format states its own target rule and ingestion shape in the match arms of the copy lifecycle below; adding a format is a new variant plus its arms. Builders resolve a FORMAT name (and its aliases) through REGISTERED_FORMATS. See the codec module docs.

ModulesΒ§

arrow πŸ”’
Standard Arrow IPC streams over COPY, using Flight’s bulk ingestion core.
codec πŸ”’
The COPY FROM STDIN formats.
csv πŸ”’
The csv format β€” currently the only implemented COPY FROM STDIN format.
influxdb πŸ”’
The influxdb line protocol format for COPY FROM STDIN.
jsonl πŸ”’
The jsonl format: newline-delimited JSON objects, one per record.
options πŸ”’
Format-neutral collection of COPY WITH (...) options.
otlp πŸ”’
The otlp format for COPY FROM STDIN: one binary OTLP payload for any of the three signals β€” ExportMetricsServiceRequest, ExportTraceServiceRequest or ExportLogsServiceRequest.
parse πŸ”’
Textual parser for COPY ... FROM STDIN statements.
prom_write πŸ”’
The promwrite format for COPY FROM STDIN: one Prometheus Remote Write request body (v1 or v2), snappy- or zstd-compressed protobuf.

StructsΒ§

BufferedReservation πŸ”’
The receive-stage reservation for one buffered payload, handed to the flush that consumes the payload: the guards must outlive the payload’s bytes (they may coexist with the decode buffer or wait on decode quota), and charged_bytes is the payload’s pre-charged reservation to hand to decode-side fits checks.
CopyFromStdin πŸ”’
The parsed COPY tbl [(columns)] FROM STDIN [(options)] statement.
CopyInState πŸ”’
Per-connection state of an in-progress COPY FROM STDIN.
TableCopyMemory πŸ”’
Estimated working-set reservation for a row-based COPY stream.

EnumsΒ§

Payload πŸ”’

ConstantsΒ§

COPY_IN_FLUSH_ROWS πŸ”’
Number of parsed rows buffered before flushing a batch to the handler.
COPY_IN_MAX_PAYLOAD_BYTES
Default upper bound of a table-less COPY FROM STDIN payload (influxdb line protocol, OTLP, Prometheus Remote Write). One COPY statement is one bounded ingestion request (the whole payload is buffered like one HTTP request body); a larger import is multiple COPY statements. Deployments override it with postgres.max_copy_in_payload (0 disables the bound).
REGISTERED_FORMATS πŸ”’
The registered COPY FROM STDIN formats: accepted FORMAT name to builder. Unimplemented PostgreSQL text/binary formats are registered to report a clear β€œnot supported yet” instead of an unknown-format error.

FunctionsΒ§

adjust_query_context πŸ”’
all_rejected_error πŸ”’
The error for an OTLP payload whose points/spans were all rejected, carrying the pipeline’s reason when it provided one.
bad_copy_data πŸ”’
build_grpc_column_schema πŸ”’
build_unimplemented_binary_codec πŸ”’
build_unimplemented_text_codec πŸ”’
copy_from_stdin_from_sql πŸ”’
Parses a leading COPY ... FROM STDIN statement from SQL text.
copy_in_error πŸ”’
copy_in_must_run_alone_error πŸ”’
invalid_text_repr πŸ”’
is_copy_from_stdin πŸ”’
Whether an already-parsed statement is a COPY ... FROM STDIN; used to reject copy-in statements trailing other statements, where the textual scanner (which only sees statement-leading COPYs) does not see them.
resolve_columns πŸ”’
resolve_format πŸ”’
Resolves the format from the parsed options.
resolve_otlp_target πŸ”’
Resolves the SQL target’s scope and supplies a fallback destination for logs/traces. The explicit WITH table_name option takes precedence over the SQL target’s name, but does not override its catalog/schema.
resolve_table_name πŸ”’
Resolves table name parts against the query context defaults.
semantic_type_of πŸ”’
Derives a column’s semantic type the same way the flow adapter does (flow::adapter::util::column_schemas_to_proto): the time-index flag for timestamps, primary-key membership for tags.
unsupported πŸ”’

Type AliasesΒ§

FormatBuilder πŸ”’
Builds a format from the format-neutral option set.