Skip to content
Advertisement

Mariadb 10.4 Data truncated for column ‘column_name’ on insert but not on update

I have the following table (mariadb 10.4) called p:

+----------------+----------------------------------------------------------------------------------------+------+-----+---------+----------------+
| Field          | Type                                                                                   | Null | Key | Default | Extra          |
+----------------+----------------------------------------------------------------------------------------+------+-----+---------+----------------+

| id             | int(11)                                                                                | NO   | PRI | NULL    | auto_increment |
| description    | text                                                                                   | YES  |     | NULL    |                |
| url            | text                                                                                   | YES  |     | NULL    |                |
| source         | enum('source_a','source_b','source_c','source_d','source_e')                           | YES  |     | NULL    |                |

I currently have a couple of million rows on this table with the sources a, b, c, and d. Just recently we applied a migration to add source_e and we started getting the error ERROR 1265 (01000): Data truncated for column 'source' at row 1 when trying to inset a row with the source_e. The used command that yields the error is the following:

INSERT INTO p (description, url, `source`) VALUES ('test', 'https://google.com.br', 'source_e');

Insertions with any of the other sources are still working.

The behavior changes when editing a row that is already on the db, the error is not shown:

UPDATE `p` SET `source`='source_e' WHERE `id`='3'; Yields: Query OK, 1 rows affected (0.001 sec)

Is there a way to debug this scenario? I’ve tried changing the log level of the db to get a better insight on the problem (SET GLOBAL log_warnings=3;) but the error message did not change.

I also tried changing the source_e name to source_e_, the error persisted.

Btw, i did change the name of the fields to comply with company policies.

Advertisement

Answer

It turns out it was my bad. We happen to have a trigger on insertions of this table that feeds a materialized view kind of table. All I had to do was add ‘source_e’ to the source field on the other table.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement