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 numeric — float8 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.
Param(u32)
Default
DEFAULT in INSERT/UPDATE value position. The executor replaces this with
the target column’s catalog default or NULL.
Unary
Binary
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.
InList
SP28: expr [NOT] IN (e1, e2, …) — value-list membership (not a subquery).
Between
SP28: expr [NOT] BETWEEN low AND high (bounds inclusive).
Like
SP28: expr [NOT] LIKE pat / [NOT] ILIKE pat. %/_ wildcards with a
\ escape; case_insensitive is the ILIKE form.
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).
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.
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).
Quantified
SP34: expr op ANY|SOME|ALL (SELECT …). all is the ALL form; ANY/SOME
are all == false. The subquery is single-column.
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.