Skip to main content

Crate cufflink_sql_parse

Crate cufflink_sql_parse 

Source
Expand description

PostgreSQL’s own parser for Cufflink guests that accept SQL they did not write.

  • bounds: what is refused before the parser runs.
  • wire: how the platform talks to a parser process.
  • golden: statements and the answers this release gives them.
  • With the parser feature, the parse itself (pg_query), which the parser process and the native test host run.

Modules§

bounds
What the parser is never handed: input past MAX_INPUT_BYTES, and input whose tree could be deep enough to exhaust the parse’s stack.
golden
The golden corpus: statements accepted and refused, and the answer this release gives each, committed so that every implementation of the parse (the parser process, the platform, the test host) is checked against fixed bytes rather than against itself.
wire
Between the platform and a parser process, over the process’s stdin and stdout: frames of a 4-byte big-endian length and that many bytes.

Constants§

MAX_TREE_NESTING
The deepest a tree’s text may nest, in objects and arrays. A guest reads the answer with serde_json, which stops at 128 levels, and the answer wraps the tree in two more; a deeper tree is TooLarge.
PARSER
The pg_query release that parses, which fixes PostgreSQL’s grammar.
PROBE
The probe corpus: one statement a line.
PROBE_FINGERPRINT
The SHA-256 of PROBE’s trees as PARSER reads them: for each statement in order, its tree’s canonical text and a \n. A parser process whose fingerprint differs is not used.

Functions§

answer_around
What surrounds a tree’s canonical text in the sql_parse host function’s answer, a ParseResponse::Ok, so that the tree is written into the answer as it is read and never parsed again on the way.