Error
Error Code:
1305
MariaDB Error 1305: Stored Program Not Found
Description
Error 1305 indicates that the MariaDB server could not find a specified stored program (like a procedure, function, trigger, or event) or view. This typically occurs when an SQL statement attempts to reference an object that either never existed, has been dropped, or is incorrectly named or located within the database.
Error Message
%s %s does not exist
Known Causes
3 known causesIncorrect Object Name
The stored program or view name specified in the SQL statement contains a typo, incorrect casing, or does not match the actual name of the object in the database.
Object Was Dropped
The stored program or view previously existed but has since been deleted from the database, and the referencing statement was not updated to reflect this change.
Wrong Database Context
The SQL statement is being executed in a different database or schema than where the stored program or view actually resides, and a fully qualified name was not used.
Solutions
4 solutions available1. Verify Stored Program Name and Schema easy
Double-check the spelling and the schema where the stored program is expected to exist.
1
Ensure the stored program name (e.g., procedure, function, trigger) is spelled correctly in your SQL statement. Case sensitivity might be a factor depending on your MariaDB server's configuration (e.g., `lower_case_table_names`).
2
Confirm that the stored program exists in the currently selected database (schema). If it's in a different schema, you need to qualify the name with the schema name.
CALL your_schema.your_stored_procedure('argument');
SELECT your_schema.your_stored_function('argument');
3
List all stored programs in the current database to verify its existence and exact name.
SHOW PROCEDURE STATUS WHERE Db = DATABASE();
SHOW FUNCTION STATUS WHERE Db = DATABASE();
4
If the stored program is in a different database, list them from that specific database.
SHOW PROCEDURE STATUS WHERE Db = 'your_other_schema';
SHOW FUNCTION STATUS WHERE Db = 'your_other_schema';
2. Check for Missing or Incorrect Creation Statement medium
The stored program might not have been created, or the creation statement was incomplete or erroneous.
1
Review the SQL script or application code that is responsible for creating the stored program. Ensure the `CREATE PROCEDURE` or `CREATE FUNCTION` statement was executed successfully without errors.
2
Examine the `CREATE` statement for any syntax errors, missing delimiters, or incorrect parameter definitions.
DELIMITER //
CREATE PROCEDURE my_procedure(IN param1 INT)
BEGIN
-- stored procedure body
END //
DELIMITER ;
DELIMITER //
CREATE FUNCTION my_function(param1 INT) RETURNS INT
BEGIN
-- stored function body
RETURN param1;
END //
DELIMITER ;
3
If the stored program was recently created, try re-running the `CREATE` statement. Pay close attention to any error messages returned during the creation process.
3. Confirm User Permissions medium
The user executing the stored program may lack the necessary privileges.
1
Verify that the user account you are using has the `EXECUTE` privilege on the stored program.
SHOW GRANTS FOR 'your_user'@'your_host';
2
If the user lacks the privilege, grant it.
GRANT EXECUTE ON PROCEDURE your_schema.your_stored_procedure TO 'your_user'@'your_host';
GRANT EXECUTE ON FUNCTION your_schema.your_stored_function TO 'your_user'@'your_host';
3
Ensure the user has `SELECT` or `USAGE` privilege on the database (schema) where the stored program resides, as this is often a prerequisite for executing stored programs within that schema.
GRANT USAGE ON your_schema.* TO 'your_user'@'your_host';
-- or
GRANT SELECT ON your_schema.* TO 'your_user'@'your_host';
4. Restart MariaDB Service (If Program is Dynamic) easy
In rare cases, especially with dynamic SQL or system-level changes, a service restart can resolve transient issues.
1
This is a more drastic step and should be considered if other solutions fail. Ensure you have a proper backup and understand the implications of restarting the database service.
2
Restart the MariaDB service using your system's service manager.
# On systems using systemd
sudo systemctl restart mariadb
# On systems using SysVinit
sudo service mariadb restart