mysql2 0.5.0-x64-mingw32 → 0.5.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03156f7c22c99424fc4dfcdc8333f2540312ec3d803240712577b3c3fbcaed88
4
- data.tar.gz: 60190283eb939967aac2ad8184cafe17b85c051236177b26e813f6c67be47688
3
+ metadata.gz: c7888e1fd1a0730cff6d698a03a25ed008bf3d1f1f735ea2712f2a7095848e50
4
+ data.tar.gz: 89bec55a2ba4f9850cd25099abccf1830432a49e54a784ff67dbc5e9c26b32b6
5
5
  SHA512:
6
- metadata.gz: 341ef4c8d74e36a4ab39c57cc2b5baeaecdeae9d32854a623215830cf942f3595b7027c203243f97c871b9bc10bf6e7daabdcd186d449b57e06235ecad9ea288
7
- data.tar.gz: e4471cc96ea97cc28c5c03ae3afbcb1525a2e266f9b15e8a3fa395e84a9626fdd1f6dbf6e648100261d8525fb93f72191946f058553d79c0ba2b3b3f6eab7f6f
6
+ metadata.gz: b9b406ea84e6b5cfa1745222d4549479b2d36bf676a621a77926629a368b2ed51cf4a5a0adfb0b814edc482dc028a109d3e9580a678810a63c7844e6d5823d02
7
+ data.tar.gz: 685755ea5d553ff73425bec590c9658a703c9eb69b8327bb4b5cf6858653c7d3b9a21141612cec7a21b0e10c011c2337d5f839bcfc5e2be26ee57c49071c5bc2
data/README.md CHANGED
@@ -178,6 +178,9 @@ Pass your arguments to the execute method in the same number and order as the
178
178
  question marks in the statement. Query options can be passed as keyword arguments
179
179
  to the execute method.
180
180
 
181
+ Be sure to read about the known limitations of prepared statements at
182
+ https://dev.mysql.com/doc/refman/5.6/en/c-api-prepared-statement-problems.html
183
+
181
184
  ``` ruby
182
185
  statement = @client.prepare("SELECT * FROM users WHERE login_count = ?")
183
186
  result1 = statement.execute(1)
@@ -534,6 +537,7 @@ This gem is tested with the following MySQL and MariaDB versions:
534
537
 
535
538
  ### Ruby on Rails / Active Record
536
539
 
540
+ * mysql2 0.5.x works with Rails / Active Record 5.0.7, 5.1.6, and higher.
537
541
  * mysql2 0.4.x works with Rails / Active Record 4.2.5 - 5.0 and higher.
538
542
  * mysql2 0.3.x works with Rails / Active Record 3.1, 3.2, 4.x, 5.0.
539
543
  * mysql2 0.2.x works with Rails / Active Record 2.3 - 3.0.
@@ -63,6 +63,7 @@ if inc && lib
63
63
  abort "-----\nCannot find library dir(s) #{lib}\n-----" unless lib && lib.split(File::PATH_SEPARATOR).any? { |dir| File.directory?(dir) }
64
64
  warn "-----\nUsing --with-mysql-dir=#{File.dirname inc}\n-----"
65
65
  rpath_dir = lib
66
+ have_library('mysqlclient')
66
67
  elsif (mc = (with_config('mysql-config') || Dir[GLOB].first))
67
68
  # If the user has provided a --with-mysql-config argument, we must respect it or fail.
68
69
  # If the user gave --with-mysql-config with no argument means we should try to find it.
@@ -403,6 +403,39 @@ static VALUE rb_mysql_stmt_execute(int argc, VALUE *argv, VALUE self) {
403
403
  }
404
404
  }
405
405
 
406
+ // Duplicate the options hash, merge! extra opts, put the copy into the Result object
407
+ current = rb_hash_dup(rb_iv_get(stmt_wrapper->client, "@query_options"));
408
+ (void)RB_GC_GUARD(current);
409
+ Check_Type(current, T_HASH);
410
+
411
+ // Merge in hash opts/keyword arguments
412
+ if (!NIL_P(opts)) {
413
+ rb_funcall(current, intern_merge_bang, 1, opts);
414
+ }
415
+
416
+ is_streaming = (Qtrue == rb_hash_aref(current, sym_stream));
417
+
418
+ // From stmt_execute to mysql_stmt_result_metadata to stmt_store_result, no
419
+ // Ruby API calls are allowed so that GC is not invoked. If the connection is
420
+ // in results-streaming-mode for Statement A, and in the middle Statement B
421
+ // gets garbage collected, a message will be sent to the server notifying it
422
+ // to release Statement B, resulting in the following error:
423
+ // Commands out of sync; you can't run this command now
424
+ //
425
+ // In streaming mode, statement execute must return a cursor because we
426
+ // cannot prevent other Statement objects from being garbage collected
427
+ // between fetches of each row of the result set. The following error
428
+ // occurs if cursor mode is not set:
429
+ // Row retrieval was canceled by mysql_stmt_close
430
+
431
+ if (is_streaming) {
432
+ unsigned long type = CURSOR_TYPE_READ_ONLY;
433
+ if (mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, &type)) {
434
+ FREE_BINDS;
435
+ rb_raise(cMysql2Error, "Unable to stream prepared statement, could not set CURSOR_TYPE_READ_ONLY");
436
+ }
437
+ }
438
+
406
439
  if ((VALUE)rb_thread_call_without_gvl(nogvl_stmt_execute, stmt, RUBY_UBF_IO, 0) == Qfalse) {
407
440
  FREE_BINDS;
408
441
  rb_raise_mysql2_stmt_error(stmt_wrapper);
@@ -421,17 +454,6 @@ static VALUE rb_mysql_stmt_execute(int argc, VALUE *argv, VALUE self) {
421
454
  return Qnil;
422
455
  }
423
456
 
424
- // Duplicate the options hash, merge! extra opts, put the copy into the Result object
425
- current = rb_hash_dup(rb_iv_get(stmt_wrapper->client, "@query_options"));
426
- (void)RB_GC_GUARD(current);
427
- Check_Type(current, T_HASH);
428
-
429
- // Merge in hash opts/keyword arguments
430
- if (!NIL_P(opts)) {
431
- rb_funcall(current, intern_merge_bang, 1, opts);
432
- }
433
-
434
- is_streaming = (Qtrue == rb_hash_aref(current, sym_stream));
435
457
  if (!is_streaming) {
436
458
  // recieve the whole result set from the server
437
459
  if (mysql_stmt_store_result(stmt)) {
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,2 @@
1
+ RUBY_VERSION =~ /(\d+.\d+)/
2
+ require "mysql2/#{$1}/mysql2"
@@ -1,3 +1,3 @@
1
1
  module Mysql2
2
- VERSION = "0.5.0".freeze
2
+ VERSION = "0.5.1".freeze
3
3
  end
@@ -6,6 +6,10 @@ RSpec.describe Mysql2::Statement do
6
6
  end
7
7
 
8
8
  def stmt_count
9
+ # Use the performance schema in MySQL 5.7 and above
10
+ @client.query("SELECT COUNT(1) AS count FROM performance_schema.prepared_statements_instances").first['count'].to_i
11
+ rescue Mysql2::Error
12
+ # Fall back to the global prepapred statement counter
9
13
  @client.query("SHOW STATUS LIKE 'Prepared_stmt_count'").first['Value'].to_i
10
14
  end
11
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mysql2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: x64-mingw32
6
6
  authors:
7
7
  - Brian Lopez
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-03-20 00:00:00.000000000 Z
12
+ date: 2018-04-11 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: