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

Validate if `utf8mb4` character set and longer index key prefix is supported #33853

Merged
merged 3 commits into from Sep 13, 2018

Conversation

Projects
None yet
5 participants
@yahonda
Contributor

yahonda commented Sep 12, 2018

Summary

Use utf8 character set by default if MySQL server does not support longer index key prefix

Once #33608 merged If users create a new database using MySQL 5.1.x, it will fail to create databases
since MySQL 5.1 does not know utf8mb4 character set.

This pull request removes encoding: utf8mb4 from mysql.yml.tt
to let create_database method handles default character set by MySQL server version.

Other Information

supports_longer_index_key_prefix? method will need to validate if MySQL 5.5 and 5.6 server configured correctly to support longer index key prefix, but not yet.

@rails-bot

This comment has been minimized.

Show comment
Hide comment
@rails-bot

rails-bot Sep 12, 2018

r? @sgrif

(@rails-bot has picked a reviewer for you, use r? to override)

rails-bot commented Sep 12, 2018

r? @sgrif

(@rails-bot has picked a reviewer for you, use r? to override)

else
version >= "5.7.9"
end
end

This comment has been minimized.

@jeremy

jeremy Sep 12, 2018

Member

Should we feature-detect innodb_large_prefix instead of version check?

@jeremy

jeremy Sep 12, 2018

Member

Should we feature-detect innodb_large_prefix instead of version check?

This comment has been minimized.

@yahonda

yahonda Sep 12, 2018

Contributor

Sure. I've been looking for what system variables are appropriate to see if the longer key prefix is configured.

  • innodb_large_prefix
    Introduced at MySQL 5.5, deprecated in MySQL 5.7 and removed in MySQL 8.0.

  • innodb_default_row_format
    Introduced at MySQL 5.7.9, does not exist in MySQL 5.6 or lower.

@yahonda

yahonda Sep 12, 2018

Contributor

Sure. I've been looking for what system variables are appropriate to see if the longer key prefix is configured.

  • innodb_large_prefix
    Introduced at MySQL 5.5, deprecated in MySQL 5.7 and removed in MySQL 8.0.

  • innodb_default_row_format
    Introduced at MySQL 5.7.9, does not exist in MySQL 5.6 or lower.

This comment has been minimized.

@jeremy

jeremy Sep 13, 2018

Member

This seems awkward to detect.

Another approach: optimistically use utf8mb4 charset, then rescue StatementInvalid exception and raise our explanatory RuntimeError.

@jeremy

jeremy Sep 13, 2018

Member

This seems awkward to detect.

Another approach: optimistically use utf8mb4 charset, then rescue StatementInvalid exception and raise our explanatory RuntimeError.

Show outdated Hide outdated ...verecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

@jeremy jeremy requested a review from kamipo Sep 12, 2018

else
version >= "5.7.9"
end
end

This comment has been minimized.

@jeremy

jeremy Sep 13, 2018

Member

This seems awkward to detect.

Another approach: optimistically use utf8mb4 charset, then rescue StatementInvalid exception and raise our explanatory RuntimeError.

@jeremy

jeremy Sep 13, 2018

Member

This seems awkward to detect.

Another approach: optimistically use utf8mb4 charset, then rescue StatementInvalid exception and raise our explanatory RuntimeError.

Show outdated Hide outdated ...verecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb

@yahonda yahonda changed the title from Use `utf8` character set by default if MySQL does not support longer index key prefix to Validate if `utf8mb4` character set and longer index key prefix is supported Sep 13, 2018

Validate if `utf8mb4` character set and longer index key prefix is su…
…pported

Once #33608 merged If users create a new database using MySQL 5.1.x, it will fail to create databases
since MySQL 5.1 does not know `utf8mb4` character set.

This pull request removes `encoding: utf8mb4` from `mysql.yml.tt`
to let create_database method handles default character set by MySQL server version.

`supports_longer_index_key_prefix?` method will need to validate if MySQL 5.5 and 5.6 server configured
correctly to support longer index key prefix, but not yet.

yahonda added some commits Sep 12, 2018

Drop MySQL 5.1 support
* MySQL 5.1 does not support `utf8mb4` character set

* MySQL 5.1 had been already EOLed on Dec 2013
https://www.mysql.com/support/eol-notice.html

> Per Oracle's Lifetime Support policy, as of December 31, 2013, MySQL 5.1
> is covered under Oracle Sustaining Support.

* MySQL 5.5.8 is the first General Availability of MySQL 5.5

https://dev.mysql.com/doc/relnotes/mysql/5.5/en/news-5-5-8.html

@jeremy jeremy added this to the 6.0.0 milestone Sep 13, 2018

@jeremy jeremy merged commit f89e2c2 into rails:master Sep 13, 2018

2 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

yahonda added a commit to yahonda/rails that referenced this pull request Sep 13, 2018

yahonda added a commit to yahonda/rails that referenced this pull request Sep 13, 2018

Bump the minimum version of mysql2 gem to 0.5.0
Rails 6 drops MySQL 5.1 support and requires MySQL 5.5.8 by #33853
mysql2 gem 0.5.0 also drops MySQL 5.1 support.

https://github.com/brianmario/mysql2/releases/tag/0.5.0
> MySQL 5.5 or higher required. MySQL 5.0 and 5.1 are not supported.

Related to #31636 #32310 #33853

yahonda added a commit to yahonda/rails that referenced this pull request Sep 20, 2018

yahonda added a commit to yahonda/rails that referenced this pull request Sep 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment