MySQL 8.4Lab-verified · 2026-11-30

MySQL ERROR 1644 (45000): SIGNAL from a trigger or procedure

A trigger or stored procedure ran SIGNAL SQLSTATE '45000' and nobody handled it.

MySQL 8.4.13
1644 (45000): amount must be greater than 0

Jump to a cause

  1. 01Validation trigger rejected the row
  2. 02Procedure SIGNAL not handled by the caller
  3. 03SIGNAL without MESSAGE_TEXT (Unhandled user-defined exception condition)

Lab-verifiedReproduced and fixed on MySQL 8.4.13 · 2026-11-30 · container image mysql:8.4

ERROR 1644 with SQLSTATE 45000 is not a MySQL internal error. It is raised on purpose by SIGNAL SQLSTATE '45000' in a trigger or stored procedure, and the text after it is the MESSAGE_TEXT that code set (e.g. amount must be greater than 0). If no text was set, you see Unhandled user-defined exception condition.

So the first step is to find which trigger or procedure signaled and why. Below are three cases reproduced on MySQL 8.4 with the fixes that were actually run.

01Validation trigger rejected the row

INSERT INTO orders VALUES (1, 0) failed with ERROR 1644 (45000): amount must be greater than 0. The table has a trigger: information_schema.TRIGGERS showed orders_bi, INSERT, BEFORE.

The trigger works as designed, so the data must change. Inserting amount 15000 succeeded.

Setup
Setuprun as root
CREATE DATABASE shop;
USE shop;
CREATE TABLE orders (id INT PRIMARY KEY, amount DECIMAL(10,2));
DELIMITER //
CREATE TRIGGER orders_bi BEFORE INSERT ON orders FOR EACH ROW
BEGIN
  IF NEW.amount <= 0 THEN
    SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'amount must be greater than 0';
  END IF;
END//
DELIMITER ;
OUTPUT
Query OK, 1 row affected (0.01 sec)

Query OK, 0 rows affected (0.02 sec)

Query OK, 0 rows affected (0.00 sec)
Reproducerun as root
USE shop;
INSERT INTO orders VALUES (1, 0);
✕ ERROR
ERROR 1644 (45000): amount must be greater than 0
Checkrun as root
USE shop;
SELECT TRIGGER_NAME, EVENT_MANIPULATION, ACTION_TIMING FROM information_schema.TRIGGERS WHERE EVENT_OBJECT_SCHEMA = 'shop' AND EVENT_OBJECT_TABLE = 'orders';
OUTPUT
+--------------+--------------------+---------------+
| TRIGGER_NAME | EVENT_MANIPULATION | ACTION_TIMING |
+--------------+--------------------+---------------+
| orders_bi    | INSERT             | BEFORE        |
+--------------+--------------------+---------------+
1 row in set (0.00 sec)

If the rule itself is wrong, change the trigger, not the data. Check its body with SHOW CREATE TRIGGER.

After the fixrun as root
USE shop;
INSERT INTO orders VALUES (1, 15000);
SELECT * FROM orders;
✓ SUCCESS
Query OK, 1 row affected (0.01 sec)

+----+----------+
| id | amount   |
+----+----------+
|  1 | 15000.00 |
+----+----------+
1 row in set (0.00 sec)

02Procedure SIGNAL not handled by the caller

take_stock signals not enough stock when qty is too small. CALL take_stock('pen', 5) with 3 in stock failed with ERROR 1644.

A caller procedure with DECLARE EXIT HANDLER FOR SQLSTATE '45000' and GET DIAGNOSTICS CONDITION 1 p_result = MESSAGE_TEXT turned it into a result: ordering 5 returned not enough stock, ordering 2 returned OK and left qty 1.

Setup
Setuprun as root
CREATE DATABASE shop;
USE shop;
CREATE TABLE stock (item VARCHAR(10) PRIMARY KEY, qty INT);
INSERT INTO stock VALUES ('pen', 3);
DELIMITER //
CREATE PROCEDURE take_stock(IN p_item VARCHAR(10), IN p_qty INT)
BEGIN
  IF (SELECT qty FROM stock WHERE item = p_item) < p_qty THEN
    SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'not enough stock';
  END IF;
  UPDATE stock SET qty = qty - p_qty WHERE item = p_item;
END//
DELIMITER ;
OUTPUT
Query OK, 1 row affected (0.01 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 1 row affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)
Reproducerun as root
USE shop;
CALL take_stock('pen', 5);
✕ ERROR
ERROR 1644 (45000): not enough stock
Fixrun as root
USE shop;
DELIMITER //
CREATE PROCEDURE order_item(IN p_item VARCHAR(10), IN p_qty INT, OUT p_result VARCHAR(100))
BEGIN
  DECLARE EXIT HANDLER FOR SQLSTATE '45000'
  BEGIN
    GET DIAGNOSTICS CONDITION 1 p_result = MESSAGE_TEXT;
  END;
  CALL take_stock(p_item, p_qty);
  SET p_result = 'OK';
END//
DELIMITER ;
OUTPUT
Query OK, 0 rows affected (0.01 sec)
After the fixrun as root
USE shop;
CALL order_item('pen', 5, @r);
SELECT @r AS result;
CALL order_item('pen', 2, @r);
SELECT @r AS result, (SELECT qty FROM stock WHERE item = 'pen') AS qty_left;
✓ SUCCESS
Query OK, 0 rows affected (0.00 sec)

+------------------+
| result           |
+------------------+
| not enough stock |
+------------------+
1 row in set (0.00 sec)

Query OK, 1 row affected (0.00 sec)

+--------+----------+
| result | qty_left |
+--------+----------+
| OK     |        1 |
+--------+----------+
1 row in set (0.00 sec)

03SIGNAL without MESSAGE_TEXT (Unhandled user-defined exception condition)

A BEFORE DELETE trigger runs SIGNAL SQLSTATE '45000'; for paid orders but sets no text. DELETE FROM orders WHERE id = 1 failed with ERROR 1644 (45000): Unhandled user-defined exception condition, which tells the user nothing.

The trigger was recreated with SET MESSAGE_TEXT = 'paid order cannot be deleted' so the next error explains itself. The paid order was then cancelled with UPDATE ... SET status = 'CANCELLED' instead of deleted.

Setup
Setuprun as root
CREATE DATABASE shop;
USE shop;
CREATE TABLE orders (id INT PRIMARY KEY, status VARCHAR(10));
INSERT INTO orders VALUES (1, 'PAID'), (2, 'NEW');
DELIMITER //
CREATE TRIGGER orders_bd BEFORE DELETE ON orders FOR EACH ROW
BEGIN
  IF OLD.status = 'PAID' THEN
    SIGNAL SQLSTATE '45000';
  END IF;
END//
DELIMITER ;
OUTPUT
Query OK, 1 row affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 2 rows affected (0.00 sec)
Records: 2  Duplicates: 0  Warnings: 0

Query OK, 0 rows affected (0.01 sec)
Reproducerun as root
USE shop;
DELETE FROM orders WHERE id = 1;
✕ ERROR
ERROR 1644 (45000): Unhandled user-defined exception condition
Fixrun as root
USE shop;
DROP TRIGGER orders_bd;
DELIMITER //
CREATE TRIGGER orders_bd BEFORE DELETE ON orders FOR EACH ROW
BEGIN
  IF OLD.status = 'PAID' THEN
    SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'paid order cannot be deleted';
  END IF;
END//
DELIMITER ;
OUTPUT
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)
Checkrun as root
USE shop;
SELECT id, status FROM orders;
OUTPUT
+----+--------+
| id | status |
+----+--------+
|  1 | PAID   |
|  2 | NEW    |
+----+--------+
2 rows in set (0.00 sec)
After the fixrun as root
USE shop;
UPDATE orders SET status = 'CANCELLED' WHERE id = 1;
SELECT id, status FROM orders;
✓ SUCCESS
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

+----+-----------+
| id | status    |
+----+-----------+
|  1 | CANCELLED |
|  2 | NEW       |
+----+-----------+
2 rows in set (0.00 sec)

FAQ

What is MySQL error 1644 SQLSTATE 45000?

It is a user-defined error raised by SIGNAL in a trigger or stored procedure. The message is whatever MESSAGE_TEXT the code set.

What does Unhandled user-defined exception condition mean?

A SIGNAL SQLSTATE '45000' ran without MESSAGE_TEXT. Add a message to the SIGNAL so the cause is visible, as in the third case.

How do I find which trigger raised ERROR 1644?

Query information_schema.TRIGGERS for the table (EVENT_OBJECT_TABLE) and read the body with SHOW CREATE TRIGGER.

How do I catch SQLSTATE 45000 in a stored procedure?

Use DECLARE EXIT HANDLER FOR SQLSTATE '45000' and read the text with GET DIAGNOSTICS CONDITION 1 var = MESSAGE_TEXT, as in the second case.

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