Skip to main content

Query

Struct Query 

Source
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: bool

True 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: bool

groupDistinct: 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: bool

True 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: bool

FETCH 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: bool

hasRecursive: 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: usize

The number of subqueries of FROM that the planner merged into the query, which stay in the range table of PostgreSQL with no plan.

§pushed: bool

True 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

Source

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.

Source

pub fn exprs_mut(&mut self) -> Vec<&mut Expr>

The expressions of the query, in the order of Query::exprs.

Source

pub fn has_target_srfs(&self) -> bool

hasTargetSRFs: true when a target calls a function that gives a set.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for Query

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Query

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Query

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for Query

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Query

Auto Trait Implementations§

§

impl Freeze for Query

§

impl RefUnwindSafe for Query

§

impl Send for Query

§

impl Sync for Query

§

impl Unpin for Query

§

impl UnsafeUnpin for Query

§

impl UnwindSafe for Query

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.