1305
MariaDBERRORNotableStored RoutinesHIGH confidence

FUNCTION 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
  1. 1Calling a function that was never created
  2. 2Calling a function in the wrong database — it exists in another schema
  3. 3Case-sensitive naming mismatch on case-sensitive file systems
  4. 4The routine was dropped and not recreated after a schema migration
  5. 5Misspelled function name
How to reproduce

Calling a stored function that does not exist.

trigger — this will error
trigger — this will error
SELECT calculate_tax(total) FROM invoices;
-- Function calculate_tax does not exist in current db

expected output

ERROR 1305 (42000): FUNCTION mydb.calculate_tax does not exist

Fix 1

Verify the function exists and which database it is in

WHEN Before any other action — confirm the routine name and schema.

Verify the function exists and which database it is in
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 When the function exists in a different database.

Qualify the function name with the correct schema
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 When the function was dropped or never created.

Create or recreate the missing function
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.

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All MariaDB errors