Skip to content
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

MariaDBclient + Mysql8 support #30

Open
wants to merge 6 commits into
base: 0.2.x_force_latin1_to_utf8
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ext/mysql2/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,7 @@ static VALUE initialize_ext(VALUE self) {
}

void init_mysql2_client() {
#ifdef _WIN32
/* verify the libmysql we're about to use was the version we were built against
https://github.com/luislavena/mysql-gem/commit/a600a9c459597da0712f70f43736e24b484f8a99 */
int i;
Expand All @@ -1238,6 +1239,7 @@ void init_mysql2_client() {
return;
}
}
#endif

/* Initializing mysql library, so different threads could call Client.new */
/* without race condition in the library */
Expand Down Expand Up @@ -1307,6 +1309,10 @@ void init_mysql2_client() {
#ifdef CLIENT_LONG_PASSWORD
rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"),
LONG2NUM(CLIENT_LONG_PASSWORD));
#else
/* HACK because MariaDB 10.2 no longer defines this constant,
* but we're using it in our default connection flags. */
rb_const_set(cMysql2Client, rb_intern("LONG_PASSWORD"), INT2NUM(0));
#endif

#ifdef CLIENT_FOUND_ROWS
Expand Down
2 changes: 1 addition & 1 deletion ext/mysql2/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def asplode lib
/usr/local/lib/mysql5
].map{|dir| "#{dir}/bin" }

GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5}"
GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5,mariadb_config}"

# If the user has provided a --with-mysql-dir argument, we must respect it or fail.
inc, lib = dir_config('mysql')
Expand Down
139 changes: 67 additions & 72 deletions ext/mysql2/mysql_enc_name_to_ruby.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* C code produced by gperf version 3.0.3 */
/* Command-line: gperf */
/* ANSI-C code produced by gperf version 3.1 */
/* Command-line: /usr/bin/gperf */
/* Computed positions: -k'1,3,$' */

#if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \
Expand All @@ -26,11 +26,11 @@
&& ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \
&& ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126))
/* The character set is not based on ISO-646. */
error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gnu[email protected]>."
#error "gperf generated tables don't work with this execution character set. Please report a bug to <[email protected]>."
#endif

struct mysql2_mysql_enc_name_to_rb_map { const char *name; const char *rb_name; };
/* maximum key range = 66, duplicates = 0 */
/* maximum key range = 71, duplicates = 0 */

#ifdef __GNUC__
__inline
Expand All @@ -40,123 +40,118 @@ inline
#endif
#endif
static unsigned int
mysql2_mysql_enc_name_to_rb_hash (str, len)
register const char *str;
register unsigned int len;
mysql2_mysql_enc_name_to_rb_hash (register const char *str, register size_t len)
{
static const unsigned char asso_values[] =
{
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 40, 5,
0, 69, 0, 40, 25, 20, 10, 55, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 35, 5, 0,
10, 0, 20, 0, 5, 5, 69, 0, 10, 15,
0, 0, 69, 69, 25, 5, 5, 0, 69, 30,
69, 0, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69, 69, 69, 69, 69,
69, 69, 69, 69, 69, 69
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, 74, 74, 74, 74, 74, 74, 74, 74,
74, 74, 74, 74, 74, 74, 74, 74, 15, 5,
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,
74, 74, 74, 74, 74, 74, 74, 40, 5, 0,
15, 10, 0, 0, 0, 5, 74, 0, 25, 5,
0, 5, 74, 74, 20, 5, 5, 0, 74, 45,
74, 0, 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, 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, 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, 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,
74, 74, 74, 74, 74, 74
};
return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]] + asso_values[(unsigned char)str[len - 1]];
}

#ifdef __GNUC__
__inline
#ifdef __GNUC_STDC_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const struct mysql2_mysql_enc_name_to_rb_map *
mysql2_mysql_enc_name_to_rb (str, len)
register const char *str;
register unsigned int len;
mysql2_mysql_enc_name_to_rb (register const char *str, register size_t len)
{
enum
{
TOTAL_KEYWORDS = 39,
TOTAL_KEYWORDS = 42,
MIN_WORD_LENGTH = 3,
MAX_WORD_LENGTH = 8,
MIN_HASH_VALUE = 3,
MAX_HASH_VALUE = 68
MAX_HASH_VALUE = 73
};

static const struct mysql2_mysql_enc_name_to_rb_map wordlist[] =
{
{""}, {""}, {""},
{"gbk", "GBK"},
{""},
{"greek", "ISO-8859-7"},
{"utf32", "UTF-32"},
{"gb2312", "GB2312"},
{"keybcs2", NULL},
{""},
{"ucs2", "UTF-16BE"},
{"koi8u", "KOI8-R"},
{"binary", "ASCII-8BIT"},
{"eucjpms", "eucJP-ms"},
{""},
{"utf8mb4", "UTF-8"},
{"macroman", "macRoman"},
{"ujis", "eucJP-ms"},
{"cp852", "CP852"},
{"greek", "ISO-8859-7"},
{"cp1251", "Windows-1251"},
{"geostd8", NULL},
{"utf16le", "UTF-16LE"},
{""},
{"sjis", "Shift_JIS"},
{"macce", "macCentEuro"},
{"cp1257", "Windows-1257"},
{"eucjpms", "eucJP-ms"},
{""},
{"utf8", "UTF-8"},
{"cp852", "CP852"},
{"cp1250", "Windows-1250"},
{"gb18030", "GB18030"},
{""},
{"swe7", NULL},
{"koi8r", "KOI8-R"},
{"tis620", "TIS-620"},
{"geostd8", NULL},
{""},
{"big5", "Big5"},
{"euckr", "EUC-KR"},
{"latin2", "ISO-8859-2"},
{"utf8mb3", "UTF-8"},
{""},
{"macroman", "macRoman"},
{"dec8", NULL},
{"utf32", "UTF-32"},
{"cp850", "CP850"},
{"latin1", "UTF-8"},
{"utf8mb4", "UTF-8"},
{""},
{"hp8", NULL},
{"swe7", NULL},
{"euckr", "EUC-KR"},
{"cp1257", "Windows-1257"},
{""}, {""},
{"utf8", "UTF-8"},
{"koi8r", "KOI8-R"},
{"cp1256", "Windows-1256"},
{""}, {""}, {""},
{"cp866", "IBM866"},
{""},
{"utf16", "UTF-16"},
{"latin7", "ISO-8859-13"},
{""}, {""}, {""},
{"ascii", "US-ASCII"},
{"hebrew", "ISO-8859-8"},
{""}, {""},
{"big5", "Big5"},
{"utf16", "UTF-16"},
{"cp1250", "Windows-1250"},
{""}, {""}, {""},
{"cp850", "CP850"},
{"tis620", "TIS-620"},
{"cp1256", "Windows-1256"},
{""}, {""}, {""},
{"cp932", "Windows-31J"},
{"hebrew", "ISO-8859-8"},
{""}, {""}, {""}, {""},
{"latin5", "ISO-8859-9"},
{""}, {""}, {""}, {""}, {""}, {""},
{""}, {""}, {""},
{"cp866", "IBM866"},
{""}, {""}, {""}, {""}, {""}, {""}, {""},
{"armscii8", NULL}
};

if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
{
register int key = mysql2_mysql_enc_name_to_rb_hash (str, len);
register unsigned int key = mysql2_mysql_enc_name_to_rb_hash (str, len);

if (key <= MAX_HASH_VALUE && key >= 0)
if (key <= MAX_HASH_VALUE)
{
register const char *s = wordlist[key].name;

Expand Down
Loading