Expand description
Postgres-semantic value coercion for planner use-sites.
The planner matches sqlparser::ast::Value in numeric contexts
(LIMIT, OFFSET, fusion weights, …). When a parameter was sent over
the pgwire Parse message with Type::UNKNOWN — the default for
drivers that don’t pre-fetch OIDs, e.g. postgres-js with
fetch_types: false — our bind layer emits it as
Value::SingleQuotedString (we have no type information to do
otherwise at bind time, and a guess-and-coerce approach would
silently corrupt string parameters bound into string columns).
Postgres’ model: UNKNOWN literals stay uncoerced until the planner
has context, and the planner then resolves them by the surrounding
operator / column type. These helpers are the single chokepoint
implementing that resolution for numeric contexts. Any future
numeric use-site must route through here — a raw
match Value::Number ignores UNKNOWN-coerced literals and
re-introduces the silent match-failure bug class.
Functions§
- as_
f64_ literal - Resolve a
Valueinto anf64if numeric-shaped. - as_
usize_ literal - Resolve a
Valueinto ausizeif numeric-shaped. - expr_
as_ usize_ literal - Resolve an
Expr::Valueinto ausizeif numeric-shaped. Thin wrapper that unpacks theExpr→Valuelayer so callers reading LIMIT/OFFSET clauses don’t each re-write the unpack.