Syntax:
SIGNAL condition_value
    [SET signal_information_item
    [, signal_information_item] ...]

condition_value: {
    SQLSTATE [VALUE] sqlstate_value
  | condition_name
}

signal_information_item:
    condition_information_item_name = simple_value_specification

condition_information_item_name: {
    CLASS_ORIGIN
  | SUBCLASS_ORIGIN
  | MESSAGE_TEXT
  | MYSQL_ERRNO
  | CONSTRAINT_CATALOG
  | CONSTRAINT_SCHEMA
  | CONSTRAINT_NAME
  | CATALOG_NAME
  | SCHEMA_NAME
  | TABLE_NAME
  | COLUMN_NAME
  | CURSOR_NAME
}

condition_name, simple_value_specification:
    (see following discussion)

SIGNAL is the way to "return" an error. SIGNAL provides error
information to a handler, to an outer portion of the application, or to
the client. Also, it provides control over the error's characteristics
(error number, SQLSTATE value, message). Without SIGNAL, it is
necessary to resort to workarounds such as deliberately referring to a
nonexistent table to cause a routine to return an error.

No privileges are required to execute the SIGNAL statement.

To retrieve information from the diagnostics area, use the GET
DIAGNOSTICS statement (see [HELP GET DIAGNOSTICS]). For information
about the diagnostics area, see
https://dev.mysql.com/doc/refman/5.7/en/diagnostics-area.html.

URL: https://dev.mysql.com/doc/refman/5.7/en/signal.html

