Skip to content

Commit

Permalink
Fix to build with MySQL 5.1 (brianmario#1197)
Browse files Browse the repository at this point in the history
  • Loading branch information
arika authored Jan 17, 2022
1 parent 33ee746 commit 8193dc4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ext/mysql2/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,10 +935,12 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
retval = charval;
break;

#ifdef HAVE_MYSQL_DEFAULT_AUTH
case MYSQL_DEFAULT_AUTH:
charval = (const char *)StringValueCStr(value);
retval = charval;
break;
#endif

#ifdef HAVE_CONST_MYSQL_ENABLE_CLEARTEXT_PLUGIN
case MYSQL_ENABLE_CLEARTEXT_PLUGIN:
Expand Down Expand Up @@ -1404,7 +1406,11 @@ static VALUE set_init_command(VALUE self, VALUE value) {
}

static VALUE set_default_auth(VALUE self, VALUE value) {
#ifdef HAVE_MYSQL_DEFAULT_AUTH
return _mysql_client_options(self, MYSQL_DEFAULT_AUTH, value);
#else
rb_raise(cMysql2Error, "pluggable authentication is not available, you may need a newer MySQL client library");
#endif
}

static VALUE set_enable_cleartext_plugin(VALUE self, VALUE value) {
Expand Down
1 change: 1 addition & 0 deletions ext/mysql2/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def add_ssl_defines(header)
have_struct_member('MYSQL', 'net.pvio', mysql_h)

# These constants are actually enums, so they cannot be detected by #ifdef in C code.
have_const('MYSQL_DEFAULT_AUTH', mysql_h)
have_const('MYSQL_ENABLE_CLEARTEXT_PLUGIN', mysql_h)
have_const('SERVER_QUERY_NO_GOOD_INDEX_USED', mysql_h)
have_const('SERVER_QUERY_NO_INDEX_USED', mysql_h)
Expand Down

0 comments on commit 8193dc4

Please sign in to comment.