Skip to content

Commit 5fa7700

Browse files
tamirdsodabrew
authored andcommitted
Drop 1.9.3 support (#913)
1 parent 245c3d1 commit 5fa7700

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+17
-138
lines changed

.rubocop.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
inherit_from: .rubocop_todo.yml
22

33
AllCops:
4-
TargetRubyVersion: 1.9
4+
TargetRubyVersion: 2.0
55

66
DisplayCopNames: true
77
Exclude:
@@ -21,10 +21,6 @@ Layout/IndentHeredoc:
2121
Lint/EndAlignment:
2222
EnforcedStyleAlignWith: variable
2323

24-
Style/Encoding:
25-
AutoCorrectEncodingComment: '# encoding: UTF-8'
26-
EnforcedStyle: always
27-
2824
Style/TrailingCommaInArguments:
2925
EnforcedStyleForMultiline: consistent_comma
3026

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ rvm:
2323
- 2.2
2424
- 2.1
2525
- 2.0.0
26-
- 1.9.3
2726
- ruby-head
2827
matrix:
2928
include:

Gemfile

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
source 'https://rubygems.org'
42

53
gemspec
@@ -10,9 +8,8 @@ gem 'rake-compiler', '~> 1.0'
108
group :test do
119
gem 'eventmachine' unless RUBY_PLATFORM =~ /mswin|mingw/
1210
gem 'rspec', '~> 3.2'
13-
# https://github.com/bbatsov/rubocop/pull/3328
1411
# https://github.com/bbatsov/rubocop/pull/4789
15-
gem 'rubocop', '~> 0.50.0' unless RUBY_VERSION =~ /1.9/
12+
gem 'rubocop', '~> 0.50.0'
1613
end
1714

1815
group :benchmarks do

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The Mysql2 gem is meant to serve the extremely common use-case of connecting, qu
77
Some database libraries out there serve as direct 1:1 mappings of the already complex C APIs available.
88
This one is not.
99

10-
It also forces the use of UTF-8 [or binary] for the connection [and all strings in 1.9, unless Encoding.default_internal is set then it'll convert from UTF-8 to that encoding] and uses encoding-aware MySQL API calls where it can.
10+
It also forces the use of UTF-8 [or binary] for the connection and uses encoding-aware MySQL API calls where it can.
1111

1212
The API consists of three classes:
1313

@@ -510,7 +510,7 @@ As for field values themselves, I'm workin on it - but expect that soon.
510510

511511
This gem is tested with the following Ruby versions on Linux and Mac OS X:
512512

513-
* Ruby MRI 1.9.3, 2.0.0, 2.1.x, 2.2.x, 2.3.x, 2.4.x
513+
* Ruby MRI 2.0.0, 2.1.x, 2.2.x, 2.3.x, 2.4.x
514514
* Rubinius 2.x and 3.x do work but may fail under some workloads
515515

516516
This gem is tested with the following MySQL and MariaDB versions:

Rakefile

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require 'rake'
42

53
# Load custom tasks (careful attention to define tasks before prerequisites)
@@ -12,7 +10,7 @@ load 'tasks/benchmarks.rake'
1210
begin
1311
require 'rubocop/rake_task'
1412
RuboCop::RakeTask.new
15-
task default: [:spec, :rubocop]
13+
task default: %i[spec rubocop]
1614
rescue LoadError
1715
warn 'RuboCop is not available'
1816
task default: :spec

benchmark/active_record.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
42

53
require 'rubygems'

benchmark/active_record_threaded.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
42

53
require 'rubygems'

benchmark/allocations.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
42

53
require 'rubygems'

benchmark/escape.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
42

53
require 'rubygems'

benchmark/query_with_mysql_casting.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
42

53
require 'rubygems'

benchmark/query_without_mysql_casting.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
42

53
require 'rubygems'

benchmark/sequel.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
42

53
require 'rubygems'

benchmark/setup_db.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
42

53
# This script is for generating psudo-random data into a single table consisting of nearly every

examples/eventmachine.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
$LOAD_PATH.unshift 'lib'
42

53
require 'rubygems'

examples/threaded.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
$LOAD_PATH.unshift 'lib'
42
require 'mysql2'
53
require 'timeout'

ext/mysql2/client.h

-6
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
#ifndef MYSQL2_CLIENT_H
22
#define MYSQL2_CLIENT_H
33

4-
#ifndef HAVE_RB_THREAD_CALL_WITHOUT_GVL
5-
/* emulate rb_thread_call_without_gvl with rb_thread_blocking_region */
6-
#define rb_thread_call_without_gvl(func, data1, ubf, data2) \
7-
rb_thread_blocking_region((rb_blocking_function_t *)func, data1, ubf, data2)
8-
#endif /* ! HAVE_RB_THREAD_CALL_WITHOUT_GVL */
9-
104
typedef struct {
115
VALUE encoding;
126
VALUE active_thread; /* rb_thread_current() or Qnil */

ext/mysql2/extconf.rb

-13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require 'mkmf'
42
require 'English'
53

@@ -27,9 +25,6 @@ def add_ssl_defines(header)
2725
have_func('rb_absint_size')
2826
have_func('rb_absint_singlebit_p')
2927

30-
# 2.0-only
31-
have_header('ruby/thread.h') && have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
32-
3328
# Missing in RBX (https://github.com/rubinius/rubinius/issues/3771)
3429
have_func('rb_wait_for_single_fd')
3530

@@ -57,14 +52,6 @@ def add_ssl_defines(header)
5752
# If the user has provided a --with-mysql-dir argument, we must respect it or fail.
5853
inc, lib = dir_config('mysql')
5954
if inc && lib
60-
# TODO: Remove when 2.0.0 is the minimum supported version
61-
# Ruby versions not incorporating the mkmf fix at
62-
# https://bugs.ruby-lang.org/projects/ruby-trunk/repository/revisions/39717
63-
# do not properly search for lib directories, and must be corrected
64-
unless lib && lib[-3, 3] == 'lib'
65-
@libdir_basename = 'lib'
66-
inc, lib = dir_config('mysql')
67-
end
6855
abort "-----\nCannot find include dir(s) #{inc}\n-----" unless inc && inc.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
6956
abort "-----\nCannot find library dir(s) #{lib}\n-----" unless lib && lib.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
7057
warn "-----\nUsing --with-mysql-dir=#{File.dirname inc}\n-----"

ext/mysql2/mysql2_ext.h

-8
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ void Init_mysql2(void);
1818
#endif
1919

2020
#include <ruby/encoding.h>
21-
// ruby/thread.h was added in 2.0.0. See:
22-
// https://github.com/ruby/ruby/commit/c51a826
23-
//
24-
// Rubinius doesn't define this, but it ships an empty thread.h (the symbols we
25-
// care about are in ruby.h); this is safe to remove when < 2.0.0 is no longer
26-
// supported.
27-
#ifdef HAVE_RUBY_THREAD_H
2821
#include <ruby/thread.h>
29-
#endif
3022

3123
#if defined(__GNUC__) && (__GNUC__ >= 3)
3224
#define RB_MYSQL_NORETURN __attribute__ ((noreturn))

lib/mysql2.rb

+5-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require 'date'
42
require 'bigdecimal'
53

@@ -75,13 +73,11 @@ def self.key_hash_as_symbols(hash)
7573
# Timeout::ExitException was removed in Ruby 2.3.0, 2.2.3, and 2.1.8,
7674
# but is present in earlier 2.1.x and 2.2.x, so we provide a shim.
7775
#
78-
if Thread.respond_to?(:handle_interrupt)
79-
require 'timeout'
80-
TIMEOUT_ERROR_CLASS = if defined?(::Timeout::ExitException)
81-
::Timeout::ExitException
82-
else
83-
::Timeout::Error
84-
end
76+
require 'timeout'
77+
TIMEOUT_ERROR_CLASS = if defined?(::Timeout::ExitException)
78+
::Timeout::ExitException
79+
else
80+
::Timeout::Error
8581
end
8682
end
8783
end

lib/mysql2/client.rb

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
module Mysql2
42
class Client
53
attr_reader :query_options, :read_timeout
@@ -33,7 +31,7 @@ def initialize(opts = {})
3331
opts[:connect_timeout] = 120 unless opts.key?(:connect_timeout)
3432

3533
# TODO: stricter validation rather than silent massaging
36-
[:reconnect, :connect_timeout, :local_infile, :read_timeout, :write_timeout, :default_file, :default_group, :secure_auth, :init_command, :automatic_close, :enable_cleartext_plugin].each do |key|
34+
%i[reconnect connect_timeout local_infile read_timeout write_timeout default_file default_group secure_auth init_command automatic_close enable_cleartext_plugin].each do |key|
3735
next unless opts.key?(key)
3836
case key
3937
when :reconnect, :local_infile, :secure_auth, :automatic_close, :enable_cleartext_plugin
@@ -71,7 +69,7 @@ def initialize(opts = {})
7169
conn_attrs = opts[:connect_attrs] || {}
7270
conn_attrs[:program_name] = $PROGRAM_NAME unless conn_attrs.key?(:program_name)
7371

74-
if [:user, :pass, :hostname, :dbname, :db, :sock].any? { |k| @query_options.key?(k) }
72+
if %i[user pass hostname dbname db sock].any? { |k| @query_options.key?(k) }
7573
warn "============= WARNING FROM mysql2 ============="
7674
warn "The options :user, :pass, :hostname, :dbname, :db, and :sock are deprecated and will be removed at some point in the future."
7775
warn "Instead, please use :username, :password, :host, :port, :database, :socket, :flags for the options."
@@ -124,14 +122,8 @@ def parse_flags_array(flags, initial = 0)
124122
end
125123
end
126124

127-
if Thread.respond_to?(:handle_interrupt)
128-
def query(sql, options = {})
129-
Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_CLASS => :never) do
130-
_query(sql, @query_options.merge(options))
131-
end
132-
end
133-
else
134-
def query(sql, options = {})
125+
def query(sql, options = {})
126+
Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_CLASS => :never) do
135127
_query(sql, @query_options.merge(options))
136128
end
137129
end

lib/mysql2/console.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
# Loaded by script/console. Land helpers here.
42

53
Pry.config.prompt = lambda do |context, *|

lib/mysql2/em.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: utf-8
2-
31
require 'eventmachine'
42
require 'mysql2'
53

lib/mysql2/error.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
module Mysql2
42
class Error < StandardError
53
ENCODE_OPTS = {

lib/mysql2/field.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
module Mysql2
42
Field = Struct.new(:name, :type)
53
end

lib/mysql2/result.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
module Mysql2
42
class Result
53
attr_reader :server_flags

lib/mysql2/statement.rb

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
1-
# encoding: UTF-8
2-
31
module Mysql2
42
class Statement
53
include Enumerable
64

7-
if Thread.respond_to?(:handle_interrupt)
8-
def execute(*args)
9-
Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_CLASS => :never) do
10-
_execute(*args)
11-
end
12-
end
13-
else
14-
def execute(*args)
5+
def execute(*args)
6+
Thread.handle_interrupt(::Mysql2::Util::TIMEOUT_ERROR_CLASS => :never) do
157
_execute(*args)
168
end
179
end

lib/mysql2/version.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
module Mysql2
42
VERSION = "0.4.10".freeze
53
end

mysql2.gemspec

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require File.expand_path('../lib/mysql2/version', __FILE__)
42

53
Mysql2::GEMSPEC = Gem::Specification.new do |s|
@@ -12,7 +10,7 @@ Mysql2::GEMSPEC = Gem::Specification.new do |s|
1210
s.homepage = 'http://github.com/brianmario/mysql2'
1311
s.rdoc_options = ["--charset=UTF-8"]
1412
s.summary = 'A simple, fast Mysql library for Ruby, binding to libmysql'
15-
s.required_ruby_version = '>= 1.9.3'
13+
s.required_ruby_version = '>= 2.0.0'
1614

1715
s.files = `git ls-files README.md CHANGELOG.md LICENSE ext lib support`.split
1816
s.test_files = `git ls-files spec examples`.split

spec/em/em_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require 'spec_helper'
42
begin
53
require 'eventmachine'

spec/mysql2/client_spec.rb

-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require 'spec_helper'
42

53
RSpec.describe Mysql2::Client do
@@ -607,10 +605,6 @@ def run_gc
607605
end
608606

609607
it 'should be impervious to connection-corrupting timeouts in #execute' do
610-
# the statement handle gets corrupted and will segfault the tests if interrupted,
611-
# so we can't even use pending on this test, really have to skip it on older Rubies.
612-
skip('`Thread.handle_interrupt` is not defined') unless Thread.respond_to?(:handle_interrupt)
613-
614608
# attempt to break the connection
615609
stmt = @client.prepare('SELECT SLEEP(?)')
616610
expect { Timeout.timeout(0.1) { stmt.execute(0.2) } }.to raise_error(Timeout::Error)

spec/mysql2/error_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require 'spec_helper'
42

53
RSpec.describe Mysql2::Error do

spec/mysql2/result_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require 'spec_helper'
42

53
RSpec.describe Mysql2::Result do

spec/mysql2/statement_spec.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require './spec/spec_helper.rb'
42

53
RSpec.describe Mysql2::Statement do

spec/spec_helper.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
require 'rspec'
42
require 'mysql2'
53
require 'timeout'

support/mysql_enc_to_ruby.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
42
require 'mysql2'
53

support/ruby_enc_to_mysql.rb

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
mysql_to_rb = {
42
"big5" => "Big5",
53
"dec8" => nil,

tasks/benchmarks.rake

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# encoding: UTF-8
2-
31
BENCHMARKS = Dir["#{File.dirname(__FILE__)}/../benchmark/*.rb"].map do |path|
42
File.basename(path, '.rb')
53
end - ['setup_db']

0 commit comments

Comments
 (0)