1312
MariaDBerrorstored-procedureshigh confidence
No RETURN found in FUNCTION
Production Risk
Low — compile-time error; function not created.
What this means
A stored function body contains no RETURN statement, which is mandatory.
Why it happens
- 1Writing a function body without a RETURN statement
- 2RETURN placed inside a branch that may not be reached
How to reproduce
trigger — this will error
trigger — this will error
CREATE FUNCTION f() RETURNS INT DETERMINISTIC BEGIN DECLARE v INT DEFAULT 1; END;
expected output
ERROR 1312 (42000): No RETURN found in FUNCTION f
Fix
Add a RETURN statement
Add a RETURN statement
CREATE FUNCTION f() RETURNS INT DETERMINISTIC BEGIN RETURN 1; END;
Why this works
Every function must have at least one reachable RETURN.
Sources
Official documentation ↗
MySQL 8.0 — 1312 ER_SP_NORETURN
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev