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

WIP: Backport 0.4.x MySQL 8 Fixes to 0.3.x #935

Open
wants to merge 23 commits into
base: 0.3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9589643
Backport MySQL 8.0.3 support from 0.4.10 to 0.3.21
felixbuenemann Jan 16, 2018
93d3240
Backport MySQL 8.0.1 my_bool fix from PR 919
felixbuenemann Jan 16, 2018
2325197
Fix broken spec due to EXPLAIN EXTENDED on MySQL 8
felixbuenemann Apr 25, 2019
15fbd85
Fix SSL specs permission problem
felixbuenemann Apr 25, 2019
06a4344
Revert to precise on travis to fix mariadb install
felixbuenemann Apr 25, 2019
384e487
Revert "Pin to an older Rubygems gem on Travis"
felixbuenemann Apr 25, 2019
6d75e08
Use fuzzy ruby-2.3 on Travis CI
felixbuenemann Apr 25, 2019
0ff2f94
Don't allow MySQL 5.7 build errors on Travis CI
felixbuenemann Apr 25, 2019
175ca86
Remove rbx-2 from Travis CI build matrix
felixbuenemann Apr 25, 2019
62c1ff9
Try to fix Travis CI macOS builds
felixbuenemann Apr 25, 2019
757c78f
Disable SSL tests for macOS on Travis CI
felixbuenemann Apr 25, 2019
1e2372c
Use release version of MySQL 5.7 on Travis CI
felixbuenemann Apr 25, 2019
5d18e3a
Fix SSL client specs with MySQL 5.7
felixbuenemann Apr 26, 2019
71dc501
Fix ssl-verify-server-cert with Travis CI certs
felixbuenemann Apr 26, 2019
3c2fda2
Disable yaSSL valid before minute hack on Travis
felixbuenemann Apr 26, 2019
1a3e0d2
Disable socket_auth fo root on MySQL 5.7 on Travis
felixbuenemann Apr 26, 2019
091e1d5
Warn about missing MySQL encoding mappings
felixbuenemann Apr 26, 2019
246013e
Add encoding mappings for utf16le and gb18030
felixbuenemann Apr 26, 2019
f7150f5
Update encoding tables from MySQL 8.0.16
felixbuenemann Apr 26, 2019
8956784
Backport encoding bounds check from 0.5.2 / PR-976
felixbuenemann Apr 26, 2019
94b0498
Fix for MariaDB 10.2 which does not define CLIENT_LONG_PASSWORD
sodabrew Jun 29, 2017
cc7764b
Update Travis CI to Trusty / Test MySQL 8.0
felixbuenemann Apr 26, 2019
2966f64
Speed up CI feedback by allowing ree failures
felixbuenemann Apr 26, 2019
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
37 changes: 22 additions & 15 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
sudo: required
language: ruby
bundler_args: --without benchmarks
addons:
homebrew:
packages:
- mysql
script:
- bundle exec rake spec
# Temporary workaround for broken Rubygems on Travis
before_install:
- gem update --system 2.4.8
- gem --version
- |
bash -c " # Install MySQL 5.7 if DB=mysql57
if [[ x$DB =~ mysql57 ]]; then
sudo bash .travis_mysql57.sh
bash -c " # Install MySQL if DB=mysql*
if [[ x$DB =~ xmysql ]]; then
sudo bash .travis_mysql.sh '$DB'
fi
"
- |
bash -c " # Install MariaDB if DB=mariadb
bash -c " # Install MariaDB if DB=mariadb*
if [[ x$DB =~ xmariadb ]]; then
sudo bash .travis_mariadb.sh '$DB'
fi
"
- |
bash -c " # Install MySQL is OS=darwin
bash -c " # Install MySQL if OS=darwin
if [[ x$OSTYPE =~ ^xdarwin ]]; then
brew install mysql
# Disable SSL due to missing certs
echo ssl = 0 >> /usr/local/etc/my.cnf
mysql.server start
fi
"
Expand All @@ -35,29 +39,32 @@ before_install:
- mysqld --version
- mysql -u root -e "CREATE DATABASE IF NOT EXISTS test"
- mysql -u root -e "CREATE USER '$USER'@'localhost'" || true
os:
- linux
os: linux
dist: trusty
rvm:
- 1.8.7
- 1.9.3
- 2.0.0
- 2.1
- 2.2
- 2.3.1
- 2.3
- ree
matrix:
fast_finish: true
allow_failures:
- env: DB=mysql57
- rvm: rbx-2
- os: osx
- rvm: ree
include:
- rvm: 2.0.0
env: DB=mariadb55
- rvm: 2.0.0
env: DB=mariadb10
- rvm: 2.0.0
env: DB=mysql55
- rvm: 2.0.0
env: DB=mysql57
- rvm: rbx-2
env: RBXOPT=-Xgc.honor_start=true
- rvm: 2.0.0
dist: xenial
env: DB=mysql8
- rvm: 2.3
os: osx
15 changes: 11 additions & 4 deletions .travis_mariadb.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
#!/bin/sh
set -e

service mysql status && service mysql stop

service mysql stop
apt-get purge '^mysql*' 'libmysql*'
apt-get install python-software-properties
apt-get autoclean

rm -rf /etc/mysql /var/lib/mysql /var/log/mysql

apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db

. /etc/lsb-release

if [[ x$1 = xmariadb55 ]]; then
add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntu precise main'
echo "deb http://ftp.osuosl.org/pub/mariadb/repo/5.5/ubuntu $DISTRIB_CODENAME main" >> /etc/apt/sources.list
elif [[ x$1 = xmariadb10 ]]; then
add-apt-repository 'deb http://ftp.osuosl.org/pub/mariadb/repo/10.0/ubuntu precise main'
echo "deb http://ftp.osuosl.org/pub/mariadb/repo/10.3/ubuntu $DISTRIB_CODENAME main" >> /etc/apt/sources.list
fi

apt-get update
Expand Down
27 changes: 27 additions & 0 deletions .travis_mysql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh
set -e

service mysql status && service mysql stop

apt-get purge '^mysql*' 'libmysql*'
apt-get autoclean

rm -rf /etc/mysql /var/lib/mysql /var/log/mysql

apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x8C718D3B5072E1F5

. /etc/lsb-release

if [[ x$1 = xmysql56 ]]; then
echo "deb http://repo.mysql.com/apt/ubuntu $DISTRIB_CODENAME mysql-5.6" >> /etc/apt/sources.list
elif [[ x$1 = xmysql57 ]]; then
echo "deb http://repo.mysql.com/apt/ubuntu $DISTRIB_CODENAME mysql-5.7" >> /etc/apt/sources.list
elif [[ x$1 = xmysql8 ]]; then
echo "deb http://repo.mysql.com/apt/ubuntu $DISTRIB_CODENAME mysql-8.0" >> /etc/apt/sources.list
fi

apt-get update
apt-get -o Dpkg::Options::=--force-confdef -o Dpkg::Options::=--force-confold -y install mysql-server libmysqlclient-dev

# disable socket auth on mysql-community-server
mysql -u root -e "USE mysql; UPDATE user SET plugin='mysql_native_password' WHERE User='root'; FLUSH PRIVILEGES;"
16 changes: 0 additions & 16 deletions .travis_mysql57.sh

This file was deleted.

14 changes: 7 additions & 7 deletions .travis_ssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ commonName_default = ca_name
" >> ca.cnf

echo "
commonName_default = cert_name
commonName_default = localhost
" >> cert.cnf

# Generate a set of certificates
openssl genrsa -out ca-key.pem 2048
openssl req -new -x509 -nodes -days 1000 -key ca-key.pem -out ca-cert.pem -batch -config ca.cnf
openssl req -newkey rsa:2048 -days 1000 -nodes -keyout pkcs8-server-key.pem -out server-req.pem -batch -config cert.cnf
openssl x509 -req -in server-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem
openssl req -newkey rsa:2048 -days 1000 -nodes -keyout pkcs8-client-key.pem -out client-req.pem -batch -config cert.cnf
openssl x509 -req -in client-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem
openssl req -sha1 -new -x509 -nodes -days 1000 -key ca-key.pem -out ca-cert.pem -batch -config ca.cnf
openssl req -sha1 -newkey rsa:2048 -days 1000 -nodes -keyout pkcs8-server-key.pem -out server-req.pem -batch -config cert.cnf
openssl x509 -sha1 -req -in server-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out server-cert.pem
openssl req -sha1 -newkey rsa:2048 -days 1000 -nodes -keyout pkcs8-client-key.pem -out client-req.pem -batch -config cert.cnf
openssl x509 -sha1 -req -in client-req.pem -days 1000 -CA ca-cert.pem -CAkey ca-key.pem -set_serial 01 -out client-cert.pem

# Convert format from PKCS#8 to PKCS#1
openssl rsa -in pkcs8-server-key.pem -out server-key.pem
Expand All @@ -61,4 +61,4 @@ ssl-key=/etc/mysql/server-key.pem
" >> my.cnf

# Wait until the minute moves to ensure that the SSL cert is within its valid range
ruby -e 'start = Time.now.min; while Time.now.min == start; sleep 2; end'
# ruby -e 'start = Time.now.min; while Time.now.min == start; sleep 2; end'
11 changes: 11 additions & 0 deletions ext/mysql2/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,12 @@ static VALUE _mysql_client_options(VALUE self, int opt, VALUE value) {
retval = &boolval;
break;

#if defined(MYSQL_SECURE_AUTH)
case MYSQL_SECURE_AUTH:
boolval = (value == Qfalse ? 0 : 1);
retval = &boolval;
break;
#endif

case MYSQL_READ_DEFAULT_FILE:
charval = (const char *)StringValueCStr(value);
Expand Down Expand Up @@ -1182,7 +1184,12 @@ static VALUE set_ssl_options(VALUE self, VALUE key, VALUE cert, VALUE ca, VALUE
}

static VALUE set_secure_auth(VALUE self, VALUE value) {
/* This option was deprecated in MySQL 5.x and removed in MySQL 8.0 */
#if defined(MYSQL_SECURE_AUTH)
return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
#else
return Qfalse;
#endif
}

static VALUE set_read_default_file(VALUE self, VALUE value) {
Expand Down Expand Up @@ -1297,6 +1304,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
6 changes: 6 additions & 0 deletions ext/mysql2/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,12 @@ def asplode lib
asplode h unless have_header h
end

mysql_h = [prefix, 'mysql.h'].compact.join('/')

# my_bool is replaced by C99 bool in MySQL 8.0, but we want
# to retain compatibility with the typedef in earlier MySQLs.
have_type('my_bool', mysql_h)

# These gcc style flags are also supported by clang and xcode compilers,
# so we'll use a does-it-work test instead of an is-it-gcc test.
gcc_flags = ' -Wall -funroll-loops'
Expand Down
8 changes: 8 additions & 0 deletions ext/mysql2/mysql2_ext.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#ifndef MYSQL2_EXT
#define MYSQL2_EXT

/* MySQL 8.0 replaces my_bool with C99 bool. Earlier versions of MySQL had
* a typedef to char. Gem users reported failures on big endian systems when
* using C99 bool types with older MySQLs due to mismatched behavior. */
#ifndef HAVE_TYPE_MY_BOOL
#include <stdbool.h>
typedef bool my_bool;
#endif

/* tell rbx not to use it's caching compat layer
by doing this we're making a promise to RBX that
we'll never modify the pointers we get back from RSTRING_PTR */
Expand Down
Loading