0

I have a table logs with a column info - the type is text. I get an error running the following query:

insert into logs (date_time, info, log_code, company_id, updated_at, created_at) values ('2019-04-06 22:38:58', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx', 508, 410, '2019-04-30 01:23:45', '2019-04-30 00:00:00');

ERROR 1406 (22001): Data too long for column 'Info' at row 1

Unfortunately the error can't be reproduced in another table. If I run:

create table test like logs

and then run the same query on test then it works.

Even with unicode this amount of data shouldn't be a problem for a data type that can hold over 65 kilobytes.

I've been looking for a solution for a couple hours and can't find anything. And it's especially odd that it can't be reproduced on another server or even on the same server in an identical table.


Results of describe logs:

+-----------------------+---------------------------------------+------+-----+---------+----------------+
| Field                 | Type                                  | Null | Key | Default | Extra          |
+-----------------------+---------------------------------------+------+-----+---------+----------------+
| id                    | int(10) unsigned                      | NO   | PRI | NULL    | auto_increment |
| company_id            | int(10) unsigned                      | YES  | MUL | NULL    |                |
| another_column1       | int(10) unsigned                      | YES  | MUL | NULL    |                |
| date_time             | timestamp                             | YES  | MUL | NULL    |                |
| log_code              | int(11)                               | YES  | MUL | NULL    |                |
| info                  | text                                  | YES  |     | NULL    |                |
| another_column2       | varchar(255)                          | YES  |     | NULL    |                |
| another_column3       | tinyint(1)                            | NO   |     | 0       |                |
| type                  | enum('log','event','warning','error') | NO   |     | log     |                |
| created_at            | timestamp                             | YES  |     | NULL    |                |
| updated_at            | timestamp                             | YES  |     | NULL    |                |
| deleted_at            | timestamp                             | YES  |     | NULL    |                |
| another_column4       | int(10) unsigned                      | YES  | MUL | NULL    |                |
+-----------------------+---------------------------------------+------+-----+---------+----------------+
  • 3
    Show table's DDL. Check the table storage for errors. Check if some trigger exists. – Akina Apr 30 at 8:17
  • Do you get a warning when you insert to the test table? Are you somehow inadvertently switching between strict and non-strict sql_mode? – dbdemon Apr 30 at 8:29
  • 1
    @Akina As it turns out my DB administrator added a trigger that copies the data to another table when critical error are logged. And that table has a wrong datatype. Thanks for pointing me to this. If you post this as an answer I'll mark it as the solution. – Rafał G. Apr 30 at 8:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.