pub fn parse_function_body(body: &str) -> Result<PlPgSqlBlock, ParseError>Expand description
v7.12.4 — parse a PL/pgSQL function body (the bytes between
$$ ... $$). Returns the parsed BEGIN ... END; block.
v7.12.4 grammar (strict subset — IF / LOOP / DECLARE / RAISE / embedded SQL land in v7.12.5+):
body := [ws] block [ws]
block := BEGIN stmt ( ; stmt )* [ ; ] END [ ; ]
stmt := assign | return
assign := assign_target := expr
assign_target := ( NEW | OLD ) . ident | ident
return := RETURN ( NEW | OLD | NULL | expr )expr is parsed by recursing into the regular Parser — so a
PL/pgSQL NEW.search_vector := to_tsvector('english', NEW.subject || ' ' || NEW.sender) body shape works without
the body parser knowing what to_tsvector is.
Errors here cause the caller to fall back to
FunctionBody::Raw — keeping the CREATE FUNCTION DDL itself
successful, but the executor will refuse to invoke the
function with an “unparseable body” error.
v7.12.4 — public alias for [parse_plpgsql_body] re-exported
from the crate root as spg_sql::parse_function_body.