Skip to main content

Module prepare

Module prepare 

Source
Expand description

The single gateway every caller statement passes through.

Nothing in this crate sends a caller’s text to the server except through this module, so the order of the defences exists in one place only and cannot be reordered by accident at a call site.

§The prepared protocol is the defence

exec_rows and exec_drop call the driver’s exec_* family, which speaks the binary prepared protocol. The server manual requires the text of a prepared statement to represent one single statement, so a text carrying two commands is refused by the server itself. That refusal does not depend on this tool reading the text correctly, which is what makes it the structural defence rather than one more textual check.

The driver’s query_* family speaks the text protocol and hands the server a text it is free to split. It is never used here. Swapping one for the other would look like a harmless simplification and would remove the whole defence, which is why the reason is written next to the code.

§A value is never pasted into the text

A caller value travels bound and never as text spliced into the statement. Splicing is injection, whatever quoting is applied first. An object name cannot travel as a parameter, and the one sanctioned way to put one into a statement is crate::sql::ident::quote.

Structs§

Gated
A statement that passed every defence and the values bound to it.

Enums§

Kind
The kinds a declared parameter may be.

Functions§

bind
Turns caller values into the shape the driver sends.
echo
Writes the exact statement to the auxiliary channel, never the primary one.
exec_count
Reads one whole number out of a single-cell result.
exec_drop
Runs a prepared statement that returns no rows.
exec_rows
Runs a prepared statement and collects the rows of its first result set.
gate
Admits one caller statement, or says exactly why it is refused.