Involved Source Files Package pgio is a low-level toolkit for building and parsing messages in the
PostgreSQL wire protocol.
pgio provides functions for appending integers to a []byte while doing byte
order conversion, and a bounds-checked Reader for parsing binary values from
untrusted input.read.gowrite.go
Package-Level Type Names (only one, which is exported)
/* sort exporteds by: | */
Reader is a bounds-checked reader for the PostgreSQL binary format. It is
designed so that decoders of untrusted input cannot forget a length check:
every read validates against the remaining bytes, and the first failure
sticks. After a failure all subsequent reads return zero values, so a
decoder can read an entire structure without intermediate error checks and
inspect Err or Finish once at the end.
Reads never panic. A decoder that branches on a value it just read (e.g. an
element count used to size an allocation) should check Err before acting on
the value.errerrorrpints[]byte(*Reader) Byte() byte Bytes reads the next n bytes. The returned slice aliases the source; it is
not a copy. CString reads a NUL-terminated string, returning the bytes before the
terminator and consuming the terminator. The returned slice aliases the
source; it is not a copy. Count reads an int32 element count and validates it against the remaining
bytes: the count must be non-negative, and since each element occupies at
least minElemSize bytes, count*minElemSize must not exceed the remaining
message. This bounds allocations sized from the count against a malicious
or corrupt message claiming a huge count. Returns 0 on any failure. Err returns the first error encountered, if any. Finish returns the first error encountered, or an error if unread bytes
remain. Decoders that must consume the entire source should end with Finish.(*Reader) Int16() int16(*Reader) Int32() int32(*Reader) Int64() int64 Remaining returns the number of unread bytes.(*Reader) Uint16() uint16(*Reader) Uint32() uint32(*Reader) Uint64() uint64 Value reads an int32 length followed by that many bytes — the standard
PostgreSQL binary representation of a value. A length of -1 means NULL and
returns (nil, true). Any other negative length is an error. The returned
slice aliases the source; null is only meaningful if Err returns nil.(*Reader) errTrailing() error(*Reader) fail(err error)(*Reader) failShort(n int) need reports whether n more bytes are available, recording an error if not.
The error is built by failShort rather than here so that need stays within
the inliner's budget. Reads of fixed-size values are the hottest path in the
driver, and an un-inlined bounds check costs more than the read itself.
*Reader : math/rand/v2.Source
func NewReader(s []byte) *Reader
func github.com/jackc/pgx/v5/pgtype.nbaseDigitsToInt64(r *Reader, digitsLeft int) (accum int64, digitsRead int)
Package-Level Functions (total 12, in which 11 are exported)