RESIGNAL is used inside a DECLARE ... HANDLER block (or equivalent condition-handling construct) to propagate the caught error upward or to raise a new error with a different SQLSTATE, message, or error number. When used without arguments, RESIGNAL passes the original error unchanged to the next outer handler or to the client. When supplied with a condition value and/or a SET clause, it allows the developer to modify the SQLSTATE code, message text, MySQL error number, or other diagnostic items before the exception continues to propagate. This is extremely useful for layering stored procedures, where inner routines want to surface cleaner or more domain-specific error messages while preserving the original failure context. RESIGNAL must be executed inside a handler; calling it outside a handler results in an error. Unlike SIGNAL, RESIGNAL never terminates the code immediately where it appears; instead, control returns to the runtime error-handling chain.
condition_value
(string or int) - Optional. A SQLSTATE value (e.g., '45000'), a named condition, or a MySQL error number that replaces the original.signal_information_item_list
(list) - Optional key-value pairs such as- SQLSTATE
- = 'state'SIGNAL, DECLARE HANDLER, EXCEPTION HANDLING, SQLSTATE, RAISE (PL/pgSQL)
MySQL 5.5 (after SQL:2003 standard)
SIGNAL raises a new error from regular code. RESIGNAL rethrows the current error from inside an active handler, optionally altering its details.
Yes. Provide SQLSTATE 'value' in the RESIGNAL statement or in the SET clause to override the original SQLSTATE before the error propagates.
Execution leaves the handler, then the error propagates to the next outer handler or client. It does not continue normal code after the handler.
MariaDB 10.3 and newer and IBM DB2 support RESIGNAL with similar syntax, making it portable across these systems.