Skip to content

Commit a5ff23f

Browse files
authored
Support utf8mb3 charset naming for MySQL 8 and MariaDB 10.6 (brianmario#1323)
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.
1 parent c022701 commit a5ff23f

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

ext/mysql2/mysql_enc_name_to_ruby.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ mysql2_mysql_enc_name_to_rb_hash (str, len)
5151
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
5252
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
5353
74, 74, 74, 74, 74, 74, 74, 74, 15, 5,
54-
0, 74, 5, 25, 40, 10, 20, 50, 74, 74,
54+
0, 30, 5, 25, 40, 10, 20, 50, 74, 74,
5555
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
5656
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
5757
74, 74, 74, 74, 74, 74, 74, 74, 74, 74,
@@ -89,7 +89,7 @@ mysql2_mysql_enc_name_to_rb (str, len)
8989
{
9090
enum
9191
{
92-
TOTAL_KEYWORDS = 41,
92+
TOTAL_KEYWORDS = 42,
9393
MIN_WORD_LENGTH = 3,
9494
MAX_WORD_LENGTH = 8,
9595
MIN_HASH_VALUE = 3,
@@ -133,7 +133,8 @@ mysql2_mysql_enc_name_to_rb (str, len)
133133
{"big5", "Big5"},
134134
{"euckr", "EUC-KR"},
135135
{"latin2", "ISO-8859-2"},
136-
{""}, {""},
136+
{"utf8mb3", "UTF-8"},
137+
{""},
137138
{"dec8", NULL},
138139
{"cp850", "CP850"},
139140
{"latin1", "ISO-8859-1"},

ext/mysql2/mysql_enc_to_ruby.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,5 +306,20 @@ static const char *mysql2_mysql_enc_to_rb[] = {
306306
"UTF-8",
307307
"UTF-8",
308308
"UTF-8",
309+
"UTF-8",
310+
"UTF-8",
311+
"UTF-8",
312+
"UTF-8",
313+
"UTF-8",
314+
"UTF-8",
315+
"UTF-8",
316+
"UTF-8",
317+
"UTF-8",
318+
"UTF-8",
319+
"UTF-8",
320+
"UTF-8",
321+
"UTF-8",
322+
"UTF-8",
323+
"UTF-8",
309324
"UTF-8"
310325
};

support/mysql_enc_to_ruby.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"macroman" => "macRoman",
3434
"cp852" => "CP852",
3535
"latin7" => "ISO-8859-13",
36+
"utf8mb3" => "UTF-8",
3637
"utf8mb4" => "UTF-8",
3738
"cp1251" => "Windows-1251",
3839
"utf16" => "UTF-16",

support/ruby_enc_to_mysql.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"macroman" => "macRoman",
2929
"cp852" => "CP852",
3030
"latin7" => "ISO-8859-13",
31+
"utf8mb3" => "UTF-8",
3132
"utf8mb4" => "UTF-8",
3233
"cp1251" => "Windows-1251",
3334
"utf16" => "UTF-16",

0 commit comments

Comments
 (0)