pub struct CreateFunction<'a> {
    pub create_span: Span,
    pub create_options: Vec<CreateOption<'a>>,
    pub function_span: Span,
    pub if_not_exists: Option<Span>,
    pub name: Identifier<'a>,
    pub params: Vec<(Option<FunctionParamDirection>, Identifier<'a>, DataType<'a>)>,
    pub returns_span: Span,
    pub return_type: DataType<'a>,
    pub characteristics: Vec<FunctionCharacteristic<'a>>,
    pub return_: Option<Box<Statement<'a>>>,
}
Expand description

Representation of Create Function Statement

This is not fully implemented yet

let sql = "DELIMITER $$
CREATE FUNCTION add_func3(IN a INT, IN b INT, OUT c INT) RETURNS INT
BEGIN
    SET c = 100;
    RETURN a + b;
END;
$$
DELIMITER ;";
let mut stmts = parse_statements(sql, &mut issues, &options);

assert!(issues.is_empty());
let create: CreateFunction = match stmts.pop() {
    Some(Statement::CreateFunction(c)) => c,
    _ => panic!("We should get an create function statement")
};

assert!(create.name.as_str() == "add_func3");
println!("{:#?}", create.return_)

Fields§

§create_span: Span

Span of “CREATE”

§create_options: Vec<CreateOption<'a>>

Options after “CREATE”

§function_span: Span

Span of “FUNCTION”

§if_not_exists: Option<Span>

Span of “IF NOT EXISTS” if specified

§name: Identifier<'a>

Name o created function

§params: Vec<(Option<FunctionParamDirection>, Identifier<'a>, DataType<'a>)>

Names and types of function arguments

§returns_span: Span

Span of “RETURNS”

§return_type: DataType<'a>

Type of return value

§characteristics: Vec<FunctionCharacteristic<'a>>

Characteristics of created function

§return_: Option<Box<Statement<'a>>>

Statement computing return value

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Compute byte span of an ast fragment
Compute the minimal span containing both self and other

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.