Skip to content

Commit 752c4f0

Browse files
committed
fix(pgwire): decode binary-format NUMERIC and TIMESTAMP/TIMESTAMPTZ parameters
Binary-format NUMERIC, TIMESTAMP, and TIMESTAMPTZ extended-query parameters were previously refused outright with SQLSTATE 0A000, forcing clients that declare these types via prepare_typed to fall back to text format. NUMERIC is now decoded via rust_decimal's FromSql implementation (the variable-length base-10000 digit encoding), and TIMESTAMP/TIMESTAMPTZ are decoded from their 8-byte big-endian microsecond offset from the PostgreSQL epoch, converted to NdbDateTime. Malformed payloads, overflow, and the +/-infinity sentinels are rejected with typed SQLSTATE 22P02 errors rather than panicking or silently producing a wrong value. The text-format NUMERIC path also no longer falls back to ParamValue::Text on a parse failure or mantissa overflow, since Decimal is the only downstream representation for a NUMERIC parameter and silently passing an unparseable value through as text would permanently lose precision; it now errors with the same SQLSTATE 22P02 as the binary path. Enables rust_decimal's db-postgres feature for the FromSql impl this decoding relies on.
1 parent 39598b8 commit 752c4f0

3 files changed

Lines changed: 355 additions & 68 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nodedb/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ nodedb-types = { workspace = true }
2626
nodedb-columnar = { workspace = true }
2727
nodedb-bridge = { workspace = true }
2828
nodedb-physical = { workspace = true }
29-
rust_decimal = { workspace = true }
29+
rust_decimal = { workspace = true, features = ["db-postgres"] }
3030
nodedb-cluster = { workspace = true }
3131
nodedb-raft = { workspace = true }
3232
nodedb-wal = { workspace = true }

0 commit comments

Comments
 (0)