mysql2 0.2.16-x86-mswin32-60 → 0.2.18-x86-mswin32-60
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +7 -0
- data/CHANGELOG.md +13 -0
- data/ext/mysql2/client.c +30 -22
- data/lib/mysql2/version.rb +1 -1
- metadata +168 -100
data/.travis.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 0.2.18 (December 6th, 2011)
|
4
|
+
* change mysql error detection strategy from using mysql_field_count to the more explicit mysql_errno
|
5
|
+
* bugfix to avoid race condition with active connections that error out
|
6
|
+
* revert back to using xmalloc/xfree for allocations
|
7
|
+
* avoid potentially unsafe Ruby C API usage w/o GVL
|
8
|
+
* reacquire GVL before retrying on EINTR on connect
|
9
|
+
|
10
|
+
## 0.2.17 (November 9th, 2011)
|
11
|
+
|
12
|
+
## 0.2.16 (November 9th, 2011)
|
13
|
+
|
14
|
+
## 0.2.15 (November 9th, 2011)
|
15
|
+
|
3
16
|
## 0.2.14 (November 9th, 2011)
|
4
17
|
* use rb_wait_for_single_fd() if available
|
5
18
|
* fixed a bug with inheriting query options
|
data/ext/mysql2/client.c
CHANGED
@@ -46,6 +46,8 @@ struct nogvl_connect_args {
|
|
46
46
|
struct nogvl_send_query_args {
|
47
47
|
MYSQL *mysql;
|
48
48
|
VALUE sql;
|
49
|
+
const char *sql_ptr;
|
50
|
+
long sql_len;
|
49
51
|
mysql_client_wrapper *wrapper;
|
50
52
|
};
|
51
53
|
|
@@ -112,12 +114,10 @@ static VALUE nogvl_connect(void *ptr) {
|
|
112
114
|
struct nogvl_connect_args *args = ptr;
|
113
115
|
MYSQL *client;
|
114
116
|
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
args->client_flag);
|
120
|
-
} while (! client && errno == EINTR && (errno = 0) == 0);
|
117
|
+
client = mysql_real_connect(args->mysql, args->host,
|
118
|
+
args->user, args->passwd,
|
119
|
+
args->db, args->port, args->unix_socket,
|
120
|
+
args->client_flag);
|
121
121
|
|
122
122
|
return client ? Qtrue : Qfalse;
|
123
123
|
}
|
@@ -147,7 +147,7 @@ static VALUE nogvl_close(void *ptr) {
|
|
147
147
|
#endif
|
148
148
|
|
149
149
|
mysql_close(wrapper->client);
|
150
|
-
|
150
|
+
xfree(wrapper->client);
|
151
151
|
}
|
152
152
|
|
153
153
|
return Qnil;
|
@@ -158,7 +158,7 @@ static void rb_mysql_client_free(void * ptr) {
|
|
158
158
|
|
159
159
|
nogvl_close(wrapper);
|
160
160
|
|
161
|
-
|
161
|
+
xfree(ptr);
|
162
162
|
}
|
163
163
|
|
164
164
|
static VALUE allocate(VALUE klass) {
|
@@ -169,7 +169,7 @@ static VALUE allocate(VALUE klass) {
|
|
169
169
|
wrapper->active = 0;
|
170
170
|
wrapper->reconnect_enabled = 0;
|
171
171
|
wrapper->closed = 1;
|
172
|
-
wrapper->client = (MYSQL*)
|
172
|
+
wrapper->client = (MYSQL*)xmalloc(sizeof(MYSQL));
|
173
173
|
return obj;
|
174
174
|
}
|
175
175
|
|
@@ -181,25 +181,26 @@ static VALUE rb_mysql_client_escape(RB_MYSQL_UNUSED VALUE klass, VALUE str) {
|
|
181
181
|
Check_Type(str, T_STRING);
|
182
182
|
|
183
183
|
oldLen = RSTRING_LEN(str);
|
184
|
-
newStr =
|
184
|
+
newStr = xmalloc(oldLen*2+1);
|
185
185
|
|
186
186
|
newLen = mysql_escape_string((char *)newStr, StringValuePtr(str), oldLen);
|
187
187
|
if (newLen == oldLen) {
|
188
188
|
// no need to return a new ruby string if nothing changed
|
189
|
-
|
189
|
+
xfree(newStr);
|
190
190
|
return str;
|
191
191
|
} else {
|
192
192
|
rb_str = rb_str_new((const char*)newStr, newLen);
|
193
193
|
#ifdef HAVE_RUBY_ENCODING_H
|
194
194
|
rb_enc_copy(rb_str, str);
|
195
195
|
#endif
|
196
|
-
|
196
|
+
xfree(newStr);
|
197
197
|
return rb_str;
|
198
198
|
}
|
199
199
|
}
|
200
200
|
|
201
201
|
static VALUE rb_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE port, VALUE database, VALUE socket, VALUE flags) {
|
202
202
|
struct nogvl_connect_args args;
|
203
|
+
VALUE rv;
|
203
204
|
GET_CLIENT(self);
|
204
205
|
|
205
206
|
args.host = NIL_P(host) ? "localhost" : StringValuePtr(host);
|
@@ -211,9 +212,14 @@ static VALUE rb_connect(VALUE self, VALUE user, VALUE pass, VALUE host, VALUE po
|
|
211
212
|
args.mysql = wrapper->client;
|
212
213
|
args.client_flag = NUM2ULONG(flags);
|
213
214
|
|
214
|
-
|
215
|
-
|
216
|
-
|
215
|
+
rv = rb_thread_blocking_region(nogvl_connect, &args, RUBY_UBF_IO, 0);
|
216
|
+
if (rv == Qfalse) {
|
217
|
+
while (rv == Qfalse && errno == EINTR) {
|
218
|
+
errno = 0;
|
219
|
+
rv = rb_thread_blocking_region(nogvl_connect, &args, RUBY_UBF_IO, 0);
|
220
|
+
}
|
221
|
+
if (rv == Qfalse)
|
222
|
+
return rb_raise_mysql2_error(wrapper);
|
217
223
|
}
|
218
224
|
|
219
225
|
return self;
|
@@ -243,10 +249,8 @@ static VALUE rb_mysql_client_close(VALUE self) {
|
|
243
249
|
static VALUE nogvl_send_query(void *ptr) {
|
244
250
|
struct nogvl_send_query_args *args = ptr;
|
245
251
|
int rv;
|
246
|
-
const char *sql = StringValuePtr(args->sql);
|
247
|
-
long sql_len = RSTRING_LEN(args->sql);
|
248
252
|
|
249
|
-
rv = mysql_send_query(args->mysql,
|
253
|
+
rv = mysql_send_query(args->mysql, args->sql_ptr, args->sql_len);
|
250
254
|
|
251
255
|
return rv == 0 ? Qtrue : Qfalse;
|
252
256
|
}
|
@@ -311,9 +315,11 @@ static VALUE rb_mysql_client_async_result(VALUE self) {
|
|
311
315
|
result = (MYSQL_RES *)rb_thread_blocking_region(nogvl_store_result, wrapper, RUBY_UBF_IO, 0);
|
312
316
|
|
313
317
|
if (result == NULL) {
|
314
|
-
if (
|
318
|
+
if (mysql_errno(wrapper->client) != 0) {
|
319
|
+
MARK_CONN_INACTIVE(self);
|
315
320
|
rb_raise_mysql2_error(wrapper);
|
316
321
|
}
|
322
|
+
// no data and no error, so query was not a SELECT
|
317
323
|
return Qnil;
|
318
324
|
}
|
319
325
|
|
@@ -450,6 +456,8 @@ static VALUE rb_mysql_client_query(int argc, VALUE * argv, VALUE self) {
|
|
450
456
|
// ensure the string is in the encoding the connection is expecting
|
451
457
|
args.sql = rb_str_export_to_enc(args.sql, conn_enc);
|
452
458
|
#endif
|
459
|
+
args.sql_ptr = StringValuePtr(args.sql);
|
460
|
+
args.sql_len = RSTRING_LEN(args.sql);
|
453
461
|
|
454
462
|
// see if this connection is still waiting on a result from a previous query
|
455
463
|
if (wrapper->active == 0) {
|
@@ -502,12 +510,12 @@ static VALUE rb_mysql_client_real_escape(VALUE self, VALUE str) {
|
|
502
510
|
#endif
|
503
511
|
|
504
512
|
oldLen = RSTRING_LEN(str);
|
505
|
-
newStr =
|
513
|
+
newStr = xmalloc(oldLen*2+1);
|
506
514
|
|
507
515
|
newLen = mysql_real_escape_string(wrapper->client, (char *)newStr, StringValuePtr(str), oldLen);
|
508
516
|
if (newLen == oldLen) {
|
509
517
|
// no need to return a new ruby string if nothing changed
|
510
|
-
|
518
|
+
xfree(newStr);
|
511
519
|
return str;
|
512
520
|
} else {
|
513
521
|
rb_str = rb_str_new((const char*)newStr, newLen);
|
@@ -517,7 +525,7 @@ static VALUE rb_mysql_client_real_escape(VALUE self, VALUE str) {
|
|
517
525
|
rb_str = rb_str_export_to_enc(rb_str, default_internal_enc);
|
518
526
|
}
|
519
527
|
#endif
|
520
|
-
|
528
|
+
xfree(newStr);
|
521
529
|
return rb_str;
|
522
530
|
}
|
523
531
|
}
|
data/lib/mysql2/version.rb
CHANGED
metadata
CHANGED
@@ -1,124 +1,176 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mysql2
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 51
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 18
|
10
|
+
segments_generated: true
|
11
|
+
version: 0.2.18
|
6
12
|
platform: x86-mswin32-60
|
7
|
-
authors:
|
13
|
+
authors:
|
8
14
|
- Brian Lopez
|
9
15
|
autorequire:
|
10
16
|
bindir: bin
|
11
17
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
18
|
+
|
19
|
+
date: 2011-12-06 00:00:00 -08:00
|
20
|
+
default_executable:
|
21
|
+
dependencies:
|
22
|
+
- !ruby/object:Gem::Dependency
|
15
23
|
name: eventmachine
|
16
|
-
requirement: &
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
25
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
|
22
|
-
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
segments_generated: true
|
33
|
+
version: "0"
|
23
34
|
prerelease: false
|
24
|
-
|
25
|
-
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
26
38
|
name: rake-compiler
|
27
|
-
requirement: &
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
40
|
none: false
|
29
|
-
requirements:
|
41
|
+
requirements:
|
30
42
|
- - ~>
|
31
|
-
- !ruby/object:Gem::Version
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 13
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
- 7
|
48
|
+
- 7
|
49
|
+
segments_generated: true
|
32
50
|
version: 0.7.7
|
33
|
-
type: :development
|
34
51
|
prerelease: false
|
35
|
-
|
36
|
-
|
52
|
+
type: :development
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
37
55
|
name: rake
|
38
|
-
requirement: &
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
57
|
none: false
|
40
|
-
requirements:
|
41
|
-
- - =
|
42
|
-
- !ruby/object:Gem::Version
|
58
|
+
requirements:
|
59
|
+
- - "="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 49
|
62
|
+
segments:
|
63
|
+
- 0
|
64
|
+
- 8
|
65
|
+
- 7
|
66
|
+
segments_generated: true
|
43
67
|
version: 0.8.7
|
44
|
-
type: :development
|
45
68
|
prerelease: false
|
46
|
-
|
47
|
-
|
69
|
+
type: :development
|
70
|
+
version_requirements: *id003
|
71
|
+
- !ruby/object:Gem::Dependency
|
48
72
|
name: rspec
|
49
|
-
requirement: &
|
73
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
74
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
55
|
-
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
segments_generated: true
|
82
|
+
version: "0"
|
56
83
|
prerelease: false
|
57
|
-
|
58
|
-
|
84
|
+
type: :development
|
85
|
+
version_requirements: *id004
|
86
|
+
- !ruby/object:Gem::Dependency
|
59
87
|
name: activerecord
|
60
|
-
requirement: &
|
88
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
61
89
|
none: false
|
62
|
-
requirements:
|
63
|
-
- -
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
|
66
|
-
|
90
|
+
requirements:
|
91
|
+
- - ">="
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
hash: 3
|
94
|
+
segments:
|
95
|
+
- 0
|
96
|
+
segments_generated: true
|
97
|
+
version: "0"
|
67
98
|
prerelease: false
|
68
|
-
|
69
|
-
|
99
|
+
type: :development
|
100
|
+
version_requirements: *id005
|
101
|
+
- !ruby/object:Gem::Dependency
|
70
102
|
name: mysql
|
71
|
-
requirement: &
|
103
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
72
104
|
none: false
|
73
|
-
requirements:
|
74
|
-
- -
|
75
|
-
- !ruby/object:Gem::Version
|
76
|
-
|
77
|
-
|
105
|
+
requirements:
|
106
|
+
- - ">="
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
hash: 3
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
segments_generated: true
|
112
|
+
version: "0"
|
78
113
|
prerelease: false
|
79
|
-
|
80
|
-
|
114
|
+
type: :development
|
115
|
+
version_requirements: *id006
|
116
|
+
- !ruby/object:Gem::Dependency
|
81
117
|
name: do_mysql
|
82
|
-
requirement: &
|
118
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
83
119
|
none: false
|
84
|
-
requirements:
|
85
|
-
- -
|
86
|
-
- !ruby/object:Gem::Version
|
87
|
-
|
88
|
-
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 3
|
124
|
+
segments:
|
125
|
+
- 0
|
126
|
+
segments_generated: true
|
127
|
+
version: "0"
|
89
128
|
prerelease: false
|
90
|
-
|
91
|
-
|
129
|
+
type: :development
|
130
|
+
version_requirements: *id007
|
131
|
+
- !ruby/object:Gem::Dependency
|
92
132
|
name: sequel
|
93
|
-
requirement: &
|
133
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
94
134
|
none: false
|
95
|
-
requirements:
|
96
|
-
- -
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
|
99
|
-
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
hash: 3
|
139
|
+
segments:
|
140
|
+
- 0
|
141
|
+
segments_generated: true
|
142
|
+
version: "0"
|
100
143
|
prerelease: false
|
101
|
-
|
102
|
-
|
144
|
+
type: :development
|
145
|
+
version_requirements: *id008
|
146
|
+
- !ruby/object:Gem::Dependency
|
103
147
|
name: faker
|
104
|
-
requirement: &
|
148
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
105
149
|
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
110
|
-
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
hash: 3
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
segments_generated: true
|
157
|
+
version: "0"
|
111
158
|
prerelease: false
|
112
|
-
|
159
|
+
type: :development
|
160
|
+
version_requirements: *id009
|
113
161
|
description:
|
114
162
|
email: seniorlopez@gmail.com
|
115
163
|
executables: []
|
164
|
+
|
116
165
|
extensions: []
|
166
|
+
|
117
167
|
extra_rdoc_files: []
|
118
|
-
|
168
|
+
|
169
|
+
files:
|
119
170
|
- .gitignore
|
120
171
|
- .rspec
|
121
172
|
- .rvmrc
|
173
|
+
- .travis.yml
|
122
174
|
- CHANGELOG.md
|
123
175
|
- Gemfile
|
124
176
|
- MIT-LICENSE
|
@@ -169,43 +221,59 @@ files:
|
|
169
221
|
- lib/mysql2/1.8/mysql2.so
|
170
222
|
- lib/mysql2/1.9/mysql2.so
|
171
223
|
- lib/mysql2/mysql2.rb
|
224
|
+
has_rdoc: true
|
172
225
|
homepage: http://github.com/brianmario/mysql2
|
173
226
|
licenses: []
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
227
|
+
|
228
|
+
post_install_message: |+
|
229
|
+
|
230
|
+
======================================================================================================
|
231
|
+
|
232
|
+
You've installed the binary version of mysql2.
|
233
|
+
It was built using MySQL Connector/C version 6.0.2.
|
234
|
+
It's recommended to use the exact same version to avoid potential issues.
|
235
|
+
|
236
|
+
At the time of building this gem, the necessary DLL files where available
|
237
|
+
in the following download:
|
238
|
+
|
239
|
+
http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
|
240
|
+
|
241
|
+
And put lib\libmysql.dll file in your Ruby bin directory, for example C:\Ruby\bin
|
242
|
+
|
243
|
+
======================================================================================================
|
244
|
+
|
245
|
+
rdoc_options:
|
181
246
|
- --charset=UTF-8
|
182
|
-
require_paths:
|
247
|
+
require_paths:
|
183
248
|
- lib
|
184
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
249
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
185
250
|
none: false
|
186
|
-
requirements:
|
187
|
-
- -
|
188
|
-
- !ruby/object:Gem::Version
|
189
|
-
|
190
|
-
segments:
|
251
|
+
requirements:
|
252
|
+
- - ">="
|
253
|
+
- !ruby/object:Gem::Version
|
254
|
+
hash: 3
|
255
|
+
segments:
|
191
256
|
- 0
|
192
|
-
|
193
|
-
|
257
|
+
segments_generated: true
|
258
|
+
version: "0"
|
259
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
194
260
|
none: false
|
195
|
-
requirements:
|
196
|
-
- -
|
197
|
-
- !ruby/object:Gem::Version
|
198
|
-
|
199
|
-
segments:
|
261
|
+
requirements:
|
262
|
+
- - ">="
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
hash: 3
|
265
|
+
segments:
|
200
266
|
- 0
|
201
|
-
|
267
|
+
segments_generated: true
|
268
|
+
version: "0"
|
202
269
|
requirements: []
|
270
|
+
|
203
271
|
rubyforge_project:
|
204
|
-
rubygems_version: 1.
|
272
|
+
rubygems_version: 1.3.9.3
|
205
273
|
signing_key:
|
206
274
|
specification_version: 3
|
207
275
|
summary: A simple, fast Mysql library for Ruby, binding to libmysql
|
208
|
-
test_files:
|
276
|
+
test_files:
|
209
277
|
- examples/eventmachine.rb
|
210
278
|
- examples/threaded.rb
|
211
279
|
- spec/em/em_fiber_spec.rb
|