Commit 752c4f0
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
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
0 commit comments