pub struct BoundSelect {Show 14 fields
pub sources: Vec<BoundSource>,
pub filter: Option<BoundExpr>,
pub group_by: Vec<BoundExpr>,
pub having: Option<BoundExpr>,
pub columns: Vec<BoundResultColumn>,
pub distinct: bool,
pub order_by: Vec<BoundOrderTerm>,
pub limit: Option<BoundExpr>,
pub offset: Option<BoundExpr>,
pub aggregates: Vec<BoundAggregate>,
pub values: Vec<Vec<BoundExpr>>,
pub compounds: Vec<(CompoundOp, BoundSelect)>,
pub windows: Vec<BoundWindow>,
pub correlations: Vec<usize>,
}Expand description
A bound SELECT.
Fields§
§sources: Vec<BoundSource>The FROM terms, in written order.
filter: Option<BoundExpr>The WHERE clause.
group_by: Vec<BoundExpr>The GROUP BY terms.
having: Option<BoundExpr>The HAVING clause.
columns: Vec<BoundResultColumn>The result columns, after star expansion.
distinct: boolWhether DISTINCT was written.
order_by: Vec<BoundOrderTerm>The ORDER BY terms.
limit: Option<BoundExpr>The LIMIT expression.
offset: Option<BoundExpr>The OFFSET expression.
aggregates: Vec<BoundAggregate>The aggregates the statement computes.
values: Vec<Vec<BoundExpr>>The rows of a VALUES arm, when the statement is one.
compounds: Vec<(CompoundOp, BoundSelect)>The later arms of a compound, each with the operator that joined it.
When this is not empty, the order_by, limit and offset on this
block belong to the compound as a whole rather than to the first arm -
which is exactly SQLite’s rule, since an arm of a compound may not
carry its own. distinct stays the first arm’s own.
windows: Vec<BoundWindow>The window calls the block computes, in the order they were bound.
correlations: Vec<usize>The FROM terms belonging to an enclosing block that this one reads.
A block with an empty list is uncorrelated and can be evaluated once; a block with a non-empty one has to be re-evaluated for each row of the outermost term it names. The compiler needs no more than that, because the outer cursors are still open and positioned when the child runs.
Implementations§
Source§impl BoundSelect
impl BoundSelect
Sourcepub fn columns_read(&self, source: usize) -> ColumnUse
pub fn columns_read(&self, source: usize) -> ColumnUse
Returns which of one FROM term’s columns this block reads.
Every expression the block holds is visited, because the question this
answers is whether an index carries everything the query needs from a
table - and a single missed expression would be a column read from an
index that does not hold it. The walk is therefore written to be
obviously complete rather than briefly: every field of the block that
can hold an expression is named here, and BoundExpr::children is
exhaustive so a new expression variant is a compilation error rather
than an unvisited subtree.
Anything it cannot enumerate marks the answer opaque, and an opaque answer is never coverable. A nested block that correlates to this term is the case that matters: it is a query of its own and could read any column of the term it correlates to. @param source - the statement-wide number of the FROM term
Sourcepub fn is_aggregate(&self) -> bool
pub fn is_aggregate(&self) -> bool
Returns whether the statement aggregates its input into one group or into groups.