pub struct BoundSelect {Show 15 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>,
pub shared: Option<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.
The number of the common table expression this block is a reference to, when its references share one evaluation.
SQLite evaluates a CTE that is used twice once. It matters when the body
calls random(), which must give both references the same value. None
for every other block.
Implementations§
Source§impl BoundSelect
impl BoundSelect
Sourcepub fn column_affinity(&self, index: usize) -> Affinity
pub fn column_affinity(&self, index: usize) -> Affinity
Returns the affinity a reader of result column index applies, with
“none” reported as Affinity::Blob the way a column with no declared
type reports it.
@param index - which result column
Sourcepub fn column_affinity_if_any(&self, index: usize) -> Option<Affinity>
pub fn column_affinity_if_any(&self, index: usize) -> Option<Affinity>
Returns the affinity of result column index, or None when no arm of
the block has an affinity of any kind.
None and Some(Affinity::Blob) are different answers: the first is an
expression with nothing declared, the second is a column or a clash.
A comparison treats both as “apply nothing”, but an enclosing compound
does not.
@param index - which result column
Sourcepub fn scalar_affinity(&self) -> Option<Affinity>
pub fn scalar_affinity(&self) -> Option<Affinity>
Returns the affinity a scalar subquery has as an operand.
The last arm decides, not the combination of all of them. SQLite
reads the first result column of the statement it holds for the
subquery, and for a compound that statement is the last arm. Measured
with (SELECT a FROM t UNION ALL SELECT b FROM u LIMIT 1) = 1.0 over a
TEXT a and an INTEGER b: the text row '1' is equal to 1.0,
which only the INTEGER arm’s affinity gives, and the same arms written
in the other order and compared with '1.0' answer false.
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.