pub struct Binder<'a> { /* private fields */ }Expand description
The binder’s working state for one statement.
Implementations§
Source§impl<'a> Binder<'a>
impl<'a> Binder<'a>
Sourcepub fn with_scratch(self, scratch: BinderScratch) -> Binder<'a>
pub fn with_scratch(self, scratch: BinderScratch) -> Binder<'a>
Binds into vectors the caller keeps, rather than into fresh ones.
For a caller that binds one statement after another, which is every
connection: the scratch is cleared on the way in, so the second bind
pushes into capacity the first one took. See BinderScratch for what
is in it and what is deliberately not.
@param scratch - the vectors to fill, cleared first
Sourcepub fn into_scratch(self) -> BinderScratch
pub fn into_scratch(self) -> BinderScratch
Returns the vectors this bind filled, for the next bind to reuse.
The binder is consumed, so nothing can still be reading what is handed
back. The bound statement is not in here - it was returned by
Binder::bind_statement and owns its own vectors.
Source§impl<'a> Binder<'a>
impl<'a> Binder<'a>
Sourcepub fn with_source(self, source: &'a [u8]) -> Binder<'a>
pub fn with_source(self, source: &'a [u8]) -> Binder<'a>
Points the binder at the text its parse came from.
A binder with no source names an unaliased expression column with the empty string, which is what a nested parse of schema text wants: those columns are never returned to anybody.
Sourcepub fn with_functions(self, functions: &'a [ExternalFunction]) -> Binder<'a>
pub fn with_functions(self, functions: &'a [ExternalFunction]) -> Binder<'a>
Names the functions an application registered on this connection.
Sourcepub fn with_collations(
self,
collations: &'a [(String, Collation)],
) -> Binder<'a>
pub fn with_collations( self, collations: &'a [(String, Collation)], ) -> Binder<'a>
Names the collations an application defined on this connection.
Sourcepub fn with_trusted_schema(self, trusted: bool) -> Binder<'a>
pub fn with_trusted_schema(self, trusted: bool) -> Binder<'a>
Says whether the connection trusts the schema it read.
PRAGMA trusted_schema is the lever, and it is read at bind time, so a
connection that changes it throws its compiled statements away - a plan
bound under one answer is that answer.
@param trusted - whether a schema may name a function that is not innocuous
Sourcepub fn in_schema(self) -> Binder<'a>
pub fn in_schema(self) -> Binder<'a>
Binds as though every expression had been written in the schema.
For a caller that already knows what it is holding is schema text and
has no enclosing statement to inherit the site from: the query
CREATE INDEX builds to fill an index on an expression, and the view
body PRAGMA table_info binds to find out a view’s columns.
The index build is why this exists (task-1972). An index on an
expression is filled by running a SELECT the engine writes out of that
expression, and a SELECT is a statement - so the build was the one
place a schema expression reached the machine with a statement’s
permissions, and CREATE INDEX i ON t (embed(body)) loaded a 275 MB
model once per row before any later write of the table was refused for
naming it.
Sourcepub fn new(
catalog: &'a dyn CatalogView,
ast: &'a Ast,
authorizer: &'a dyn Authorizer,
) -> Binder<'a>
pub fn new( catalog: &'a dyn CatalogView, ast: &'a Ast, authorizer: &'a dyn Authorizer, ) -> Binder<'a>
Returns a binder over one catalog snapshot and one parse.
Sourcepub fn with_limits(self, limits: &Limits) -> Binder<'a>
pub fn with_limits(self, limits: &Limits) -> Binder<'a>
Names the limits this connection is configured with.
Only Limit::TriggerDepth is read here; the parser reads the rest for
itself. A limit below one would refuse the first trigger of any chain,
which is not what a limit of zero means anywhere else, so it is floored
at one the way limits.toml’s own minimum says.
@param limits - the connection’s limits
Sourcepub fn with_foreign_keys(self, enforced: bool, deferred: bool) -> Binder<'a>
pub fn with_foreign_keys(self, enforced: bool, deferred: bool) -> Binder<'a>
Turns foreign-key enforcement on, and says whether it is deferred.
Off is the default, and it is SQLite’s: a constraint that has never been enforced on an existing database would refuse writes the application has always made, so the application asks for it.
Sourcepub fn dependencies(&self) -> &Dependencies
pub fn dependencies(&self) -> &Dependencies
Returns what the bound statement depends on.
Sourcepub fn bind_statement(
&mut self,
statement: &Statement,
) -> Result<BoundStatement, ParseError>
pub fn bind_statement( &mut self, statement: &Statement, ) -> Result<BoundStatement, ParseError>
Binds a statement, or reports why it cannot be bound.
Sourcepub fn bind_select(&mut self, id: SelectId) -> Result<BoundSelect, ParseError>
pub fn bind_select(&mut self, id: SelectId) -> Result<BoundSelect, ParseError>
Binds a SELECT, including its WITH prefix and every compound arm.
The block’s scope is pushed here rather than in the arm binder because
ORDER BY belongs to the statement and resolves in the first arm’s
scope: pushing and popping around the arm alone made every qualified
name in an ORDER BY report “no such table”.
Sourcepub fn bind_result_columns_public(
&mut self,
columns: &[ResultColumn],
) -> Result<Vec<BoundResultColumn>, ParseError>
pub fn bind_result_columns_public( &mut self, columns: &[ResultColumn], ) -> Result<Vec<BoundResultColumn>, ParseError>
Binds a result-column list against the current sources.
RETURNING is a result-column list over the row a DML statement wrote,
so it is bound by the same code that binds a SELECT list rather than
by a second implementation that would have to be kept in step with it.
Source§impl<'a> Binder<'a>
impl<'a> Binder<'a>
Sourcepub fn bind_directive(
&mut self,
statement: &Statement,
) -> Result<Directive, ParseError>
pub fn bind_directive( &mut self, statement: &Statement, ) -> Result<Directive, ParseError>
Binds a statement the session carries out itself.
Source§impl<'a> Binder<'a>
impl<'a> Binder<'a>
Sourcepub fn bind_insert(
&mut self,
insert: &Insert,
) -> Result<BoundInsert, ParseError>
pub fn bind_insert( &mut self, insert: &Insert, ) -> Result<BoundInsert, ParseError>
Binds an INSERT or REPLACE.
Sourcepub fn bind_update(
&mut self,
update: &Update,
) -> Result<BoundUpdate, ParseError>
pub fn bind_update( &mut self, update: &Update, ) -> Result<BoundUpdate, ParseError>
Binds an UPDATE.
Sourcepub fn bind_delete(
&mut self,
delete: &Delete,
) -> Result<BoundDelete, ParseError>
pub fn bind_delete( &mut self, delete: &Delete, ) -> Result<BoundDelete, ParseError>
Binds a DELETE.
Sourcepub fn bind_schema_expr(&mut self, sql: &[u8]) -> Result<BoundExpr, ParseError>
pub fn bind_schema_expr(&mut self, sql: &[u8]) -> Result<BoundExpr, ParseError>
Parses and binds an expression that was written in the schema.
It is parsed into its own arena and bound against the statement’s
current sources, so the result is an ordinary BoundExpr that refers to
the target table by position and carries no reference to the schema
text it came from.