The label-redefine error appears when a stored program declares the same label twice in the same scope.
MySQL Error 1309 ER_SP_LABEL_REDEFINE arises when a stored procedure or trigger declares the same label more than once within the same scope. Rename or remove the duplicate label, then re-run the routine to resolve the issue.
Redefining label %s
Error 1309 is raised when MySQL encounters two identical labels in the same lexical scope of a stored procedure, function, trigger, or event. MySQL’s parser flags this as a syntax violation and aborts compilation.
The condition name ER_SP_LABEL_REDEFINE literally means "Stored Program Label Redefine." It protects control-flow integrity so that a LEAVE or ITERATE statement always resolves to a unique target.
Duplicate labels inside a BEGIN…END block trigger the error immediately during CREATE or ALTER PROCEDURE execution. The conflict can be direct or through nested compound statements sharing the same label string.
Copy-pasted code, auto-generated templates, or refactors that forget to update label names are common triggers. MySQL 5.6-8.3 all enforce the rule.
Search the affected routine for repeated label identifiers. Rename one occurrence or remove the redundant block. Re-deploy the object after verifying with SHOW WARNINGS.
When labels are required in nested loops, add clear prefixes, for example outer_loop and inner_loop, to keep names unique.
A FOR loop copied twice with the same loop_label will break compilation. Change the second to loop_label2.
Nested cursors that each use fetch_loop cause the same failure. Prefix the inner cursor label to fetch_loop_inner.
Adopt a naming convention such as block__. Use code review or static analysis tools to catch duplicates before deployment.
Galaxy’s SQL editor highlights duplicate labels in real time, preventing the issue before you run DELIMITER commands.
Error 1334 ER_SP_UNDECLARED_VAR appears when a variable is referenced before declaration. Ensure DECLARE lines precede usage.
Error 1335 ER_SP_DUP_PARAM flags duplicate parameter names. Rename overlapping parameters similarly to how you resolve label redefinitions.
No. They only need to be unique within the compound statement scope of the stored program.
MySQL does not offer a flag to bypass label validation. Unique names are mandatory.
Labels are case sensitive on all platforms, so foo and FOO are treated as different.
Galaxy’s real-time linter flags duplicate labels while you type, letting you rename them before executing the CREATE PROCEDURE statement.