Details
-
Bug
-
Status: Confirmed (View Workflow)
-
Critical
-
Resolution: Unresolved
-
10.6, 10.11, 11.4, 11.8, 12.1
-
None
Description
If a table has an ENUM column without a default value, then when inserting a row without specifying this column, the first ENUM value is inserted. This is expected and matches the documentation:
https://mariadb.com/docs/server/reference/data-types/string-data-types/enum
CREATE TABLE `enum_test` (
|
`id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, |
`enum_column` enum('N','Y') NOT NULL, |
`datum` datetime NOT NULL,
|
PRIMARY KEY (`id`)
|
) ENGINE=InnoDB
|
DEFAULT CHARSET=utf8mb4
|
COLLATE=utf8mb4_general_ci;
|
|
INSERT INTO enum_test (datum) VALUES (NOW());
|
SELECT * FROM enum_test;
|
|
+----+-------------+---------------------+
|
| id | enum_column | datum |
|
+----+-------------+---------------------+
|
| 1 | N | 2025-08-22 10:05:36 | |
+----+-------------+---------------------+
|
However, if a BEFORE trigger is added to this table, then when inserting a row without specifying the ENUM column, instead of the first ENUM value, an empty string ('') gets inserted:
DELIMITER $$
|
CREATE TRIGGER `test_trigger` BEFORE UPDATE ON `enum_test` FOR EACH ROW BEGIN
|
END
|
$$
|
DELIMITER ;
|
|
INSERT INTO enum_test (datum) VALUES (NOW());
|
SELECT * FROM enum_test;
|
|
+----+-------------+---------------------+
|
| id | enum_column | datum |
|
+----+-------------+---------------------+
|
| 1 | N | 2025-08-22 10:05:36 | |
| 2 | | 2025-08-22 10:05:52 | |
+----+-------------+---------------------+
|
Affected versions: 10.6.23, 10.11.14, 11.4.8, 11.8.3, 12.0.2, 12.1.1
Not affected versions: 11.2.2, 11.2.6, 11.3.2
Attachments
Issue Links
- relates to
-
MDEV-19761 Before Trigger not processed for Not Null Columns if no explicit value and no DEFAULT
-
- Closed
-