petoju / terraform-provider-mysql

Terraform MySQL provider – unofficial fork
https://registry.terraform.io/providers/petoju/mysql
Mozilla Public License 2.0
66 stars 41 forks source link

MySQL 8.0 utf8 persistent diff / tests failing #7

Closed petoju closed 2 years ago

petoju commented 2 years ago

MySQL 8.0 tests are not passing, because the semantics has changed.

Per https://dev.mysql.com/doc/refman/8.0/en/charset-unicode-utf8.html this has changed in version 8.0.28:

The utf8mb3 character set is deprecated and you should expect it to be removed in a future MySQL release. Please use utf8mb4 instead. utf8 is currently an alias for utf8mb3, but it is now deprecated as such, and utf8 is expected subsequently to become a reference to utf8mb4.

And also

utf8 has been used by MySQL is an alias for the utf8mb3 character set, but this usage is being phased out; as of MySQL 8.0.28, SHOW statements and columns of Information Schema tables display utf8mb3 instead.

Futhermore, aliasing works the other way around on old DBs.

So we and our users are in a bad situation if they specified utf8 like our tests. We can:

  1. "Fix" our tests to use utf8mb4 and leave our users with new (and old) MySQL up to persistent diff. This is a quick fix.
  2. Ignore changes if they are between utf8 and utf8mb3. But this will start working unexpectedly in the future once utf8 becomes utf8mb4
  3. Find out the version on connection and based on the version, either leave utf8 like that, rewrite utf8 to utf8mb3 or to utf8mb4. This will make charset of user's DBs/tables change once MySQL starts using different aliasing.

I'll start with the quick fix. I'm not sure I should do something more.