mysql2 0.3.9-x86-mingw32 → 0.3.11-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.11 (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.3.10 (November 9th, 2011)
11
+
12
+ ## 0.3.9 (November 9th, 2011)
13
+
3
14
  ## 0.3.8 (November 9th, 2011)
4
15
  * remove fiber support from mysql2, the code has moved to the
5
16
  em-synchrony gem.
@@ -44,6 +55,19 @@
44
55
  * BREAKING CHANGE: the ActiveRecord adapter has been pulled into Rails 3.1 and is no longer part of the gem
45
56
  * added Mysql2::Client.escape (class-level) for raw one-off non-encoding-aware escaping
46
57
 
58
+ ## 0.2.18 (December 6th, 2011)
59
+ * change mysql error detection strategy from using mysql_field_count to the more explicit mysql_errno
60
+ * bugfix to avoid race condition with active connections that error out
61
+ * revert back to using xmalloc/xfree for allocations
62
+ * avoid potentially unsafe Ruby C API usage w/o GVL
63
+ * reacquire GVL before retrying on EINTR on connect
64
+
65
+ ## 0.2.17 (November 9th, 2011)
66
+
67
+ ## 0.2.16 (November 9th, 2011)
68
+
69
+ ## 0.2.15 (November 9th, 2011)
70
+
47
71
  ## 0.2.14 (November 9th, 2011)
48
72
  * use rb_wait_for_single_fd() if available
49
73
  * fixed a bug with inheriting query options
data/README.md CHANGED
@@ -317,6 +317,15 @@ bundle install
317
317
  rake
318
318
  ```
319
319
 
320
+ The tests require the "test" database to exist, and expect to connect
321
+ both as root and the running user, both with a blank password:
322
+
323
+ ``` sql
324
+ CREATE DATABASE test;
325
+ CREATE USER '<user>'@'localhost' IDENTIFIED BY '';
326
+ GRANT ALL PRIVILEGES ON test.* TO '<user>'@'localhost';
327
+ ```
328
+
320
329
  ## Special Thanks
321
330
 
322
331
  * Eric Wong - for the contribution (and the informative explanations) of some thread-safety, non-blocking I/O and cleanup patches. You rock dude
@@ -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
- do {
116
- client = mysql_real_connect(args->mysql, args->host,
117
- args->user, args->passwd,
118
- args->db, args->port, args->unix_socket,
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
- free(wrapper->client);
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
- free(ptr);
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*)malloc(sizeof(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 = malloc(oldLen*2+1);
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
- free(newStr);
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
- free(newStr);
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
- if (rb_thread_blocking_region(nogvl_connect, &args, RUBY_UBF_IO, 0) == Qfalse) {
215
- // unable to connect
216
- return rb_raise_mysql2_error(wrapper);
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, sql, sql_len);
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 (mysql_field_count(wrapper->client) != 0) {
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 = malloc(oldLen*2+1);
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
- free(newStr);
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
- free(newStr);
528
+ xfree(newStr);
521
529
  return rb_str;
522
530
  }
523
531
  }
@@ -80,7 +80,7 @@ static void rb_mysql_result_free(void * wrapper) {
80
80
  mysql2_result_wrapper * w = wrapper;
81
81
  /* FIXME: this may call flush_use_result, which can hit the socket */
82
82
  rb_mysql_result_free_result(w);
83
- free(wrapper);
83
+ xfree(wrapper);
84
84
  }
85
85
 
86
86
  /*
@@ -1,3 +1,3 @@
1
1
  module Mysql2
2
- VERSION = "0.3.9"
2
+ VERSION = "0.3.11"
3
3
  end
metadata CHANGED
@@ -1,121 +1,172 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: mysql2
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.9
3
+ version: !ruby/object:Gem::Version
4
+ hash: 5
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 3
9
+ - 11
10
+ segments_generated: true
11
+ version: 0.3.11
6
12
  platform: x86-mingw32
7
- authors:
13
+ authors:
8
14
  - Brian Lopez
9
15
  autorequire:
10
16
  bindir: bin
11
17
  cert_chain: []
12
- date: 2011-11-09 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
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: &70366941834500 !ruby/object:Gem::Requirement
24
+ requirement: &id001 !ruby/object:Gem::Requirement
17
25
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
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
- version_requirements: *70366941834500
25
- - !ruby/object:Gem::Dependency
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
26
38
  name: rake-compiler
27
- requirement: &70366941832980 !ruby/object:Gem::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
- version_requirements: *70366941832980
36
- - !ruby/object:Gem::Dependency
52
+ type: :development
53
+ version_requirements: *id002
54
+ - !ruby/object:Gem::Dependency
37
55
  name: rake
38
- requirement: &70366941831480 !ruby/object:Gem::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
- version_requirements: *70366941831480
47
- - !ruby/object:Gem::Dependency
69
+ type: :development
70
+ version_requirements: *id003
71
+ - !ruby/object:Gem::Dependency
48
72
  name: rspec
49
- requirement: &70366941830420 !ruby/object:Gem::Requirement
73
+ requirement: &id004 !ruby/object:Gem::Requirement
50
74
  none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :development
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
- version_requirements: *70366941830420
58
- - !ruby/object:Gem::Dependency
84
+ type: :development
85
+ version_requirements: *id004
86
+ - !ruby/object:Gem::Dependency
59
87
  name: activerecord
60
- requirement: &70366941829400 !ruby/object:Gem::Requirement
88
+ requirement: &id005 !ruby/object:Gem::Requirement
61
89
  none: false
62
- requirements:
63
- - - ! '>='
64
- - !ruby/object:Gem::Version
65
- version: '0'
66
- type: :development
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
- version_requirements: *70366941829400
69
- - !ruby/object:Gem::Dependency
99
+ type: :development
100
+ version_requirements: *id005
101
+ - !ruby/object:Gem::Dependency
70
102
  name: mysql
71
- requirement: &70366941828800 !ruby/object:Gem::Requirement
103
+ requirement: &id006 !ruby/object:Gem::Requirement
72
104
  none: false
73
- requirements:
74
- - - ! '>='
75
- - !ruby/object:Gem::Version
76
- version: '0'
77
- type: :development
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
- version_requirements: *70366941828800
80
- - !ruby/object:Gem::Dependency
114
+ type: :development
115
+ version_requirements: *id006
116
+ - !ruby/object:Gem::Dependency
81
117
  name: do_mysql
82
- requirement: &70366941828320 !ruby/object:Gem::Requirement
118
+ requirement: &id007 !ruby/object:Gem::Requirement
83
119
  none: false
84
- requirements:
85
- - - ! '>='
86
- - !ruby/object:Gem::Version
87
- version: '0'
88
- type: :development
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
- version_requirements: *70366941828320
91
- - !ruby/object:Gem::Dependency
129
+ type: :development
130
+ version_requirements: *id007
131
+ - !ruby/object:Gem::Dependency
92
132
  name: sequel
93
- requirement: &70366941827760 !ruby/object:Gem::Requirement
133
+ requirement: &id008 !ruby/object:Gem::Requirement
94
134
  none: false
95
- requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0'
99
- type: :development
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
- version_requirements: *70366941827760
102
- - !ruby/object:Gem::Dependency
144
+ type: :development
145
+ version_requirements: *id008
146
+ - !ruby/object:Gem::Dependency
103
147
  name: faker
104
- requirement: &70366941827060 !ruby/object:Gem::Requirement
148
+ requirement: &id009 !ruby/object:Gem::Requirement
105
149
  none: false
106
- requirements:
107
- - - ! '>='
108
- - !ruby/object:Gem::Version
109
- version: '0'
110
- type: :development
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
- version_requirements: *70366941827060
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
- files:
168
+
169
+ files:
119
170
  - .gitignore
120
171
  - .rspec
121
172
  - .rvmrc
@@ -164,43 +215,59 @@ files:
164
215
  - lib/mysql2/1.8/mysql2.so
165
216
  - lib/mysql2/1.9/mysql2.so
166
217
  - lib/mysql2/mysql2.rb
218
+ has_rdoc: true
167
219
  homepage: http://github.com/brianmario/mysql2
168
220
  licenses: []
169
- post_install_message: ! "\n======================================================================================================\n\n
170
- \ You've installed the binary version of mysql2.\n It was built using MySQL Connector/C
171
- version 6.0.2.\n It's recommended to use the exact same version to avoid potential
172
- issues.\n\n At the time of building this gem, the necessary DLL files where available\n
173
- \ in the following download:\n\n http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick\n\n
174
- \ And put lib\\libmysql.dll file in your Ruby bin directory, for example C:\\Ruby\\bin\n\n======================================================================================================\n\n"
175
- rdoc_options:
221
+
222
+ post_install_message: |+
223
+
224
+ ======================================================================================================
225
+
226
+ You've installed the binary version of mysql2.
227
+ It was built using MySQL Connector/C version 6.0.2.
228
+ It's recommended to use the exact same version to avoid potential issues.
229
+
230
+ At the time of building this gem, the necessary DLL files where available
231
+ in the following download:
232
+
233
+ http://dev.mysql.com/get/Downloads/Connector-C/mysql-connector-c-noinstall-6.0.2-win32.zip/from/pick
234
+
235
+ And put lib\libmysql.dll file in your Ruby bin directory, for example C:\Ruby\bin
236
+
237
+ ======================================================================================================
238
+
239
+ rdoc_options:
176
240
  - --charset=UTF-8
177
- require_paths:
241
+ require_paths:
178
242
  - lib
179
- required_ruby_version: !ruby/object:Gem::Requirement
243
+ required_ruby_version: !ruby/object:Gem::Requirement
180
244
  none: false
181
- requirements:
182
- - - ! '>='
183
- - !ruby/object:Gem::Version
184
- version: '0'
185
- segments:
245
+ requirements:
246
+ - - ">="
247
+ - !ruby/object:Gem::Version
248
+ hash: 3
249
+ segments:
186
250
  - 0
187
- hash: 4509010119636737419
188
- required_rubygems_version: !ruby/object:Gem::Requirement
251
+ segments_generated: true
252
+ version: "0"
253
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
254
  none: false
190
- requirements:
191
- - - ! '>='
192
- - !ruby/object:Gem::Version
193
- version: '0'
194
- segments:
255
+ requirements:
256
+ - - ">="
257
+ - !ruby/object:Gem::Version
258
+ hash: 3
259
+ segments:
195
260
  - 0
196
- hash: 4509010119636737419
261
+ segments_generated: true
262
+ version: "0"
197
263
  requirements: []
264
+
198
265
  rubyforge_project:
199
- rubygems_version: 1.8.10
266
+ rubygems_version: 1.3.9.3
200
267
  signing_key:
201
268
  specification_version: 3
202
269
  summary: A simple, fast Mysql library for Ruby, binding to libmysql
203
- test_files:
270
+ test_files:
204
271
  - examples/eventmachine.rb
205
272
  - examples/threaded.rb
206
273
  - spec/em/em_spec.rb