pub struct CreateMacro<X: Extension = NoExt> {
pub or_replace: bool,
pub temporary: Option<TemporaryTableKind>,
pub spelling: MacroSpelling,
pub if_not_exists: bool,
pub name: ObjectName,
pub params: ThinVec<MacroParam<X>>,
pub body: MacroBody<X>,
pub meta: Meta,
}Expand description
CREATE [OR REPLACE] [TEMP|TEMPORARY] {MACRO | FUNCTION} [IF NOT EXISTS] <name> (<param> [, ...]) AS <body> — DuckDB’s macro DDL (gated by
StatementDdlGates::create_macro).
This is a distinct node from CreateFunction, not a variant of it: a DuckDB
macro body is a live SQL expression or query (AS x + 1 / AS TABLE SELECT …),
whereas a PostgreSQL/MySQL CREATE FUNCTION body is an opaque source string in a
target language (AS 'RETURN 1'). The two share only the CREATE … (params) AS
prefix; their bodies, parameter grammars (a macro parameter is a bare untyped name,
a routine parameter is [name] <type>), and option tails are disjoint.
DuckDB spells the same feature with either the MACRO keyword or FUNCTION as an
exact synonym; spelling records which so the source keyword
round-trips (the tag pattern of TemporaryTableKind, not a semantic difference).
Whole-statement gated to DuckDB (and Lenient): every other dialect either has no
macro grammar (MACRO is left unconsumed and surfaces as an unknown statement) or
spells CREATE FUNCTION as the incompatible string-body routine, so the gate is
behaviour-accurate, not merely a modelling limitation. Boxed by the enclosing
Statement::CreateMacro to keep the enum within its size budget.
The single-body surface — one (params) AS body per statement — is modelled; DuckDB
additionally accepts a comma-separated overload list (… AS a, (x, y) AS b), a
deliberate follow-up (no vendored corpus statement spells it) the shape would extend
by lifting params/body into an overload sequence.
Fields§
§or_replace: boolWhether the or replace form was present in the source.
temporary: Option<TemporaryTableKind>Optional temporary for this syntax.
spelling: MacroSpellingExact source spelling retained for faithful rendering.
if_not_exists: boolWhether the if not exists form was present in the source.
name: ObjectNameName referenced by this syntax.
params: ThinVec<MacroParam<X>>params in source order.
body: MacroBody<X>Statement or query body governed by this node.
meta: MetaSource location and node identity.
Trait Implementations§
Source§impl<X: Clone + Extension> Clone for CreateMacro<X>
impl<X: Clone + Extension> Clone for CreateMacro<X>
Source§fn clone(&self) -> CreateMacro<X>
fn clone(&self) -> CreateMacro<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 CreateMacro<X>where
X: Deserialize<'de> + Extension,
impl<'de, X> Deserialize<'de> for CreateMacro<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 CreateMacro<X>
Source§impl<X: Extension + Render> Render for CreateMacro<X>
impl<X: Extension + Render> Render for CreateMacro<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 CreateMacro<X>
impl<X> Serialize for CreateMacro<X>
Source§impl<X: Extension> Spanned for CreateMacro<X>
impl<X: Extension> Spanned for CreateMacro<X>
impl<X: PartialEq + Extension> StructuralPartialEq for CreateMacro<X>
Auto Trait Implementations§
impl<X> Freeze for CreateMacro<X>
impl<X> RefUnwindSafe for CreateMacro<X>where
X: RefUnwindSafe,
impl<X> Send for CreateMacro<X>where
X: Send,
impl<X> Sync for CreateMacro<X>where
X: Sync,
impl<X> Unpin for CreateMacro<X>where
X: Unpin,
impl<X> UnsafeUnpin for CreateMacro<X>
impl<X> UnwindSafe for CreateMacro<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.