pub struct SelectStatement {Show 16 fields
pub locking: Option<Box<LockingClause>>,
pub ctes: Vec<Cte>,
pub distinct: bool,
pub distinct_on: Vec<Expr>,
pub items: Vec<SelectItem>,
pub from: Option<FromClause>,
pub where_: Option<Expr>,
pub group_by: Option<Vec<Expr>>,
pub group_by_all: bool,
pub having: Option<Expr>,
pub unions: Vec<(UnionKind, SelectStatement)>,
pub order_by: Vec<OrderBy>,
pub limit: Option<LimitExpr>,
pub offset: Option<LimitExpr>,
pub limit_with_ties: bool,
pub window_check_exprs: Vec<Expr>,
}Fields§
§locking: Option<Box<LockingClause>>v7.39 (round 293, E3 Phase 1) — FOR UPDATE and friends. The
clause was parsed and DISCARDED since v7.17, so SPG accepted the
whole syntax and locked nothing: two workers running the classic
SKIP LOCKED queue take both took the same row.
v7.39 (round 305) — boxed. A locking clause appears on a
vanishing fraction of SELECTs, but an inline Option<LockingClause>
cost every SelectStatement 32 bytes, and this struct sits in
recursive evaluation frames where the engine already runs close to
its stack budget (a 512 KB depth guard is the canary).
ctes: Vec<Cte>v4.11: WITH name AS (SELECT ...) [, ...] common-table
expressions, materialised once at query start before the
body SELECT runs. Empty for a regular SELECT. Non-recursive
only — no WITH RECURSIVE for v4.x.
distinct: bool§distinct_on: Vec<Expr>v7.37.17 (17.6 siblings) — SELECT DISTINCT ON (exprs):
keep the first row (per ORDER BY) of each group the
expressions define. Empty = no DISTINCT ON.
items: Vec<SelectItem>§from: Option<FromClause>§where_: Option<Expr>§group_by: Option<Vec<Expr>>§group_by_all: boolv6.4.1 — GROUP BY ALL shortcut: when true, the planner
expands group_by to every non-aggregate SELECT-list item
before the executor runs. Mutually exclusive with an
explicit group_by list (the parser sets exactly one).
having: Option<Expr>HAVING <expr> — filter applied after GROUP BY aggregation.
Supports aggregate calls (e.g. HAVING count(*) > 1); the
aggregate executor resolves them through the same synthetic
schema used for the SELECT items.
unions: Vec<(UnionKind, SelectStatement)>UNION / UNION ALL chain. Empty for a plain SELECT. Each peer is
itself a SelectStatement with order_by = None and limit = None (the parser enforces that — ORDER BY / LIMIT belong to the
top of the chain).
order_by: Vec<OrderBy>v6.4.0 — multi-key ORDER BY. Empty Vec means no ORDER BY.
Keys are matched left-to-right: first key decides, ties break
to the second, etc.
limit: Option<LimitExpr>LIMIT <n> — bound on row output. n is an integer
literal or (v7.9.24) a placeholder $N resolved
against the prepared-statement Bind values. mailrs
migration follow-up H2.
offset: Option<LimitExpr>OFFSET <n> — drop the first n rows after ORDER BY but
before LIMIT (so LIMIT 10 OFFSET 5 keeps rows 6..=15).
limit_with_ties: boolv7.17.0 Phase 3.P0-49 — FETCH FIRST <n> ROWS WITH TIES
(SQL:2008). When true and an ORDER BY is present, the
executor extends past the LIMIT-truncated tail to include
every row whose ORDER BY key equals the last-kept row’s
key. Requires an ORDER BY; the executor errors otherwise
(matching PG’s WITH TIES rule). The parser was already
accepting WITH TIES since Phase 5.1; this field captures
the choice so the executor can act on it.
window_check_exprs: Vec<Expr>v7.39 (round 705) — the key expressions of WINDOW-clause definitions
that NOTHING referenced. PG analyses every definition whether
referenced or not, so WINDOW w AS (ORDER BY nosuch) fails there
and silently succeeded here — the referenced ones get their columns
resolved through the WindowFunction nodes they were inlined into,
and the unreferenced ones used to be dropped at parse, unexamined.
The engine resolves these with a LIMIT-0 probe of the same FROM.
Not part of Display: an unreferenced definition has no effect on
the result, so a deparsed body (a stored view) omits it.
Implementations§
Source§impl SelectStatement
v7.9.24 — extract LIMIT / OFFSET as a u32 literal. After
the engine’s substitute_placeholders pass these are
always Literal; in the simple-query path a Placeholder
shape returns None (executor surfaces as
“LIMIT/OFFSET ${n} requires prepared-statement binding”).
impl SelectStatement
v7.9.24 — extract LIMIT / OFFSET as a u32 literal. After
the engine’s substitute_placeholders pass these are
always Literal; in the simple-query path a Placeholder
shape returns None (executor surfaces as
“LIMIT/OFFSET ${n} requires prepared-statement binding”).
pub fn limit_literal(&self) -> Option<u32>
pub fn offset_literal(&self) -> Option<u32>
Trait Implementations§
Source§impl Clone for SelectStatement
impl Clone for SelectStatement
Source§fn clone(&self) -> SelectStatement
fn clone(&self) -> SelectStatement
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more