Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-29 · container image mysql:8.4
ERROR 1305 shows where MySQL looked: FUNCTION lab_a.addtax does not exist means it searched the database lab_a for a function named addtax. Check both parts: the name may be misspelled, or the routine may live in a different database than the current one.
Stored functions and procedures belong to a database. A call without a database prefix uses the current database (SELECT DATABASE()).
01Misspelled function name
The function was created as add_tax, but SELECT addtax(1000) failed with ERROR 1305 (42000): FUNCTION lab_a.addtax does not exist.
information_schema.ROUTINES for the current database listed add_tax as a FUNCTION. Calling the correct name add_tax(1000) returned 1100.
Setup
CREATE FUNCTION lab_a.add_tax(p INT) RETURNS INT DETERMINISTIC
RETURN ROUND(p * 1.1);Query OK, 0 rows affected (0.01 sec)SELECT addtax(1000) AS price;ERROR 1305 (42000): FUNCTION lab_a.addtax does not existSELECT ROUTINE_NAME, ROUTINE_TYPE FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = DATABASE();+--------------+--------------+
| ROUTINE_NAME | ROUTINE_TYPE |
+--------------+--------------+
| add_tax | FUNCTION |
+--------------+--------------+
1 row in set (0.00 sec)SELECT add_tax(1000) AS price;+-------+
| price |
+-------+
| 1100 |
+-------+
1 row in set (0.00 sec)02CALL of a procedure that lives in another database
close_day() was created in the shop database and lab_a had EXECUTE on it. lab_a ran CALL close_day() and got PROCEDURE lab_a.close_day does not exist: SELECT DATABASE() showed the current database was lab_a, not shop.
CALL shop.close_day() with the database prefix returned closed.
Setup
CREATE DATABASE shop;
CREATE PROCEDURE shop.close_day() SELECT 'closed' AS result;
GRANT EXECUTE ON shop.* TO lab_a;Query OK, 1 row affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)CALL close_day();ERROR 1305 (42000): PROCEDURE lab_a.close_day does not existSELECT DATABASE();+------------+
| DATABASE() |
+------------+
| lab_a |
+------------+
1 row in set (0.00 sec)CALL shop.close_day();+--------+
| result |
+--------+
| closed |
+--------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)03DROP PROCEDURE of a procedure that is not there
DROP PROCEDURE close_day failed with ERROR 1305, and SHOW PROCEDURE STATUS WHERE Db = 'lab_a' returned an empty set. This stops deployment scripts that drop before re-creating.
DROP PROCEDURE IF EXISTS close_day succeeded with 1 warning. SHOW WARNINGS showed it as a Note with code 1305 instead of an error.
DROP PROCEDURE close_day;ERROR 1305 (42000): PROCEDURE lab_a.close_day does not existSHOW PROCEDURE STATUS WHERE Db = 'lab_a';Empty set (0.00 sec)DROP PROCEDURE IF EXISTS close_day;
SHOW WARNINGS;Query OK, 0 rows affected, 1 warning (0.00 sec)
+-------+------+------------------------------------------+
| Level | Code | Message |
+-------+------+------------------------------------------+
| Note | 1305 | PROCEDURE lab_a.close_day does not exist |
+-------+------+------------------------------------------+
1 row in set (0.00 sec)FAQ
The function exists but MySQL says FUNCTION does not exist. Why?
Check the database in the message. If it is not the database where the function was created, call it with a prefix like shop.close_day(), as above.
How do I list stored functions and procedures in MySQL?
Query information_schema.ROUTINES with ROUTINE_SCHEMA = DATABASE(), or use SHOW PROCEDURE STATUS WHERE Db = '...'. Both were used above.
How do I avoid ERROR 1305 in a deploy script?
Use DROP PROCEDURE IF EXISTS. Above it turned the error into a Note with code 1305 and the script could continue.
How we verify
Each scenario starts from fresh database users. A script runs the setup, confirms the exact error code, applies the fix and runs the statement again. The output shown is what the database printed, saved by the script.
lab_a and lab_b are ordinary users created for the test, each with full rights on a database of the same name (its default database); root is the administrator. MySQL 8.4.13