Expand description
Recursive-descent parser with a Pratt (precedence-climbing) sub-parser for expressions.
Precedence (lowest → highest binding):
OR (1) < AND (2) < NOT unary (3) <
comparisons = <> < <= > >= (4) <
+ - (5) < * / (6) < unary - (7) < parens / atom.
This matches PG’s behaviour for the operators we support — e.g. NOT a = b
parses as NOT (a = b) and -a * b as (-a) * b.
Structs§
Enums§
- SciExpanded
- v7.38 (read01) — parse a lexer
Token::Numericsource string (digits with an optional single., no sign, no exponent) into(unscaled, scale)forLiteral::Numeric. ReturnsNoneif the mantissa overflows i128. v7.39 (read01 numeric.c) — the result of expanding an1.5e3-style scientific literal into PG’s plain NUMERIC decimal form.
Functions§
- expand_
scientific_ literal - Expand scientific notation into a plain decimal string by moving the decimal point — no float round-trip, so the value stays exact. PG treats such literals as NUMERIC; the digit-count caps mirror PG’s numeric format limits (“value overflows numeric format”).
- is_
multiword_ type_ phrase - v7.12.4 — map a bare type-name identifier (the form that
appears in a function arg list or RETURNS clause) to a
ColumnTypeName. ReturnsNonefor unknown / extension types so the caller can preserve them asFunctionArgType::Raw/FunctionReturn::Other. - parse_
expression - v7.9.30 — parse a single expression (no trailing junk). Used by the engine to re-hydrate stored partial-index / unique-index predicates from their canonical Display form. The same Pratt parser the statement path uses; this entry point just skips the statement dispatch.
- parse_
function_ body - v7.12.4 — parse a PL/pgSQL function body (the bytes between
$$ ... $$). Returns the parsedBEGIN ... END;block. - parse_
interval_ text - parse_
statement - Parse exactly one statement, swallow an optional trailing
;, and require the token stream to end there. PG string semantics. - parse_
statement_ with - v7.22 (round-13 T3) — dialect-aware entry:
backslash_escapesselects MySQL-style string lexing (seelexer::tokenize_with). The engine threads its session flag through here. - syntax_
error_ position - v7.39 (read01 round 95) — recover PG’s 1-based CHARACTER error position for
a
ParseError::token_pos. Kept off theParseErrorstruct (and so off every recursiveResultslot) to protect the nesting-budget frame cliff: this re-tokenizesinputon the cold error path to map the failing token index to its start byte, then to a character offset.backslash_escapesmust match the parse that producedtoken_pos(it barely shifts offsets, but stay consistent). ReturnsNonewhen the index has no offset or the byte isn’t a char boundary. The wire attaches it as the ErrorResponseP.