Skip to main content

Module sqlite

Module sqlite 

Source
Expand description

The SQLite analysis, over SQLite’s own resolved tree (crate::sqlite_tree, produced by csrc/reylo_sqlite.c from a patched amalgamation). SQLite resolves the names, the join sides, every parameter’s context and the DML target columns itself, and reports each expression’s affinity. What SQLite has no facts for stays here, as explicit tables: the result type and nullability of the built-in functions, the type a function gives its arguments, the arithmetic rule, and the row-count proof from the unique keys. The host runs two queries, one for the schema DDL and one for the functions its SQLite has; everything else happens inside the engine.

Two entries share the code: analyze, replayed through the Host like every dialect, and analyze_ddl, for a host that holds a live connection and runs DDL_QUERY and FUNCTIONS_QUERY on it itself, with Extras naming the scalar functions it registers there.

Structs§

Extras
What a host says of the SQLite on its own connection: the functions it registers there, and the functions that SQLite has (FUNCTIONS_QUERY; None when it cannot list them).
HostFunction
One row of FUNCTIONS_QUERY.
SqliteAnalysis
analyze_ddl’s answer: the analysis, and what the tree adds for a host that types a result column by the spelling its table declares.
TotalFunction
A scalar function the host registers on its own connection, which the engine’s replay cannot see: the replay registers a stub under the same name and argument count, so a statement calling it prepares, and the function table types a call as returns, NULL only when an argument is. A function the host vouches for as total, Postgres’s Trust::total in SQLite’s terms: NULL only when an argument is, with the argument count SQLite resolves a call by.

Enums§

Affinity
A storage class a value lands in, as SQLite names a column’s affinity.

Constants§

DDL_QUERY
The schema, as SQLite stores it: its sql column is the DDL the engine replays into its in-memory copy. The replayed entry asks the host for it; a host with a connection of its own runs it there and hands the rows to analyze_ddl.
FUNCTIONS_QUERY
The functions the host’s SQLite has, which decide what a statement may call: SQLite builds differ in them (the math functions, soundex, a newer release’s additions), and the embedded one has every optional family, so it alone would accept a call the host then refuses to run. The replayed entry asks the host for it; a host with a connection of its own runs it there and hands the rows to Extras::host through host_functions. A SQLite that cannot answer (an old one whose pragma lacks these columns, or a service that refuses the pragma) is taken to have what the embedded one has.

Functions§

affinity
SQLite’s five affinity rules over a declared type.
analyze
The replayed entry: the host answers DDL_QUERY and FUNCTIONS_QUERY (session-scoped, asked in one round), the rest is [run]. marked names the parameters cast to nullable(…).
analyze_ddl
The direct entry, for a host with a connection of its own: ddl is the sql column of DDL_QUERY run there, extras the functions it registers there. No round trip; a lex error, a prepare error (SQLite’s own message, at its offset) and a replay failure come back as diagnostics, as on the replayed path.
host_functions
The rows of FUNCTIONS_QUERY as the host’s function list; None when there is none to read, since every SQLite has functions and an empty list would refuse every call.