Expand description
Reading a statement into a syntax tree, inside bounds this module owns.
This module answers one question: can the parser be entered safely, and what
did it produce. It says nothing about what the statement does; that is
crate::sql::classify.
§Why the recursion guard is built here
The parser crate ships a recursive-protection feature whose stack-probing
dependency compiles C, which would stop this product installing on a host
without a C toolchain. That feature is therefore switched off in the
manifest and replaced by two measures applied here, both driven by
ParseLimits rather than by a value buried in the code:
- A ceiling on the statement size, checked before the parser is entered.
- A dedicated thread with an enlarged stack, so deep nesting exhausts a stack this module owns instead of the one the process runs on.
§Why the text is prepared before it is parsed
The parser is handed the statement the server will run, which is not always
the statement that arrived. A conditional comment carries code, and the
parser crate expands only one of the two introducers this server honours.
crate::sql::strip::expand_conditional_comments applies that one rule
first, so nothing downstream reasons about a tree the server never had.
Structs§
- Parse
Limits - The bounds applied to one parse.
Constants§
- DEFAULT_
MAX_ STATEMENT_ BYTES - The default ceiling on the size of one statement, in bytes.
- DEFAULT_
PARSER_ STACK_ BYTES - The default stack given to the thread that runs the parser, in bytes.
Functions§
- parse
- Parses a statement inside the bounds this module owns.