Skip to main content

Expr

Enum Expr 

Source
pub enum Expr {
Show 22 variants IntLiteral(String), NumericLiteral(String), StringLiteral(String), BoolLiteral(bool), NullLiteral, Column { table: Option<String>, name: String, }, Param(u32), Default, Unary { op: UnaryOp, expr: Box<Expr>, }, Binary { op: BinaryOp, left: Box<Expr>, right: Box<Expr>, }, Func(FuncCall), IsNull { expr: Box<Expr>, negated: bool, }, InList { expr: Box<Expr>, list: Vec<Expr>, negated: bool, }, Between { expr: Box<Expr>, low: Box<Expr>, high: Box<Expr>, negated: bool, }, Like { expr: Box<Expr>, pattern: Box<Expr>, negated: bool, case_insensitive: bool, }, Case { operand: Option<Box<Expr>>, whens: Vec<(Expr, Expr)>, else_result: Option<Box<Expr>>, }, Cast { expr: Box<Expr>, ty: ColumnType, }, ScalarSubquery(Box<QueryExpr>), Exists(Box<QueryExpr>), InSubquery { expr: Box<Expr>, subquery: Box<QueryExpr>, negated: bool, }, Quantified { expr: Box<Expr>, op: BinaryOp, all: bool, subquery: Box<QueryExpr>, }, Const { value: Datum, ty: ColumnType, },
}

Variants§

§

IntLiteral(String)

§

NumericLiteral(String)

SP32: a decimal/exponent literal. PostgreSQL types these as numeric (SP30 typed them float8; SP32 introduced numeric, so a bare 1.5/1e3 is now scale-faithful numericfloat8 requires an explicit cast).

§

StringLiteral(String)

§

BoolLiteral(bool)

§

NullLiteral

§

Column

SP33: a column reference, optionally table-qualified (a.col). table is None for a bare col.

Fields

§name: String
§

Param(u32)

§

Default

DEFAULT in INSERT/UPDATE value position. The executor replaces this with the target column’s catalog default or NULL.

§

Unary

Fields

§expr: Box<Expr>
§

Binary

Fields

§left: Box<Expr>
§right: Box<Expr>
§

Func(FuncCall)

SP27: a function call, e.g. count(*), sum(a + 1), count(DISTINCT x). Whether a name is an aggregate (vs. an unknown/undefined function) is decided by the executor, not the parser.

§

IsNull

SP28: expr IS [NOT] NULL. Never evaluates to NULL itself.

Fields

§expr: Box<Expr>
§negated: bool
§

InList

SP28: expr [NOT] IN (e1, e2, …) — value-list membership (not a subquery).

Fields

§expr: Box<Expr>
§list: Vec<Expr>
§negated: bool
§

Between

SP28: expr [NOT] BETWEEN low AND high (bounds inclusive).

Fields

§expr: Box<Expr>
§low: Box<Expr>
§high: Box<Expr>
§negated: bool
§

Like

SP28: expr [NOT] LIKE pat / [NOT] ILIKE pat. %/_ wildcards with a \ escape; case_insensitive is the ILIKE form.

Fields

§expr: Box<Expr>
§pattern: Box<Expr>
§negated: bool
§case_insensitive: bool
§

Case

SP28: a CASE expression. operand is Some for the simple form (CASE x WHEN v THEN r …) and None for the searched form (CASE WHEN cond THEN r …). whens is non-empty (parser-enforced).

Fields

§operand: Option<Box<Expr>>
§whens: Vec<(Expr, Expr)>
§else_result: Option<Box<Expr>>
§

Cast

SP31: an explicit cast — CAST(expr AS ty) or expr::ty. The target type is resolved to a ColumnType by the parser (an unknown type name is a parse error); the executor performs the value conversion.

Fields

§expr: Box<Expr>
§

ScalarSubquery(Box<QueryExpr>)

SP34: a scalar subquery (SELECT …) — one row, one column, usable as an expression. Resolved (uncorrelated) to Const by the executor pre-pass.

§

Exists(Box<QueryExpr>)

SP34: EXISTS (SELECT …) — true iff the subquery returns ≥1 row. NOT EXISTS is the prefix NOT wrapping this.

§

InSubquery

SP34: expr [NOT] IN (SELECT …) — subquery membership (single-column subquery).

Fields

§expr: Box<Expr>
§subquery: Box<QueryExpr>
§negated: bool
§

Quantified

SP34: expr op ANY|SOME|ALL (SELECT …). all is the ALL form; ANY/SOME are all == false. The subquery is single-column.

Fields

§expr: Box<Expr>
§all: bool
§subquery: Box<QueryExpr>
§

Const

SP34: an executor-produced literal — a resolved subquery folded to a value carrying its static type. The parser NEVER emits this; ty matters because a zero-row scalar subquery is a typed NULL.

Fields

§value: Datum

Trait Implementations§

Source§

impl Clone for Expr

Source§

fn clone(&self) -> Expr

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 Expr

Source§

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

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

impl PartialEq for Expr

Source§

fn eq(&self, other: &Expr) -> 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 Expr

Auto Trait Implementations§

§

impl Freeze for Expr

§

impl RefUnwindSafe for Expr

§

impl Send for Expr

§

impl Sync for Expr

§

impl Unpin for Expr

§

impl UnsafeUnpin for Expr

§

impl UnwindSafe for Expr

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.