Skip to content

Commit

Permalink
Support utf8mb3 charset naming for MySQL 8 and MariaDB 10.6 (#1323)
Browse files Browse the repository at this point in the history
MySQL and MariaDB have long aliased the `utf8` charset to the
underlying `utf8mb3`. They both switched to report the underlying
charset name instead of the alias name, allowing `utf8` to target
`utf8mb4` in the future.

That means we need to explicitly map `utf8mb3` for folks running
newer MySQL/MariaDB with older `utf8` dbs.
  • Loading branch information
jeremy committed Aug 3, 2023
1 parent c022701 commit a5ff23f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
7 changes: 4 additions & 3 deletions ext/mysql2/mysql_enc_name_to_ruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ mysql2_mysql_enc_name_to_rb_hash (str, len)
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 15, 5,
0, 74, 5, 25, 40, 10, 20, 50, 74, 74,
0, 30, 5, 25, 40, 10, 20, 50, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
Expand Down Expand Up @@ -89,7 +89,7 @@ mysql2_mysql_enc_name_to_rb (str, len)
{
enum
{
TOTAL_KEYWORDS = 41,
TOTAL_KEYWORDS = 42,
MIN_WORD_LENGTH = 3,
MAX_WORD_LENGTH = 8,
MIN_HASH_VALUE = 3,
Expand Down Expand Up @@ -133,7 +133,8 @@ mysql2_mysql_enc_name_to_rb (str, len)
{"big5", "Big5"},
{"euckr", "EUC-KR"},
{"latin2", "ISO-8859-2"},
{""}, {""},
{"utf8mb3", "UTF-8"},
{""},
{"dec8", NULL},
{"cp850", "CP850"},
{"latin1", "ISO-8859-1"},
Expand Down
15 changes: 15 additions & 0 deletions ext/mysql2/mysql_enc_to_ruby.h
Original file line number Diff line number Diff line change
Expand Up @@ -306,5 +306,20 @@ static const char *mysql2_mysql_enc_to_rb[] = {
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8",
"UTF-8"
};
1 change: 1 addition & 0 deletions support/mysql_enc_to_ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"macroman" => "macRoman",
"cp852" => "CP852",
"latin7" => "ISO-8859-13",
"utf8mb3" => "UTF-8",
"utf8mb4" => "UTF-8",
"cp1251" => "Windows-1251",
"utf16" => "UTF-16",
Expand Down
1 change: 1 addition & 0 deletions support/ruby_enc_to_mysql.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"macroman" => "macRoman",
"cp852" => "CP852",
"latin7" => "ISO-8859-13",
"utf8mb3" => "UTF-8",
"utf8mb4" => "UTF-8",
"cp1251" => "Windows-1251",
"utf16" => "UTF-16",
Expand Down

0 comments on commit a5ff23f

Please sign in to comment.