Skip to content

Commit 8193dc4

Browse files
authored
Fix to build with MySQL 5.1 (#1197)
1 parent 33ee746 commit 8193dc4

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

ext/mysql2/client.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,10 +935,12 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
935935
retval = charval;
936936
break;
937937

938+
#ifdef HAVE_MYSQL_DEFAULT_AUTH
938939
case MYSQL_DEFAULT_AUTH:
939940
charval = (const char *)StringValueCStr(value);
940941
retval = charval;
941942
break;
943+
#endif
942944

943945
#ifdef HAVE_CONST_MYSQL_ENABLE_CLEARTEXT_PLUGIN
944946
case MYSQL_ENABLE_CLEARTEXT_PLUGIN:
@@ -1404,7 +1406,11 @@ static VALUE set_init_command(VALUE self, VALUE value) {
14041406
}
14051407

14061408
static VALUE set_default_auth(VALUE self, VALUE value) {
1409+
#ifdef HAVE_MYSQL_DEFAULT_AUTH
14071410
return _mysql_client_options(self, MYSQL_DEFAULT_AUTH, value);
1411+
#else
1412+
rb_raise(cMysql2Error, "pluggable authentication is not available, you may need a newer MySQL client library");
1413+
#endif
14081414
}
14091415

14101416
static VALUE set_enable_cleartext_plugin(VALUE self, VALUE value) {

ext/mysql2/extconf.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ def add_ssl_defines(header)
124124
have_struct_member('MYSQL', 'net.pvio', mysql_h)
125125

126126
# These constants are actually enums, so they cannot be detected by #ifdef in C code.
127+
have_const('MYSQL_DEFAULT_AUTH', mysql_h)
127128
have_const('MYSQL_ENABLE_CLEARTEXT_PLUGIN', mysql_h)
128129
have_const('SERVER_QUERY_NO_GOOD_INDEX_USED', mysql_h)
129130
have_const('SERVER_QUERY_NO_INDEX_USED', mysql_h)

0 commit comments

Comments
 (0)