Skip to content

Commit

Permalink
MySQL 8.0.17+ support: INT types no longer return a width specification
Browse files Browse the repository at this point in the history
Fixes: #4216
  • Loading branch information
Deltik committed Jul 16, 2020
1 parent 3fcbcd3 commit aee67c1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions e107_handlers/db_verify_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,16 @@ private function diffStructurePermissive($expected, $actual)
$actual['default'] = preg_replace("/DEFAULT '(\d*\.?\d*)'/i", 'DEFAULT $1', $actual['default'] );
}

/**
* Display width specification for integer data types was deprecated in MySQL 8.0.17
* @see https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-19.html
*/
if(1 === preg_match('/([A-Z]*INT)/i', $expected['type']))
{
$expected['value'] = '';
$actual['value'] = '';
}

// Correct difference on CREATE TABLE statement between MariaDB and MySQL
if(1 === preg_match('/(DATE|DATETIME|TIMESTAMP|TIME|YEAR)/i', $expected['default']))
{
Expand Down

3 comments on commit aee67c1

@dimante
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to understand PHP a bit more.. How does this make the script behave differently when it's MySQL 8 ?

@Deltik
Copy link
Member Author

@Deltik Deltik commented on aee67c1 Jul 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code just makes the db_verify::diffStructurePermissive() ignore any differences in the "value" when the "type" ends with INT (includes MEDIUMINT and BIGINT, for instance). "value" here is the character width of the type. MySQL 8.0.17+ decided that the value is meaningless, so they removed it. This commit does the same thing and simply ignores the value by removing it.

@dimante
Copy link
Contributor

@dimante dimante commented on aee67c1 Jul 17, 2020 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.