Skip to content

Commit

Permalink
Merge remote-tracking branch 'brianmario/master' into force_latin1_to…
Browse files Browse the repository at this point in the history
…_utf8
  • Loading branch information
jeremy committed Feb 23, 2022
2 parents d388a11 + 8193dc4 commit b5766f5
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 24 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,36 @@ jobs:
- ubuntu-18.04 # bionic
# - ubuntu-16.04 # xenial
ruby:
- '3.1'
- '3.0'
- 2.7
- 2.6
- 2.5
- 2.4
- 2.3
- 2.2
- 2.1
- '2.7'
- '2.6'
- '2.5'
- '2.4'
- '2.3'
- '2.2'
- '2.1'
db: ['']
include:
# Allow failure due to Mysql2::Error: Unknown system variable 'session_track_system_variables'.
- {os: ubuntu-16.04, ruby: 2.4, db: mariadb10.0, allow-failure: true}
- {os: ubuntu-16.04, ruby: '2.4', db: mariadb10.0, allow-failure: true}
# Comment out due to ci/setup.sh stucking.
# - {os: ubuntu-18.04, ruby: 2.4, db: mariadb10.1}
# Allow failure due to the issue #965, #1165.
- {os: ubuntu-20.04, ruby: 2.4, db: mariadb10.3, allow-failure: true}
- {os: ubuntu-18.04, ruby: 2.4, db: mysql57}
- {os: ubuntu-20.04, ruby: '2.4', db: mariadb10.3, allow-failure: true}
- {os: ubuntu-18.04, ruby: '2.4', db: mysql57}
# Allow failure due to the issue #1165.
- {os: ubuntu-20.04, ruby: 2.4, db: mysql80, allow-failure: true}
- {os: ubuntu-20.04, ruby: '2.4', db: mysql80, allow-failure: true}
- {os: ubuntu-18.04, ruby: 'head', db: '', allow-failure: true}
# db: A DB's brew package name in macOS case.
# Set a name "db: '[email protected]'" when using an old version.
# MariaDB lastet version
# Allow failure due to the following test failures that rarely happens.
# https://github.com/brianmario/mysql2/issues/1194
- {os: macos-latest, ruby: 2.4, db: mariadb, allow-failure: true}
- {os: macos-latest, ruby: '2.4', db: mariadb, allow-failure: true}
# MySQL latest version
# Allow failure due to the issue #1165.
- {os: macos-latest, ruby: 2.4, db: mysql, allow-failure: true}
- {os: macos-latest, ruby: '2.4', db: mysql, allow-failure: true}
# On the fail-fast: true, it cancels all in-progress jobs
# if any matrix job fails unlike Travis fast_finish.
fail-fast: false
Expand Down
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
1 change: 1 addition & 0 deletions ext/mysql2/result.c
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,7 @@ void init_mysql2_result() {
rb_global_variable(&cDateTime);

cMysql2Result = rb_define_class_under(mMysql2, "Result", rb_cObject);
rb_undef_alloc_func(cMysql2Result);
rb_global_variable(&cMysql2Result);

rb_define_method(cMysql2Result, "each", rb_mysql_result_each, -1);
Expand Down
1 change: 1 addition & 0 deletions ext/mysql2/statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ void init_mysql2_statement() {
rb_global_variable(&cBigDecimal);

cMysql2Statement = rb_define_class_under(mMysql2, "Statement", rb_cObject);
rb_undef_alloc_func(cMysql2Statement);
rb_global_variable(&cMysql2Statement);

rb_define_method(cMysql2Statement, "param_count", rb_mysql_stmt_param_count, 0);
Expand Down
13 changes: 2 additions & 11 deletions spec/mysql2/result_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,8 @@
end

it "should raise a TypeError exception when it doesn't wrap a result set" do
if RUBY_VERSION >= "3.1"
expect { Mysql2::Result.new }.to raise_error(TypeError)
expect { Mysql2::Result.allocate }.to raise_error(TypeError)
else
r = Mysql2::Result.new
expect { r.count }.to raise_error(TypeError)
expect { r.fields }.to raise_error(TypeError)
expect { r.field_types }.to raise_error(TypeError)
expect { r.size }.to raise_error(TypeError)
expect { r.each }.to raise_error(TypeError)
end
expect { Mysql2::Result.new }.to raise_error(TypeError)
expect { Mysql2::Result.allocate }.to raise_error(TypeError)
end

it "should have included Enumerable" do
Expand Down

0 comments on commit b5766f5

Please sign in to comment.