Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Column message_body too short #78

Open
sebastianopilla opened this issue May 21, 2018 · 1 comment
Open

Column message_body too short #78

sebastianopilla opened this issue May 21, 2018 · 1 comment
Labels

Comments

@sebastianopilla
Copy link

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
  1. 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
Copy link
Collaborator

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants