Documentation
¶
Overview ¶
Package pgbinary validates and normalizes PostgreSQL binary COPY streams before they are handed to DuckDB's postgres_scanner extension.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Rewrite ¶
Rewrite validates src and writes a scanner-compatible PostgreSQL binary COPY stream to dst. NUMERIC values are coerced to their destination scale using round-half-away-from-zero, matching PostgreSQL's numeric typmod behavior.
func RewriteProtocolCompleted ¶
RewriteProtocolCompleted validates a protocol-completed binary COPY stream and writes scanner-compatible file framing, including one canonical trailer when the protocol ended cleanly between tuples without one.
Types ¶
type Column ¶
type Column struct {
Numeric *Numeric
// contains filtered or unexported fields
}
Column describes scanner-sensitive properties of one binary COPY column. A nil Numeric means the field can be validated and copied byte-for-byte.
type Inspection ¶
Inspection reports whether a scanner-compatible rewrite is needed.
func Inspect ¶
func Inspect(src io.Reader, schema Schema) (Inspection, error)
Inspect validates a complete PostgreSQL binary COPY stream without retaining it in memory. It reports whether NUMERIC scales or a header extension require a scanner-compatible rewrite.
func InspectProtocolCompleted ¶
func InspectProtocolCompleted(src io.Reader, schema Schema) (Inspection, error)
InspectProtocolCompleted validates a PostgreSQL binary COPY stream after its surrounding protocol has explicitly confirmed successful completion. In that mode, EOF between complete tuples is equivalent to the canonical file trailer and requests a rewrite that adds the canonical trailer.
type Numeric ¶
Numeric describes the destination DECIMAL typmod for a PostgreSQL NUMERIC field. PostgreSQL applies this typmod (including rounding) while loading a binary COPY stream; DuckDB's read_postgres_binary currently assumes the field's wire dscale already matches it, so we apply that coercion explicitly.
type Schema ¶
type Schema struct {
Columns []Column
}
Schema is the expected tuple layout for a binary COPY stream.
func SchemaFromDatabaseTypes ¶
SchemaFromDatabaseTypes builds the validation schema carried from the control plane's lossless column metadata. Non-numeric types need no payload transformation, but still contribute to the exact tuple width.