I'm currently working on updating a Drupal site from 6.38 to 7.59, with a MySQL 5.7.21 DB and PHP 5.3.29.

On running the update script, it fails on update 7061 of the update module, due to a MySQL error: "Error Code: 1171. All parts of a PRIMARY KEY must be NOT NULL; if you need NULL in a key, use UNIQUE instead" in response to "CREATE TABLE system_update_7061 ( `vid` INT DEFAULT NULL, PRIMARY KEY (`vid`) ) ENGINE = InnoDB DEFAULT CHARACTER SET utf8 COMMENT 'Stores temporary data for system_update_7061.'"

I wound up executing the table creation query by hand without the DEFAULT NULL, and was able to complete the update as normal. I dug into this a little bit, and it seems that many contributed modules have resolved this simply by adding a 'not null' => TRUE to the table creation (in this case, at system.install line 2871).

I'm wondering if due to this behavior in MySQL 5.7, if includes/database/mysql/schema.inc (createTableSql, ~ line 92) should instead be modified to automatically add the not null if the field is in the array of primary keys. If so, then I guess this issue component needs to get switched.

I can submit a patch if desired, I just haven't done any Drupal contributions to date (and I'm new to the ecosystem as a whole).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

LFP6 created an issue. See original summary.

mfb’s picture

This is also preventing tests from passing in the MySQL 5.7 environment, so let's fix it.

Status: Needs review » Needs work

The last submitted patch, 2: system-update-2981248-2.patch, failed testing. View results

mfb’s picture

Status: Needs work » Needs review

I guess that was a heisenfailure

mfb’s picture

@LFP6 or anyone else, feel free to review this patch :)

mfb’s picture

Issue tags: +Drupal 7.60 target

Adding Drupal 7.60 target as it would be nice to run automated tests on MySQL 5.7

sjerdo’s picture

Status: Needs review » Reviewed & tested by the community

LGTM +1

mfb’s picture

There's an older duplicate issue @ #2665362: D7 upgrades fail with mysql 5.7:

greggles’s picture

Since the change is the same and the other issue is older, I guess this should be marked as a duplicate?

Would be great to get your +1/rtbc on that issue.

Would also be great if you could look at #2615496: A serial/primary key field can not be added to an existing table for some databases!

joseph.olstad’s picture

Version: 7.59 » 7.60
Issue tags: -Drupal 7.60 target +Drupal 7.61 target

this didn't make it into 7.60, bumping to 7.61

Anaconda777’s picture

Hi,

Sorry: it was wrong place to post this.

sjerdo’s picture

Fabianx’s picture

Version: 7.6 » 7.x-dev
Assigned: Unassigned » Pol
Issue tags: +Pending Drupal 7 commit

Looks good to me, marking for commit.

Pol, please include people from https://www.drupal.org/project/drupal/issues/2665362 to get credit here.

Thanks!

Pol credited msti.

Pol’s picture

Looks good to me as well.

Updating the credits.

Thanks !

Pol’s picture

Pol’s picture

Updating credits again.

  • Pol committed 56a02ca on 7.x
    Issue #2981248 by mfb, LFP6, msti: MySQL 5.7 incompatibility in system...
Pol’s picture

Status: Reviewed & tested by the community » Fixed

Fixed, thanks !

Status: Fixed » Closed (fixed)

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

joseph.olstad’s picture

Assigned: Pol » Unassigned
Issue tags: -Drupal bugfix target, -Pending Drupal 7 commit

This is fixed, thanks everyone!

Removing the tags.