pub enum FunctionBody<X: Extension = NoExt> {
Definition {
definition: Literal,
meta: Meta,
},
Return {
expr: Box<Expr<X>>,
meta: Meta,
},
Block {
body: Box<Statement<X>>,
meta: Meta,
},
}Expand description
The executable body of a CreateFunction routine — the body-representation axis.
Two body kinds are modelled today. Definition is an opaque source
string introduced by the order-independent AS option (AS 'SELECT 1', AS $$ … $$,
AS $body$ … $body$). Return is the SQL-standard live body
RETURN <expr> (PostgreSQL 14+ / standard opt_routine_body), a real SQL Expr that
rides the trailing CreateFunction::body slot — a distinct parse position from AS
(the RETURN body strictly follows the whole option list, oracle-proven). This is a
distinct enum — not a bare Literal field on FunctionOption::As — precisely so the
live body reuses one body vocabulary across both slots rather than reshaping the option.
The axis is body kind (opaque string vs. live SQL), not quote style: a plain '…'
and a dollar-quoted $tag$…$tag$ body are both
LiteralKind::String and differ only in source spelling. That
spelling — the delimiter tag and the verbatim body text — round-trips from the
Literal’s span; it is recovered from source, never normalized, so a dollar body
re-renders byte-for-byte.
The enum is generic over X because Return carries an Expr<X>; the
Definition string variant is generic-free. A statement-list
BEGIN ATOMIC … END body (PostgreSQL, oracle-accepted) shares the trailing slot and slots
in here as a further variant carrying a routine-body statement list — deliberately deferred:
modelling it honestly needs a routine-body statement grammar (its inner RETURN is not a
top-level Statement), which is a separate surface from this single-Expr body.
Variants§
Definition
AS <string> — an opaque routine body in the target language, kept as the source
Literal (plain-quoted or dollar-quoted) rather than re-parsed, because the body’s
grammar is the target language, not SQL.
Fields
Return
RETURN <expr> — the SQL-standard live expression body (opt_routine_body’s
ReturnStmt). The Expr is boxed (the MacroBody precedent) so the common AS
string body pays no Expr footprint on the shared FunctionOption::As path.
Fields
Block
A MySQL SQL/PSM routine body — one routine_body statement, usually the
BEGIN … END compound block (Statement::Compound)
but any single body statement (a bare SET, a flow-control construct, a RETURN).
This is the live statement-list body the FunctionBody axis doc anticipated; it
rides the trailing CreateFunction::body slot exactly as Return
does — a distinct grammatical position after the whole characteristic list. Boxed
(Statement is large) so the common AS-string path pays no footprint.
Trait Implementations§
Source§impl<X: Clone + Extension> Clone for FunctionBody<X>
impl<X: Clone + Extension> Clone for FunctionBody<X>
Source§fn clone(&self) -> FunctionBody<X>
fn clone(&self) -> FunctionBody<X>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<'de, X> Deserialize<'de> for FunctionBody<X>where
X: Deserialize<'de> + Extension,
impl<'de, X> Deserialize<'de> for FunctionBody<X>where
X: Deserialize<'de> + Extension,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl<X: Eq + Extension> Eq for FunctionBody<X>
Source§impl<X: Extension + Render> Render for FunctionBody<X>
impl<X: Extension + Render> Render for FunctionBody<X>
Source§fn render(&self, ctx: &RenderCtx<'_>, f: &mut Formatter<'_>) -> Result
fn render(&self, ctx: &RenderCtx<'_>, f: &mut Formatter<'_>) -> Result
Source§fn operand_binding_power(&self) -> Option<BindingPower>
fn operand_binding_power(&self) -> Option<BindingPower>
None (the default) for a self-delimiting node — an atom, call, or
constructor — that never needs parentheses. Read moreSource§impl<X> Serialize for FunctionBody<X>
impl<X> Serialize for FunctionBody<X>
Source§impl<X: Extension> Spanned for FunctionBody<X>
impl<X: Extension> Spanned for FunctionBody<X>
impl<X: PartialEq + Extension> StructuralPartialEq for FunctionBody<X>
Auto Trait Implementations§
impl<X> Freeze for FunctionBody<X>
impl<X> RefUnwindSafe for FunctionBody<X>where
X: RefUnwindSafe,
impl<X> Send for FunctionBody<X>where
X: Send,
impl<X> Sync for FunctionBody<X>where
X: Sync,
impl<X> Unpin for FunctionBody<X>
impl<X> UnsafeUnpin for FunctionBody<X>
impl<X> UnwindSafe for FunctionBody<X>where
X: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> DynAstExt for T
impl<T> DynAstExt for T
Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&dyn Any for downcasting a node back to its concrete type.Source§fn dyn_clone(&self) -> Box<dyn DynAstExt>
fn dyn_clone(&self) -> Box<dyn DynAstExt>
Clone (whose
Self-returning signature cannot go through a vtable).Source§fn dyn_eq(&self, other: &dyn DynAstExt) -> bool
fn dyn_eq(&self, other: &dyn DynAstExt) -> bool
PartialEq (whose &Self argument cannot go through a vtable). Equal
iff other holds the same concrete type and that type deems the values
equal; differently-typed nodes are never equal.