Skip to main content

Binder

Struct Binder 

Source
pub struct Binder<'a> { /* private fields */ }
Expand description

The binder’s working state for one statement.

Implementations§

Source§

impl<'a> Binder<'a>

Source

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

Source

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>

Source

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.

Source

pub fn with_functions(self, functions: &'a [ExternalFunction]) -> Binder<'a>

Names the functions an application registered on this connection.

Source

pub fn with_collations( self, collations: &'a [(String, Collation)], ) -> Binder<'a>

Names the collations an application defined on this connection.

Source

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

Source

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.

Source

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.

Source

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

Source

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.

Source

pub fn dependencies(&self) -> &Dependencies

Returns what the bound statement depends on.

Source

pub fn bind_statement( &mut self, statement: &Statement, ) -> Result<BoundStatement, ParseError>

Binds a statement, or reports why it cannot be bound.

Source

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”.

Source

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

pub fn bind_expr(&mut self, id: ExprId) -> Result<BoundExpr, ParseError>

Binds one expression.

Source§

impl<'a> Binder<'a>

Source

pub fn bind_directive( &mut self, statement: &Statement, ) -> Result<Directive, ParseError>

Binds a statement the session carries out itself.

Source§

impl<'a> Binder<'a>

Source

pub fn bind_insert( &mut self, insert: &Insert, ) -> Result<BoundInsert, ParseError>

Binds an INSERT or REPLACE.

Source

pub fn bind_update( &mut self, update: &Update, ) -> Result<BoundUpdate, ParseError>

Binds an UPDATE.

Source

pub fn bind_delete( &mut self, delete: &Delete, ) -> Result<BoundDelete, ParseError>

Binds a DELETE.

Source

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.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for Binder<'a>

§

impl<'a> !Send for Binder<'a>

§

impl<'a> !Sync for Binder<'a>

§

impl<'a> !UnwindSafe for Binder<'a>

§

impl<'a> Freeze for Binder<'a>

§

impl<'a> Unpin for Binder<'a>

§

impl<'a> UnsafeUnpin for Binder<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.