WIP Default to standards-compliant utf8mb4 character set
Description
xref #915
The utf8 character set in current MySQL versions is not actually standards-compliant. The standards-compliant UTF-8 character set is spelled utf8mb4, and that should be mycli's default.
~WIP because this should be researched/tested for MariaDB and Percona.~ Edit: tested on MariaDB. Researched for Percona: pages such as https://www.percona.com/blog/2018/04/10/migrating-database-charsets-to-utf8mb4/ have no suggestion of incompatibility.
Checklist
- [x] I've added this contribution to the
changelog.md. - [x] I've added my name to the
AUTHORSfile (or it's already there).
I think this default should depend on the server version: mysql < 5.5 cannot handle utf8mb4.
@pasenor excellent point.
Wait, how would that work? We set the charset before we make the connection.
Oops, indeed, that's messy. But we should be able call set_charset() on the PyMySQL connection object inside our SQLExecute once know the version
Note that utf8 is considered an alias for utf8mb3 and both MySQL and MariaDB are actively doing work to eventually change the alias to map to utf8mb4.
- https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8.html
- https://dev.mysql.com/doc/relnotes/mysql/8.0/en/news-8-0-30.html
Important Change: A previous change renamed character sets having deprecated names prefixed with utf8_ to use utf8mb3_ instead. In this release, we rename the utf8_ collations as well, using the utf8mb3_ prefix; this is to make the collation names consistent with those of the character sets, not to rely any longer on the deprecated collation names, and to clarify the distinction between utf8mb3 and utf8mb4. The names using the utf8mb3_ prefix are now used exclusively for these collations in the output of SHOW statements such as SHOW CREATE TABLE, as well as in the values displayed in the columns of Information Schema tables including the COLLATIONS and COLUMNS tables. (Bug #33787300)
- https://jira.mariadb.org/browse/MDEV-8334
- https://jira.mariadb.org/browse/MDEV-22217
The utf8mb4 character set was introduced in MySQL 5.5.4, this was not a G.A. release (5.5.8 was the first G.A. release). So utf8mb4 should be used for MySQL 5.5 and newer.
- https://downloads.mysql.com/docs/mysql-5.5-relnotes-en.pdf
@rolandwalker Is this PR still valid? Should this be merged?
@amjith yes we should do something about it. Will review.