PDOException: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'mailto' at row 1: INSERT INTO {mail_logger} (mailkey, mailto, subject, body, mailfrom, headers, date_sent, language) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7); Array ( [:db_insert_placeholder_0] => workflow_notify_workflow_notify [:db_insert_placeholder_1] => Rebecca Driscoll - Event Creator;Matthew Biewener;Nancy Wichmann;A Proud CAPT Staff Person;Empress Nancy [:db_insert_placeholder_2] => something wicked this way cometh is now "Revisions Needed" [:db_insert_placeholder_3] => This is a multi-part message in MIME format. --3a30bbe224f026e56eaecb52d3cf2d7f304c8bfc1 Content-Type: multipart/alternative; boundary="40b7d85d5ee182c0f057108e64e4a19af9618b610" Content-Transfer-Encoding: 8bit --40b7d85d5ee182c0f057108e64e4a19af9618b610 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit something wicked this way cometh [1] is now "Revisions Needed". [1] http://local.captconnect.edc.org/event/something-wicked-way-cometh --40b7d85d5ee182c0f057108e64e4a19af9618b610 Content-Type: text/html; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8Bit

something wicked this way cometh is now "Revisions Needed".

--40b7d85d5ee182c0f057108e64e4a19af9618b610-- --3a30bbe224f026e56eaecb52d3cf2d7f304c8bfc1-- [:db_insert_placeholder_4] => "CAPT Connect" [:db_insert_placeholder_5] => a:7:{s:12:"MIME-Version";s:3:"1.0";s:12:"Content-Type";s:69:"multipart/mixed; boundary="3a30bbe224f026e56eaecb52d3cf2d7f304c8bfc1"";s:25:"Content-Transfer-Encoding";s:4:"8Bit";s:8:"X-Mailer";s:6:"Drupal";s:11:"Return-Path";s:19:"";s:6:"Sender";s:34:""CAPT Connect" ";s:4:"From";s:34:""CAPT Connect" ";} [:db_insert_placeholder_6] => 1439239991 [:db_insert_placeholder_7] => en ) in mail_logger_mail_alter() (line 110 of C:\wamp\www\Core7\sites\captconnect.edc.org\modules\contrib\mail_logger\mail_logger.module).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

NancyDru created an issue. See original summary.

NancyDru’s picture

Priority: Major » Normal

I increased the field to VARCHAR(2047) in the mail_logger.install file and I'm running now.

NancyDru’s picture

Assigned: Unassigned » NancyDru
Status: Active » Needs review
FileSize
1.02 KB

Here's a patch.

  • NancyDru committed 7363306 on 7.x-1.x
    Issue #2549049 by NancyDru: Expand mailto column.
    
NancyDru’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

vincenzodb’s picture

This patch throw an error:

WD php: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes: CREATE TABLE {mail_logger} (                                    [error]
`mlid` INT unsigned NOT NULL auto_increment COMMENT 'Mail Logger entry ID', 
`mailkey` VARCHAR(255) NOT NULL COMMENT 'a key identifying the mail type', 
`mailto` VARCHAR(2047) NOT NULL COMMENT 'to whom this mail is going', 
`subject` VARCHAR(255) NOT NULL COMMENT 'Mail subject', 
`body` LONGTEXT NOT NULL COMMENT 'Body text of the mail', 
`mailfrom` VARCHAR(255) NOT NULL COMMENT 'the FROM email address', 
`headers` LONGTEXT NOT NULL COMMENT 'Headers of the outgoing mail', 
`date_sent` INT unsigned NOT NULL COMMENT 'Mail Logger entry ID', 
`language` VARCHAR(20) NOT NULL COMMENT 'Language code', 
PRIMARY KEY (`mlid`), 
INDEX `mailto` (`mailto`), 
INDEX `mailfrom` (`mailfrom`), 
INDEX `subject` (`subject`(20)), 
INDEX `date_sent` (`date_sent`), 
INDEX `language` (`language`)
) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Mail Logger table stores outgoing mails'; Array
(
)
 in db_create_table() (line 2720 of /home/[...]/includes/database/database.inc).
NancyDru’s picture

Status: Closed (fixed) » Active

Hmm, worked fine for me on three different sites.

What version of MySql are you running?

vincenzodb’s picture

@NancyDru 5.6.26

according to http://dev.mysql.com/doc/refman/5.6/en/innodb-restrictions.html

to increase index key size it's needed a specific configuration
By default, an index key for a single-column index can be up to 767 bytes. The same length limit applies to any index key prefix. See Section 13.1.12, “CREATE INDEX Syntax”. For example, you might hit this limit with a column prefix index of more than 255 characters on a TEXT or VARCHAR column, assuming a UTF-8 character set and the maximum of 3 bytes for each character. When the innodb_large_prefix configuration option is enabled, this length limit is raised to 3072 bytes, for InnoDB tables that use the DYNAMIC and COMPRESSED row formats.

(also for mysql 5.7)

NancyDru’s picture

Status: Active » Needs review
FileSize
1.65 KB

Please try this patch.

vincenzodb’s picture

It works, many thanks!

NancyDru’s picture

Great. I will go ahead and commit.

  • NancyDru committed 779b3d3 on 7.x-1.x
    Issue #2549049 by NancyDru, vincenzodb - Correct index setting.
    
NancyDru’s picture

Status: Needs review » Fixed
Rob C’s picture

This does not seem to solve my problem.

On a site with 1.1 installed i upgraded to revision 779b3d30426e573d9779fbef40543837dbbba830 and executed updates via updates.php. This is what i get:

Failed: PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes: ALTER TABLE {mail_logger} CHANGE `mailto` `mailto` VARCHAR(2047) NOT NULL COMMENT 'to whom this mail is going'; Array ( ) in db_change_field() (line 3020 of /public/includes/database/database.inc).

I'm on:
branch 7.x-1.x
779b3d30426e573d9779fbef40543837dbbba830

NancyDru’s picture

Please try the latest version, 7.x-1.3.

heatoni’s picture

I seem to be seeing this same issue with 7.x-1.3:

PDOException: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes: ALTER TABLE {mail_logger} CHANGE `mailto` `mailto` VARCHAR(2047) NOT NULL COMMENT 'to whom this mail is going'; Array ( ) in db_change_field() (line 3020 of /home/ttivps/public_html/includes/database/database.inc).

Is there some way I can debug this? MySQL version: 5.6.29-log

NancyDru’s picture

The index should be meet that limit now. Make sure you ran update.php.

egontinno’s picture

Same error is displayed when I run update.php.
MySQL 5.6.28

NancyDru’s picture

Status: Fixed » Needs work

Any MySql experts around?

brad.bulger’s picture

also getting an error with mysql 5.6.28

Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes: ALTER TABLE {mail_logger} CHANGE `mailto` `mailto` VARCHAR(2047) NOT NULL COMMENT 'to whom this mail is going';

what's peculiar is that running that same query via drush sql-query works. running db_change_field() from a script fails.

the difference seems to be the value of the variable sql_mode - when the query is run from the script, the value is

REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,STRICT_TRANS_TABLES,STRICT_ALL_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER

STRICT_TRANS_TABLES seems to be the culprit. setting that explicitly before running the ALTER TABLE query causes the error.

http://dev.mysql.com/doc/refman/5.6/en/sql-mode.html
http://dev.mysql.com/doc/refman/5.6/en/sql-mode.html#sql-mode-strict

NancyDru’s picture

Is that something that was changed in 5.6? How might people turn that off? Can it be turned off in the update hook?

brad.bulger’s picture

FileSize
590 bytes

i changed the sql_mode variable in the install hook and that worked for me. the mysql doc link about strict sql mode says that it didn't used to generate an error, i think. it also implies that without the error it would just fail silently, i think, which isn't great.

NancyDru’s picture

Could you try it like this, please?

  if (db_driver() == 'mysql') {}
    // Otherwise the alter table may fail.
    db_query("set sql_mode = 'NO_ENGINE_SUBSTITUTION'");
  }
Rob C’s picture

Status: Needs work » Needs review
FileSize
587 bytes

#23 / #24 fixed the problem for me with MySQL 5.6.29.

  • NancyDru committed 7abb379 on 7.x-1.x
    Issue #2549049 by brad.bulger, NancyDru - Fix index setting.
    
NancyDru’s picture

Status: Needs review » Fixed

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.