pub enum Declaration<X: Extension = NoExt> {
Variable {
names: ThinVec<Ident>,
data_type: DataType<X>,
default: Option<Expr<X>>,
meta: Meta,
},
Condition {
name: Ident,
value: ConditionValue,
meta: Meta,
},
Cursor {
name: Ident,
query: Box<Query<X>>,
meta: Meta,
},
Handler {
action: HandlerAction,
conditions: ThinVec<HandlerCondition>,
body: Box<Statement<X>>,
meta: Meta,
},
}Expand description
One DECLARE … item in a CompoundStatement prefix.
The four forms are parsed uniformly into this prefix; their ordering is enforced
post-hoc by the parser’s declaration 4-counter ({Variable,
Condition} → Cursor →
Handler), mirroring the server’s own mechanism rather than
encoding the order as grammar productions.
Variants§
Variable
DECLARE <name> [, <name> …] <type> [DEFAULT <expr>] — one or more local
variables sharing a type and optional default.
Fields
Condition
DECLARE <name> CONDITION FOR <condition-value> — a named condition alias.
Fields
value: ConditionValueThe SQLSTATE '…' or MySQL error-code value the name aliases.
Cursor
DECLARE <name> CURSOR FOR <select> — a cursor over a query.
Fields
Handler
DECLARE {CONTINUE | EXIT | UNDO} HANDLER FOR <condition> [, …] <statement> — a
condition handler whose body runs when any listed condition is raised.
Fields
action: HandlerActionThe handler action (CONTINUE/EXIT/UNDO).
conditions: ThinVec<HandlerCondition>The condition values the handler catches, in source order (at least one).
Trait Implementations§
Source§impl<X: Clone + Extension> Clone for Declaration<X>
impl<X: Clone + Extension> Clone for Declaration<X>
Source§fn clone(&self) -> Declaration<X>
fn clone(&self) -> Declaration<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 Declaration<X>where
X: Deserialize<'de> + Extension,
impl<'de, X> Deserialize<'de> for Declaration<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 Declaration<X>
Source§impl<X: Extension + Render> Render for Declaration<X>
impl<X: Extension + Render> Render for Declaration<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 Declaration<X>
impl<X> Serialize for Declaration<X>
Source§impl<X: Extension> Spanned for Declaration<X>
impl<X: Extension> Spanned for Declaration<X>
impl<X: PartialEq + Extension> StructuralPartialEq for Declaration<X>
Auto Trait Implementations§
impl<X> Freeze for Declaration<X>where
X: Freeze,
impl<X> RefUnwindSafe for Declaration<X>where
X: RefUnwindSafe,
impl<X> Send for Declaration<X>where
X: Send,
impl<X> Sync for Declaration<X>where
X: Sync,
impl<X> Unpin for Declaration<X>where
X: Unpin,
impl<X> UnsafeUnpin for Declaration<X>where
X: UnsafeUnpin,
impl<X> UnwindSafe for Declaration<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.