I created a BEFORE INSERT trigger which modifies a value making it too long. Despite the sql_mode, no error/warning appears.
MariaDB [test]> USE test;
|
Database changed
|
MariaDB [test]> SET @@session.sql_mode = 'STRICT_ALL_TABLES,STRICT_TRANS_TABLES'
|
;
|
Query OK, 0 rows affected (0.00 sec)
|
|
MariaDB [test]> DROP TABLE IF EXISTS t1;
|
Query OK, 0 rows affected (0.06 sec)
|
|
MariaDB [test]> CREATE TABLE t1 (
|
-> c CHAR(1) NOT NULL
|
-> ) ENGINE = InnoDB;
|
Query OK, 0 rows affected (0.08 sec)
|
|
MariaDB [test]> DELIMITER ||
|
MariaDB [test]> CREATE TRIGGER t1_bi
|
-> BEFORE INSERT
|
-> ON t1
|
-> FOR EACH ROW
|
-> BEGIN
|
-> SET NEW.c = 'www';
|
-> END;
|
-> ||
|
Query OK, 0 rows affected (0.04 sec)
|
|
MariaDB [test]> DELIMITER ;
|
MariaDB [test]> INSERT INTO t1 VALUES ('a');
|
Query OK, 1 row affected (0.00 sec)
|
Records: 1 Duplicates: 0 Warnings: 0
|
|
MariaDB [test]> SHOW WARNINGS;
|
Empty set (0.00 sec)
|
|
MariaDB [test]> SELECT * FROM t1;
|
+---+
|
| c |
|
+---+
|
| w |
|
+---+
|
1 row in set (0.00 sec)
|
Sorry, i dont have a MySQL installed locally anymore, so i dont know if this bug is mainstream.
Some notes...
- only happens with before insert triggers, not with update triggers or procedures or functions
- only happens when doing SET NEW.col, not when trying to UPDATE another table
- only happens for long data, not if you try to set NULL a NOT NULL column