Procs
proc decodeBinaryArray(data: openArray[byte]): tuple[elemOid: int32, dims: seq[int32], lowerBounds: seq[int32], elements: seq[tuple[off: RelOff, len: int]]] {....raises: [PgError], tags: [], forbids: [].}
- Decode binary array header. -1 len = NULL. Offsets relative to data.
proc decodeBinaryComposite(data: openArray[byte]): seq[ tuple[oid: int32, off: RelOff, len: int]] {....raises: [PgError], tags: [], forbids: [].}
- Decode binary composite. len==-1 is NULL; offsets relative.
proc decodeBinaryDate(data: openArray[byte]): DateTime {....raises: [PgError], tags: [], forbids: [].}
proc decodeBinaryTime(data: openArray[byte]): PgTime {....raises: [PgError], tags: [], forbids: [].}
proc decodeBinaryTimestamp(data: openArray[byte]): DateTime {....raises: [PgError], tags: [], forbids: [].}
proc decodeBinaryTimeTz(data: openArray[byte]): PgTimeTz {....raises: [PgError], tags: [], forbids: [].}
proc decodeBinaryTsQuery(data: openArray[byte]): string {....raises: [PgError], tags: [], forbids: [].}
- Decode PostgreSQL binary tsquery (prefix/preorder, right operand first) to the server's text representation (infix).
proc decodeBinaryTsVector(data: openArray[byte]): string {....raises: [PgError], tags: [], forbids: [].}
- Decode PostgreSQL binary tsvector to text representation.
proc decodeHstoreBinary(data: openArray[byte]): PgHstore {....raises: [PgError], tags: [], forbids: [].}
- Decode PostgreSQL binary hstore format.
proc decodeInetBinary(data: openArray[byte]): tuple[address: IpAddress, mask: uint8] {....raises: [PgError], tags: [], forbids: [].}
- Decode PostgreSQL binary inet/cidr format: 1 byte: family (2=IPv4, 3=IPv6) 1 byte: bits (netmask length) 1 byte: is_cidr (0 or 1) 1 byte: addrlen (4 or 16) N bytes: address
proc decodeNumericBinary(data: openArray[byte]): PgNumeric {....raises: [PgError], tags: [], forbids: [].}
- Decode PostgreSQL binary numeric format into PgNumeric.
proc decodePointBinary(data: openArray[byte]; off: int): PgPoint {. ...raises: [PgError], tags: [], forbids: [].}
- Decode a point from 16 bytes at offset.
proc ensureNoTrailing(pos, total: int; what: string) {.inline, ...raises: [PgTypeError], tags: [], forbids: [].}
- Reject trailing bytes after a binary value.
proc fromPgText(data: seq[byte]; oid: int32): string {....raises: [], tags: [], forbids: [].}
- Convert text-format bytes from PostgreSQL to a Nim string. The bytes are copied as is; oid is unused and kept for compatibility.
proc parseDateText(s: string): DateTime {....gcsafe, raises: [PgError], tags: [], forbids: [].}
proc parseHstoreText(s: string): PgHstore {....raises: [PgError], tags: [], forbids: [].}
- Parse PostgreSQL hstore text format: "key1"=>"val1", "key2"=>NULL.
proc parseInetText(s: string): tuple[address: IpAddress, mask: uint8] {. ...raises: [PgError], tags: [], forbids: [].}
proc parseIntervalText(s: string): PgInterval {....raises: [PgError], tags: [], forbids: [].}
-
Parse interval text output in any IntervalStyle: postgres: "1 year 2 mons 3 days 04:05:06.123456", "-1 years +3 days" postgres_verbose: "@ 1 year 2 mons 3 days 4 hours 5 mins 6.5 secs ago" sql_standard: "1-2", "3 4:05:06.5", "+1-2 -3 +4:05:06" iso_8601: "P1Y2M3DT4H5M6.5S"
infinity / -infinity (PostgreSQL 17+, every style) decode to the same all-max / all-min fields as the binary format. Oversized fields raise PgTypeError, never a Defect. Surrounding spaces are ignored.
proc parsePointsText(s: string): seq[PgPoint] {....raises: [PgError], tags: [], forbids: [].}
- Parse a comma-separated list of points like "(x1,y1),(x2,y2),...".
proc parsePointText(s: string): PgPoint {....raises: [PgError], tags: [], forbids: [].}
- Parse "(x,y)" text format.
proc parseTextArray(s: string): seq[Option[string]] {....raises: [PgError], tags: [], forbids: [].}
- Parse PostgreSQL 1-D text-format array literal: {elem1,elem2,...} Returns elements as Option[string] (none for NULL). Raises PgTypeError for multi-dimensional literals; callers that need multi-dim support should decode via the PgArray[T] accessors. Every error carries len= and pos=, the latter a 0-based byte offset into s (so it matches what the caller sees) pointing at the byte that failed — for an unterminated quoted element, at its opening quote. An empty literal has no byte to point at and reports pos=0.
proc parseTimestampText(s: string): DateTime {....gcsafe, raises: [PgError], tags: [], forbids: [].}
proc parseTimeText(s: string): PgTime {....raises: [PgError], tags: [], forbids: [].}
- Parse PostgreSQL time text format: "HH:mm:ss" or "HH:mm:ss.ffffff".
proc parseTimeTzText(s: string): PgTimeTz {....raises: [PgError], tags: [], forbids: [].}
proc rejectMultiDim(decoded: tuple[elemOid: int32, dims: seq[int32], lowerBounds: seq[int32], elements: seq[tuple[off: RelOff, len: int]]]) {. ...raises: [PgError], tags: [], forbids: [].}
- Reject multi-dim array for 1-D accessors. Use PgArray[T] instead.
Exports
-
readString, decodeFloat32BE, writeBE32, toBE64, writeBE16, fromBE16, appendBytes, decodeFloat64BE, fromBE32, writeBE64, writeBytesAt, toBE16, readBytes, toBE32, fromBE64, $, expectedElemCount, validate, PgArrayMaxDim, pgArray, pgArray, isEmpty, pgArray, validatePgArrayShape, pgArray, ==, PgArray, pgArray, ndim