pub struct Query {Show 32 fields
pub relations: Vec<Relation>,
pub from: Vec<FromItem>,
pub targets: Vec<Target>,
pub filter: Option<Expr>,
pub grouped: bool,
pub group: Vec<SortGroup>,
pub grouping_sets: Vec<GroupingSet>,
pub group_distinct: bool,
pub having: Option<Expr>,
pub sort: Vec<SortGroup>,
pub distinct: Vec<SortGroup>,
pub distinct_on: bool,
pub offset: Option<Expr>,
pub limit: Option<Expr>,
pub with_ties: bool,
pub params: Vec<u32>,
pub notices: Vec<Error>,
pub set_op: Option<SetOp>,
pub windows: Vec<WindowClause>,
pub ctes: Vec<Cte>,
pub recursive: bool,
pub row_marks: Vec<RowMark>,
pub write: Option<Write>,
pub out_args: Vec<OutArg>,
pub pulled: usize,
pub pushed: bool,
pub barrier: Vec<usize>,
pub minmax: Option<Box<MinMax>>,
pub constraint_deps: Vec<u32>,
pub shown: Option<Box<Shown>>,
pub perms: Vec<PermInfo>,
pub funcs: Vec<u32>,
}Expand description
The query tree of a SELECT.
Fields§
§relations: Vec<Relation>The relations of FROM, which a crate::Var names by index.
from: Vec<FromItem>The parts of FROM. The query joins them with a cross join.
targets: Vec<Target>The columns of the result, then the junk columns that only ORDER BY and GROUP BY read.
filter: Option<Expr>The WHERE condition, of type boolean.
grouped: boolTrue when the query makes groups of rows: it has an aggregate call, GROUP BY or HAVING. With no item of GROUP BY, all the rows make one group, also when there are no rows.
group: Vec<SortGroup>The items of GROUP BY.
grouping_sets: Vec<GroupingSet>groupingSets: the grouping sets of GROUP BY, or none for a plain GROUP BY. Each set makes groups on its own items, and the other items of GROUP BY are null in its rows.
group_distinct: boolgroupDistinct: GROUP BY DISTINCT, which makes the groups of the same grouping set once.
having: Option<Expr>The HAVING condition, of type boolean, which each group must pass.
sort: Vec<SortGroup>The items of ORDER BY.
distinct: Vec<SortGroup>The items of DISTINCT or DISTINCT ON. The items of ORDER BY come first.
distinct_on: boolTrue for DISTINCT ON, which keeps the first row of each group.
offset: Option<Expr>OFFSET as bigint.
limit: Option<Expr>LIMIT or FETCH FIRST as bigint.
with_ties: boolFETCH FIRST ... WITH TIES: the rows equal to the last row on the items of ORDER BY come too.
params: Vec<u32>The type OID of each parameter, from $1.
notices: Vec<Error>The warnings and notices of the analysis, which the session sends before the result.
set_op: Option<SetOp>UNION, INTERSECT or EXCEPT. Each SELECT of the operation is a subquery in Query::relations, and the rows of the operation are the rows of the leftmost one, which the targets read. The query has no FROM.
windows: Vec<WindowClause>The windows of the window function calls and of the WINDOW clause. A crate::WindowFunc names its window by its number, from 1.
ctes: Vec<Cte>cteList: the queries of the WITH clause of the query.
recursive: boolhasRecursive: the query has WITH RECURSIVE.
row_marks: Vec<RowMark>rowMarks: the relations that FOR UPDATE or FOR SHARE locks.
write: Option<Write>The table that an INSERT writes, or None for a SELECT.
out_args: Vec<OutArg>outargs of CallStmt: the arguments of CALL for the INOUT and OUT arguments of the procedure, in order.
pulled: usizeThe number of subqueries of FROM that the planner merged into the query, which stay in the range table of PostgreSQL with no plan.
pushed: boolTrue when each condition of WHERE is a condition of the query above that the planner moved into the query, which had no WHERE. A SELECT of a UNION ALL with no WHERE is a member of the append relation, as is_safe_append_member lets it.
barrier: Vec<usize>For an UPDATE or a DELETE of a view, and for a SELECT whose view with security_barrier the executor merged, the number of the parts of AND of the condition of each view with security_barrier, the inner view first. These conditions come first in Query::filter, and they have the security_level of securityQuals: the conditions of a view run before the conditions of the views above it and of the statement, as order_qual_clauses orders them.
minmax: Option<Box<MinMax>>The queries of preprocess_minmax_aggregates for a query whose aggregate calls are each min or max of one table, which the planner can run as an InitPlan that reads the first row of an index.
constraint_deps: Vec<u32>constraintDeps: the OIDs of the primary keys that make columns of GROUP BY queries valid, which a view depends on.
shown: Option<Box<Shown>>For the query of RETURNING, the list as EXPLAIN shows it.
perms: Vec<PermInfo>rteperminfos: the privileges that the statement needs on each relation that it reads or writes, also in its subqueries and in the queries of its views. Only the top query of a statement has them.
funcs: Vec<u32>The OIDs of the functions and of the functions of the operators that the statement calls, also in its subqueries and in the queries of its views, as ExecInitFunc checks EXECUTE on them. Only the top query of a statement has them.
Implementations§
Source§impl Query
impl Query
Sourcepub fn exprs(&self) -> Vec<&Expr>
pub fn exprs(&self) -> Vec<&Expr>
The expressions of the query, in the order of query_tree_walker: the targets, the conditions of the joins, WHERE, HAVING, OFFSET, LIMIT, the offsets of the frames of the windows, the calls of the functions in FROM, the rows of the VALUES lists and the arguments of TABLESAMPLE.
Sourcepub fn exprs_mut(&mut self) -> Vec<&mut Expr>
pub fn exprs_mut(&mut self) -> Vec<&mut Expr>
The expressions of the query, in the order of Query::exprs.
Sourcepub fn has_target_srfs(&self) -> bool
pub fn has_target_srfs(&self) -> bool
hasTargetSRFs: true when a target calls a function that gives a set.
Sourcepub fn all_exprs(&self, depth: usize) -> Vec<(&Expr, usize)>
pub fn all_exprs(&self, depth: usize) -> Vec<(&Expr, usize)>
The expressions of the query and of its subqueries in FROM, each with its depth: depth for the query, and one more for each subquery in FROM between the expression and the query. The subqueries in FROM come after the expressions of the query, as in query_tree_walker.
Sourcepub fn each_expr_mut(
&mut self,
depth: usize,
f: &mut impl FnMut(&mut Expr, usize),
)
pub fn each_expr_mut( &mut self, depth: usize, f: &mut impl FnMut(&mut Expr, usize), )
Calls f for each expression of Query::all_exprs, with its depth.