1305ERRORTier 2 — Caution✅ HIGH confidenceFUNCTION or PROCEDURE does not exist
What this means
Error 1305 (SQLSTATE 42000) is raised when a call to a stored function, stored procedure, or user-defined function references a name that does not exist in the current database or in the specified schema.
Why it happens
- 1Calling a function that was never created
- 2Calling a function in the wrong database — it exists in another schema
- 3Case-sensitive naming mismatch on case-sensitive file systems
- 4The routine was dropped and not recreated after a schema migration
- 5Misspelled function name
How to reproduce
Calling a stored function that does not exist.
SELECT calculate_tax(total) FROM invoices;
-- Function calculate_tax does not exist in current dbFix 1: Verify the function exists and which database it is in
Before any other action — confirm the routine name and schema.
SELECT ROUTINE_SCHEMA, ROUTINE_NAME, ROUTINE_TYPE
FROM information_schema.ROUTINES
WHERE ROUTINE_NAME LIKE '%calculate%';Why this works
information_schema.ROUTINES lists all stored procedures and functions visible to the current user across all databases.
Fix 2: Qualify the function name with the correct schema
When the function exists in a different database.
SELECT utils.calculate_tax(total) FROM invoices;Why this works
Qualifying with the schema name (utils.calculate_tax) resolves cross-database routine calls without changing the session database.
Fix 3: Create or recreate the missing function
When the function was dropped or never created.
CREATE FUNCTION calculate_tax(amount DECIMAL(10,2))
RETURNS DECIMAL(10,2) DETERMINISTIC
BEGIN
RETURN amount * 0.23;
END;Why this works
Recreating the function restores it. If using migrations, ensure the routine creation is part of the deployment script.
Sources
📚 Official docs: https://mariadb.com/kb/en/stored-function-overview/
🔧 Source ref: MariaDB Server error code 1305 / ER_SP_DOES_NOT_EXIST
📖 Further reading: MariaDB Stored Functions
📖 Further reading: MariaDB information_schema ROUTINES
Confidence assessment
✅ HIGH confidence
Stable.
See also
🔗 Related errors
📄 Reference pages