pub struct Select {
pub distinct: bool,
pub items: Vec<Item>,
pub from: Vec<From>,
pub filter: Vec<Expr>,
pub group: Vec<Name>,
pub order: Vec<Order>,
pub limit: Option<usize>,
pub offset: usize,
}Expand description
What a query asks for.
The relational half is several tables joined by an equality, a group by with its
aggregates, and distinct. None of those is interpreted here — crate::query compiles them
into a crate::plan::Plan and crate::engine runs it, so the join in a select and the
join in a for loop are one operator
(docs/99 §99.9 item 9).
The scalar half is Expr, and it is a per-row expression language rather than the
04 §4.2 Query sub-language: it computes
nothing a program could not, and it exists because psql writes case, a function call and a
regular expression into the queries it sends the catalogue (crate::pg).
Fields§
§distinct: boolselect distinct — the algebra’s δ, and crate::plan::Op::Distinct is what answers it.
items: Vec<Item>§from: Vec<From>The tables, in the order they were written. Empty for select 1; one for a scan; more when
the query joins, and every entry after the first carries the equality that joins it.
filter: Vec<Expr>The where, as the conjunction it is: every term must be true of a row.
A conjunction rather than one expression because that is the unit a term can be pushed
into a scan as — crate::query splits these by the table each names — and and is the
operator that makes splitting them sound.
group: Vec<Name>group by — the columns whose distinct values are the output’s rows.
order: Vec<Order>order by, in the order the keys were written; the first that distinguishes two rows
decides.
limit: Option<usize>§offset: usize