Column message_body too short
Question/Issue Overview
Using MariaDB, Holdmail fails to insert a row in the message table if the length of the message body exceeds the limit of the text type (65KB).
Expected Behavior
The row corresponding to the message should be successfully inserted in the message table.
Current Behavior
The row is not inserted, and a SQLException similar to the following one is visible in the log:
May 21 15:25:22 dev-batches java[1378]: Caused by: java.sql.SQLException: Data too long for column 'message_body' at row 1
May 21 15:25:22 dev-batches java[1378]: Query is: insert into message (has_attachments, identifier, message_size, message_body, received_date,
sender_email, sender_host, subject) values (?, ?, ?, ?, ?, ?, ?, ?), parameters [1,'<1666664075.2.1526909122666.JavaMail.tomcat@dev-batches>'
,910459,'Received: from dev-batches (localhost [127.0.0.1])
May 21 15:25:22 dev-batches java[1378]: by dev-batches
May 21 15:25:22 dev-batches java[1378]: with SMTP (HoldMailSMTPServer SMTP) id JHGA9NCB
May 21 15:25:22 dev-batches java[1378]: for [email protected];
May 21 15:25:22 dev-batches java[1378]: Mon, 21 May 2018 15:25:22 +0200 (CEST)
May 21 15:25:22 dev-batches java[1378]: From: "[email protected]" <[email protected]>
May 21 15:25:22 dev-batches java[1378]: Reply-To: [email protected]
May 21 15:25:22 dev-batches java[1378]: To: [email protected]
Reproducible Sequence
- Send a message larger than 65KB (for example with attachments).
Additional Information
A quick fix is to change the type of the message_body column to LONGTEXT:
MariaDB [holdmaildb]> alter table message modify message_body longtext;
MariaDB [holdmaildb]> desc message;
+-----------------+--------------+------+-----+----------------------+-----------------------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+----------------------+-----------------------------+
| message_id | int(11) | NO | PRI | NULL | auto_increment |
| identifier | varchar(255) | NO | | NULL | |
| subject | varchar(255) | NO | | NULL | |
| sender_email | varchar(255) | NO | | NULL | |
| received_date | timestamp(3) | NO | | CURRENT_TIMESTAMP(3) | on update CURRENT_TIMESTAMP |
| sender_host | varchar(255) | YES | | NULL | |
| message_size | int(11) | NO | | NULL | |
| message_body | longtext | YES | | NULL | |
| has_attachments | tinyint(1) | NO | | 0 | |
+-----------------+--------------+------+-----+----------------------+-----------------------------+
9 rows in set (0.00 sec)
Thanks for the bug report!
I suspect this is somewhat related to https://github.com/SpartaSystems/holdmail/issues/77 - if somebody picks this up, please consider also moving the message_body to its own table. The listing of messages does not need to query this attribute (IIRC)