Skip to content

Commit 8d6f29f

Browse files
authored
Merge pull request #632 from tamird/remove-support-for-1.8
Remove `{1.8.7,ree}` support
2 parents 59e446d + 22b0d3c commit 8d6f29f

20 files changed

+31
-356
lines changed

.travis.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,6 @@ rvm:
2727
- ruby-head
2828
matrix:
2929
include:
30-
- rvm: 1.8.7
31-
dist: precise
32-
env: SPEC_OPTS="--order rand:11"
33-
addons:
34-
hosts:
35-
- mysql2gem.example.com
36-
apt:
37-
packages:
38-
- mysql-server-5.5
39-
- mysql-client-core-5.5
40-
- mysql-client-5.5
41-
- rvm: ree
42-
dist: precise
43-
env: SPEC_OPTS="--order rand:11"
44-
addons:
45-
hosts:
46-
- mysql2gem.example.com
47-
apt:
48-
packages:
49-
- mysql-server-5.5
50-
- mysql-client-core-5.5
51-
- mysql-client-5.5
5230
- rvm: 2.4
5331
env: DB=mariadb10.0
5432
addons:

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ gem 'rake-compiler', '~> 0.9.5'
88
group :test do
99
gem 'eventmachine' unless RUBY_PLATFORM =~ /mswin|mingw/
1010
gem 'rspec', '~> 3.2'
11-
gem 'rubocop', '~> 0.34.0' unless RUBY_VERSION =~ /1.8/
11+
gem 'rubocop', '~> 0.34.0'
1212
end
1313

1414
group :benchmarks do

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,8 +509,7 @@ As for field values themselves, I'm workin on it - but expect that soon.
509509

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

512-
* Ruby MRI 1.8.7, 1.9.3, 2.0.0, 2.1.x, 2.2.x, 2.3.x, 2.4.x
513-
* Ruby Enterprise Edition (based on MRI 1.8.7)
512+
* Ruby MRI 1.9.3, 2.0.0, 2.1.x, 2.2.x, 2.3.x, 2.4.x
514513
* Rubinius 2.x and 3.x do work but may fail under some workloads
515514

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

Rakefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ load 'tasks/generate.rake'
99
load 'tasks/benchmarks.rake'
1010

1111
# TODO: remove engine check when rubinius stops crashing on RuboCop
12-
# TODO: remove defined?(Encoding) when we end support for < 1.9.3
13-
has_rubocop = if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby' && defined?(Encoding)
12+
has_rubocop = if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby'
1413
begin
1514
require 'rubocop/rake_task'
1615
RuboCop::RakeTask.new

ext/mysql2/client.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ extern VALUE mMysql2, cMysql2Error;
1919
static VALUE sym_id, sym_version, sym_header_version, sym_async, sym_symbolize_keys, sym_as, sym_array, sym_stream;
2020
static ID intern_brackets, intern_merge, intern_merge_bang, intern_new_with_args;
2121

22-
#ifndef HAVE_RB_HASH_DUP
23-
VALUE rb_hash_dup(VALUE other) {
24-
return rb_funcall(rb_cHash, intern_brackets, 1, other);
25-
}
26-
#endif
27-
2822
#define REQUIRE_INITIALIZED(wrapper) \
2923
if (!wrapper->initialized) { \
3024
rb_raise(cMysql2Error, "MySQL client is not initialized"); \
@@ -178,10 +172,8 @@ static VALUE rb_raise_mysql2_error(mysql_client_wrapper *wrapper) {
178172
VALUE rb_sql_state = rb_tainted_str_new2(mysql_sqlstate(wrapper->client));
179173
VALUE e;
180174

181-
#ifdef HAVE_RUBY_ENCODING_H
182175
rb_enc_associate(rb_error_msg, rb_utf8_encoding());
183176
rb_enc_associate(rb_sql_state, rb_usascii_encoding());
184-
#endif
185177

186178
e = rb_funcall(cMysql2Error, intern_new_with_args, 4,
187179
rb_error_msg,
@@ -357,9 +349,7 @@ static VALUE rb_mysql_client_escape(RB_MYSQL_UNUSED VALUE klass, VALUE str) {
357349
return str;
358350
} else {
359351
rb_str = rb_str_new((const char*)newStr, newLen);
360-
#ifdef HAVE_RUBY_ENCODING_H
361352
rb_enc_copy(rb_str, str);
362-
#endif
363353
xfree(newStr);
364354
return rb_str;
365355
}
@@ -386,9 +376,7 @@ static VALUE rb_mysql_info(VALUE self) {
386376
}
387377

388378
rb_str = rb_str_new2(info);
389-
#ifdef HAVE_RUBY_ENCODING_H
390379
rb_enc_associate(rb_str, rb_utf8_encoding());
391-
#endif
392380

393381
return rb_str;
394382
}
@@ -406,9 +394,7 @@ static VALUE rb_mysql_get_ssl_cipher(VALUE self)
406394
}
407395

408396
rb_str = rb_str_new2(cipher);
409-
#ifdef HAVE_RUBY_ENCODING_H
410397
rb_enc_associate(rb_str, rb_utf8_encoding());
411-
#endif
412398

413399
return rb_str;
414400
}
@@ -762,12 +748,8 @@ static VALUE rb_query(VALUE self, VALUE sql, VALUE current) {
762748
rb_iv_set(self, "@current_query_options", current);
763749

764750
Check_Type(sql, T_STRING);
765-
#ifdef HAVE_RUBY_ENCODING_H
766751
/* ensure the string is in the encoding the connection is expecting */
767752
args.sql = rb_str_export_to_enc(sql, rb_to_encoding(wrapper->encoding));
768-
#else
769-
args.sql = sql;
770-
#endif
771753
args.sql_ptr = RSTRING_PTR(args.sql);
772754
args.sql_len = RSTRING_LEN(args.sql);
773755
args.wrapper = wrapper;
@@ -804,42 +786,34 @@ static VALUE rb_mysql_client_real_escape(VALUE self, VALUE str) {
804786
unsigned char *newStr;
805787
VALUE rb_str;
806788
unsigned long newLen, oldLen;
807-
#ifdef HAVE_RUBY_ENCODING_H
808789
rb_encoding *default_internal_enc;
809790
rb_encoding *conn_enc;
810-
#endif
811791
GET_CLIENT(self);
812792

813793
REQUIRE_CONNECTED(wrapper);
814794
Check_Type(str, T_STRING);
815-
#ifdef HAVE_RUBY_ENCODING_H
816795
default_internal_enc = rb_default_internal_encoding();
817796
conn_enc = rb_to_encoding(wrapper->encoding);
818797
/* ensure the string is in the encoding the connection is expecting */
819798
str = rb_str_export_to_enc(str, conn_enc);
820-
#endif
821799

822800
oldLen = RSTRING_LEN(str);
823801
newStr = xmalloc(oldLen*2+1);
824802

825803
newLen = mysql_real_escape_string(wrapper->client, (char *)newStr, RSTRING_PTR(str), oldLen);
826804
if (newLen == oldLen) {
827805
/* no need to return a new ruby string if nothing changed */
828-
#ifdef HAVE_RUBY_ENCODING_H
829806
if (default_internal_enc) {
830807
str = rb_str_export_to_enc(str, default_internal_enc);
831808
}
832-
#endif
833809
xfree(newStr);
834810
return str;
835811
} else {
836812
rb_str = rb_str_new((const char*)newStr, newLen);
837-
#ifdef HAVE_RUBY_ENCODING_H
838813
rb_enc_associate(rb_str, conn_enc);
839814
if (default_internal_enc) {
840815
rb_str = rb_str_export_to_enc(rb_str, default_internal_enc);
841816
}
842-
#endif
843817
xfree(newStr);
844818
return rb_str;
845819
}
@@ -950,10 +924,8 @@ static VALUE rb_mysql_client_info(RB_MYSQL_UNUSED VALUE klass) {
950924
version = rb_str_new2(mysql_get_client_info());
951925
header_version = rb_str_new2(MYSQL_LINK_VERSION);
952926

953-
#ifdef HAVE_RUBY_ENCODING_H
954927
rb_enc_associate(version, rb_usascii_encoding());
955928
rb_enc_associate(header_version, rb_usascii_encoding());
956-
#endif
957929

958930
rb_hash_aset(version_info, sym_id, LONG2NUM(mysql_get_client_version()));
959931
rb_hash_aset(version_info, sym_version, version);
@@ -969,27 +941,21 @@ static VALUE rb_mysql_client_info(RB_MYSQL_UNUSED VALUE klass) {
969941
*/
970942
static VALUE rb_mysql_client_server_info(VALUE self) {
971943
VALUE version, server_info;
972-
#ifdef HAVE_RUBY_ENCODING_H
973944
rb_encoding *default_internal_enc;
974945
rb_encoding *conn_enc;
975-
#endif
976946
GET_CLIENT(self);
977947

978948
REQUIRE_CONNECTED(wrapper);
979-
#ifdef HAVE_RUBY_ENCODING_H
980949
default_internal_enc = rb_default_internal_encoding();
981950
conn_enc = rb_to_encoding(wrapper->encoding);
982-
#endif
983951

984952
version = rb_hash_new();
985953
rb_hash_aset(version, sym_id, LONG2FIX(mysql_get_server_version(wrapper->client)));
986954
server_info = rb_str_new2(mysql_get_server_info(wrapper->client));
987-
#ifdef HAVE_RUBY_ENCODING_H
988955
rb_enc_associate(server_info, conn_enc);
989956
if (default_internal_enc) {
990957
server_info = rb_str_export_to_enc(server_info, default_internal_enc);
991958
}
992-
#endif
993959
rb_hash_aset(version, sym_version, server_info);
994960
return version;
995961
}
@@ -1176,7 +1142,6 @@ static VALUE rb_mysql_client_store_result(VALUE self)
11761142
return resultObj;
11771143
}
11781144

1179-
#ifdef HAVE_RUBY_ENCODING_H
11801145
/* call-seq:
11811146
* client.encoding
11821147
*
@@ -1186,7 +1151,6 @@ static VALUE rb_mysql_client_encoding(VALUE self) {
11861151
GET_CLIENT(self);
11871152
return wrapper->encoding;
11881153
}
1189-
#endif
11901154

11911155
/* call-seq:
11921156
* client.automatic_close?
@@ -1272,17 +1236,14 @@ static VALUE set_write_timeout(VALUE self, VALUE value) {
12721236

12731237
static VALUE set_charset_name(VALUE self, VALUE value) {
12741238
char *charset_name;
1275-
#ifdef HAVE_RUBY_ENCODING_H
12761239
const struct mysql2_mysql_enc_name_to_rb_map *mysql2rb;
12771240
rb_encoding *enc;
12781241
VALUE rb_enc;
1279-
#endif
12801242
GET_CLIENT(self);
12811243

12821244
Check_Type(value, T_STRING);
12831245
charset_name = RSTRING_PTR(value);
12841246

1285-
#ifdef HAVE_RUBY_ENCODING_H
12861247
mysql2rb = mysql2_mysql_enc_name_to_rb(charset_name, (unsigned int)RSTRING_LEN(value));
12871248
if (mysql2rb == NULL || mysql2rb->rb_name == NULL) {
12881249
VALUE inspect = rb_inspect(value);
@@ -1292,7 +1253,6 @@ static VALUE set_charset_name(VALUE self, VALUE value) {
12921253
rb_enc = rb_enc_from_encoding(enc);
12931254
wrapper->encoding = rb_enc;
12941255
}
1295-
#endif
12961256

12971257
if (mysql_options(wrapper->client, MYSQL_SET_CHARSET_NAME, charset_name)) {
12981258
/* TODO: warning - unable to set charset */
@@ -1425,9 +1385,7 @@ void init_mysql2_client() {
14251385
rb_define_method(cMysql2Client, "warning_count", rb_mysql_client_warning_count, 0);
14261386
rb_define_method(cMysql2Client, "query_info_string", rb_mysql_info, 0);
14271387
rb_define_method(cMysql2Client, "ssl_cipher", rb_mysql_get_ssl_cipher, 0);
1428-
#ifdef HAVE_RUBY_ENCODING_H
14291388
rb_define_method(cMysql2Client, "encoding", rb_mysql_client_encoding, 0);
1430-
#endif
14311389

14321390
rb_define_private_method(cMysql2Client, "connect_timeout=", set_connect_timeout, 1);
14331391
rb_define_private_method(cMysql2Client, "read_timeout=", set_read_timeout, 1);

ext/mysql2/client.h

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,9 @@
22
#define MYSQL2_CLIENT_H
33

44
#ifndef HAVE_RB_THREAD_CALL_WITHOUT_GVL
5-
#ifdef HAVE_RB_THREAD_BLOCKING_REGION
6-
75
/* emulate rb_thread_call_without_gvl with rb_thread_blocking_region */
86
#define rb_thread_call_without_gvl(func, data1, ubf, data2) \
97
rb_thread_blocking_region((rb_blocking_function_t *)func, data1, ubf, data2)
10-
11-
#else /* ! HAVE_RB_THREAD_BLOCKING_REGION */
12-
/*
13-
* partial emulation of the 2.0 rb_thread_call_without_gvl under 1.8,
14-
* this is enough for dealing with blocking I/O functions in the
15-
* presence of threads.
16-
*/
17-
18-
#include <rubysig.h>
19-
#define RUBY_UBF_IO ((rb_unblock_function_t *)-1)
20-
typedef void rb_unblock_function_t(void *);
21-
static void *
22-
rb_thread_call_without_gvl(
23-
void *(*func)(void *), void *data1,
24-
RB_MYSQL_UNUSED rb_unblock_function_t *ubf,
25-
RB_MYSQL_UNUSED void *data2)
26-
{
27-
void *rv;
28-
29-
TRAP_BEG;
30-
rv = func(data1);
31-
TRAP_END;
32-
33-
return rv;
34-
}
35-
36-
#endif /* ! HAVE_RB_THREAD_BLOCKING_REGION */
378
#endif /* ! HAVE_RB_THREAD_CALL_WITHOUT_GVL */
389

3910
typedef struct {
@@ -60,7 +31,3 @@ void init_mysql2_client(void);
6031
void decr_mysql2_client(mysql_client_wrapper *wrapper);
6132

6233
#endif
63-
64-
#ifndef HAVE_RB_HASH_DUP
65-
VALUE rb_hash_dup(VALUE other);
66-
#endif

ext/mysql2/extconf.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,8 @@ def add_ssl_defines(header)
2929
# 2.0-only
3030
have_header('ruby/thread.h') && have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
3131

32-
# 1.9-only
33-
have_func('rb_thread_blocking_region')
32+
# Missing in RBX (https://github.com/rubinius/rubinius/issues/3771)
3433
have_func('rb_wait_for_single_fd')
35-
have_func('rb_hash_dup')
36-
have_func('rb_intern3')
37-
have_func('rb_big_cmp')
3834

3935
# borrowed from mysqlplus
4036
# http://github.com/oldmoe/mysqlplus/blob/master/ext/extconf.rb

ext/mysql2/mysql2_ext.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ void Init_mysql2(void);
1717
#include <mysql/errmsg.h>
1818
#endif
1919

20-
#ifdef HAVE_RUBY_ENCODING_H
2120
#include <ruby/encoding.h>
22-
#endif
2321
#ifdef HAVE_RUBY_THREAD_H
2422
#include <ruby/thread.h>
2523
#endif

0 commit comments

Comments
 (0)