Column message_body too short
Opened this issue · 1 comments
sebastianopilla commented
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 batches@example.com;
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: "no-reply@example.com" <no-reply@example.com>
May 21 15:25:22 dev-batches java[1378]: Reply-To: no-reply@example.com
May 21 15:25:22 dev-batches java[1378]: To: batches@example.com
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)
barryoneill commented
Thanks for the bug report!
I suspect this is somewhat related to #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)