Skip to content

Commit

Permalink
Merge pull request #867 from sodabrew/no-enable-cleartext-plugin
Browse files Browse the repository at this point in the history
Add ifdefs for MySQL 5.1 without MYSQL_ENABLE_CLEARTEXT_PLUGIN
  • Loading branch information
sodabrew authored Jul 6, 2017
2 parents 26e08be + f566384 commit 331f94d
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ matrix:
mariadb: 10.2
hosts:
- mysql2gem.example.com
- rvm: 2.0.0
env: DB=mysql51
dist: precise
addons:
hosts:
- mysql2gem.example.com
- rvm: 2.0.0
env: DB=mysql55
dist: precise
Expand Down Expand Up @@ -105,3 +111,6 @@ matrix:
- os: osx
rvm: system
env: DB=mysql56
- rvm: 2.0.0
env: DB=mysql51
dist: precise
11 changes: 11 additions & 0 deletions .travis_mysql51.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

set -eux

apt-get purge -qq '^mysql*' '^libmysql*'
rm -fr /etc/mysql
rm -fr /var/lib/mysql
apt-key adv --keyserver keys.gnupg.net --recv-keys 8507EFA5
add-apt-repository 'deb http://repo.percona.com/apt precise main'
apt-get update -qq
apt-get install -qq percona-server-server-5.1 percona-server-client-5.1 libmysqlclient16-dev
5 changes: 5 additions & 0 deletions .travis_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

set -eux

# Install MySQL 5.1 if DB=mysql51
if [[ -n ${DB-} && x$DB =~ ^xmysql51 ]]; then
sudo bash .travis_mysql51.sh
fi

# Install MySQL 5.7 if DB=mysql57
if [[ -n ${DB-} && x$DB =~ ^xmysql57 ]]; then
sudo bash .travis_mysql57.sh
Expand Down
6 changes: 6 additions & 0 deletions ext/mysql2/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -903,10 +903,12 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
retval = charval;
break;

#ifdef MYSQL_ENABLE_CLEARTEXT_PLUGIN
case MYSQL_ENABLE_CLEARTEXT_PLUGIN:
boolval = (value == Qfalse ? 0 : 1);
retval = &boolval;
break;
#endif

default:
return Qfalse;
Expand Down Expand Up @@ -1326,7 +1328,11 @@ static VALUE set_init_command(VALUE self, VALUE value) {
}

static VALUE set_enable_cleartext_plugin(VALUE self, VALUE value) {
#ifdef MYSQL_ENABLE_CLEARTEXT_PLUGIN
return _mysql_client_options(self, MYSQL_ENABLE_CLEARTEXT_PLUGIN, value);
#else
rb_raise(cMysql2Error, "enable-cleartext-plugin is not available, you may need a newer MySQL client library");
#endif
}

static VALUE initialize_ext(VALUE self) {
Expand Down

0 comments on commit 331f94d

Please sign in to comment.