Hello community,

here is the log from the commit of package rubygem-mysql2 for openSUSE:Factory 
checked in at 2015-08-01 11:39:11
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/rubygem-mysql2 (Old)
 and      /work/SRC/openSUSE:Factory/.rubygem-mysql2.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "rubygem-mysql2"

Changes:
--------
--- /work/SRC/openSUSE:Factory/rubygem-mysql2/rubygem-mysql2.changes    
2015-04-07 09:29:36.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.rubygem-mysql2.new/rubygem-mysql2.changes       
2015-08-01 11:39:12.000000000 +0200
@@ -1,0 +2,6 @@
+Fri Jul 31 04:31:15 UTC 2015 - [email protected]
+
+- updated to version 0.3.19
+  no changelog found
+
+-------------------------------------------------------------------

Old:
----
  mysql2-0.3.18.gem

New:
----
  mysql2-0.3.19.gem

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ rubygem-mysql2.spec ++++++
--- /var/tmp/diff_new_pack.T8av4a/_old  2015-08-01 11:39:12.000000000 +0200
+++ /var/tmp/diff_new_pack.T8av4a/_new  2015-08-01 11:39:12.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package rubygem-mysql2
 #
-# Copyright (c) 2015 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -24,7 +24,7 @@
 #
 
 Name:           rubygem-mysql2
-Version:        0.3.18
+Version:        0.3.19
 Release:        0
 %define mod_name mysql2
 %define mod_full_name %{mod_name}-%{version}
@@ -32,10 +32,10 @@
 BuildRequires:  mysql-devel
 # /MANUAL
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
-BuildRequires:  ruby-macros >= 5
 BuildRequires:  %{rubydevel}
 BuildRequires:  %{rubygem gem2rpm}
 BuildRequires:  %{rubygem rdoc > 3.10}
+BuildRequires:  ruby-macros >= 5
 Url:            http://github.com/brianmario/mysql2
 Source:         http://rubygems.org/gems/%{mod_full_name}.gem
 Source1:        rubygem-mysql2-rpmlintrc
@@ -53,7 +53,7 @@
 
 %install
 %gem_install \
-  --doc-files="README.md" \
+  --doc-files="LICENSE README.md" \
   -f
 %gem_cleanup
 

++++++ mysql2-0.3.18.gem -> mysql2-0.3.19.gem ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/LICENSE new/LICENSE
--- old/LICENSE 1970-01-01 01:00:00.000000000 +0100
+++ new/LICENSE 1970-01-01 01:00:00.000000000 +0100
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2014 Brian Lopez
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
Files old/checksums.yaml.gz and new/checksums.yaml.gz differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ext/mysql2/client.c new/ext/mysql2/client.c
--- old/ext/mysql2/client.c     1970-01-01 01:00:00.000000000 +0100
+++ new/ext/mysql2/client.c     1970-01-01 01:00:00.000000000 +0100
@@ -16,7 +16,7 @@
 
 VALUE cMysql2Client;
 extern VALUE mMysql2, cMysql2Error;
-static VALUE sym_id, sym_version, sym_async, sym_symbolize_keys, sym_as, 
sym_array, sym_stream;
+static VALUE sym_id, sym_version, sym_header_version, sym_async, 
sym_symbolize_keys, sym_as, sym_array, sym_stream;
 static ID intern_merge, intern_merge_bang, intern_error_number_eql, 
intern_sql_state_eql;
 
 #ifndef HAVE_RB_HASH_DUP
@@ -287,7 +287,7 @@
   oldLen = RSTRING_LEN(str);
   newStr = xmalloc(oldLen*2+1);
 
-  newLen = mysql_escape_string((char *)newStr, StringValuePtr(str), oldLen);
+  newLen = mysql_escape_string((char *)newStr, RSTRING_PTR(str), oldLen);
   if (newLen == oldLen) {
     /* no need to return a new ruby string if nothing changed */
     xfree(newStr);
@@ -337,13 +337,13 @@
   VALUE rv;
   GET_CLIENT(self);
 
-  args.host = NIL_P(host) ? NULL : StringValuePtr(host);
-  args.unix_socket = NIL_P(socket) ? NULL : StringValuePtr(socket);
-  args.port = NIL_P(port) ? 0 : NUM2INT(port);
-  args.user = NIL_P(user) ? NULL : StringValuePtr(user);
-  args.passwd = NIL_P(pass) ? NULL : StringValuePtr(pass);
-  args.db = NIL_P(database) ? NULL : StringValuePtr(database);
-  args.mysql = wrapper->client;
+  args.host        = NIL_P(host)     ? NULL : StringValueCStr(host);
+  args.unix_socket = NIL_P(socket)   ? NULL : StringValueCStr(socket);
+  args.port        = NIL_P(port)     ? 0    : NUM2INT(port);
+  args.user        = NIL_P(user)     ? NULL : StringValueCStr(user);
+  args.passwd      = NIL_P(pass)     ? NULL : StringValueCStr(pass);
+  args.db          = NIL_P(database) ? NULL : StringValueCStr(database);
+  args.mysql       = wrapper->client;
   args.client_flag = NUM2ULONG(flags);
 
   if (wrapper->connect_timeout)
@@ -669,7 +669,7 @@
   /* ensure the string is in the encoding the connection is expecting */
   args.sql = rb_str_export_to_enc(args.sql, conn_enc);
 #endif
-  args.sql_ptr = StringValuePtr(args.sql);
+  args.sql_ptr = RSTRING_PTR(args.sql);
   args.sql_len = RSTRING_LEN(args.sql);
 
   /* see if this connection is still waiting on a result from a previous query 
*/
@@ -736,9 +736,14 @@
   oldLen = RSTRING_LEN(str);
   newStr = xmalloc(oldLen*2+1);
 
-  newLen = mysql_real_escape_string(wrapper->client, (char *)newStr, 
StringValuePtr(str), oldLen);
+  newLen = mysql_real_escape_string(wrapper->client, (char *)newStr, 
RSTRING_PTR(str), oldLen);
   if (newLen == oldLen) {
     /* no need to return a new ruby string if nothing changed */
+#ifdef HAVE_RUBY_ENCODING_H
+    if (default_internal_enc) {
+      str = rb_str_export_to_enc(str, default_internal_enc);
+    }
+#endif
     xfree(newStr);
     return str;
   } else {
@@ -800,17 +805,17 @@
       break;
 
     case MYSQL_READ_DEFAULT_FILE:
-      charval = (const char *)StringValuePtr(value);
+      charval = (const char *)StringValueCStr(value);
       retval  = charval;
       break;
 
     case MYSQL_READ_DEFAULT_GROUP:
-      charval = (const char *)StringValuePtr(value);
+      charval = (const char *)StringValueCStr(value);
       retval  = charval;
       break;
 
     case MYSQL_INIT_COMMAND:
-      charval = (const char *)StringValuePtr(value);
+      charval = (const char *)StringValueCStr(value);
       retval  = charval;
       break;
 
@@ -843,30 +848,23 @@
  *
  * Returns a string that represents the client library version.
  */
-static VALUE rb_mysql_client_info(VALUE self) {
-  VALUE version, client_info;
-#ifdef HAVE_RUBY_ENCODING_H
-  rb_encoding *default_internal_enc;
-  rb_encoding *conn_enc;
-  GET_CLIENT(self);
-#endif
-  version = rb_hash_new();
+static VALUE rb_mysql_client_info(RB_MYSQL_UNUSED VALUE klass) {
+  VALUE version_info, version, header_version;
+  version_info = rb_hash_new();
 
-#ifdef HAVE_RUBY_ENCODING_H
-  default_internal_enc = rb_default_internal_encoding();
-  conn_enc = rb_to_encoding(wrapper->encoding);
-#endif
+  version = rb_str_new2(mysql_get_client_info());
+  header_version = rb_str_new2(MYSQL_LINK_VERSION);
 
-  rb_hash_aset(version, sym_id, LONG2NUM(mysql_get_client_version()));
-  client_info = rb_str_new2(mysql_get_client_info());
 #ifdef HAVE_RUBY_ENCODING_H
-  rb_enc_associate(client_info, conn_enc);
-  if (default_internal_enc) {
-    client_info = rb_str_export_to_enc(client_info, default_internal_enc);
-  }
+  rb_enc_associate(version, rb_usascii_encoding());
+  rb_enc_associate(header_version, rb_usascii_encoding());
 #endif
-  rb_hash_aset(version, sym_version, client_info);
-  return version;
+
+  rb_hash_aset(version_info, sym_id, LONG2NUM(mysql_get_client_version()));
+  rb_hash_aset(version_info, sym_version, version);
+  rb_hash_aset(version_info, sym_header_version, header_version);
+
+  return version_info;
 }
 
 /* call-seq:
@@ -907,14 +905,10 @@
  * Return the file descriptor number for this client.
  */
 static VALUE rb_mysql_client_socket(VALUE self) {
-  GET_CLIENT(self);
 #ifndef _WIN32
-  {
-    int fd_set_fd;
-    REQUIRE_CONNECTED(wrapper);
-    fd_set_fd = wrapper->client->net.fd;
-    return INT2NUM(fd_set_fd);
-  }
+  GET_CLIENT(self);
+  REQUIRE_CONNECTED(wrapper);
+  return INT2NUM(wrapper->client->net.fd);
 #else
   rb_raise(cMysql2Error, "Raw access to the mysql file descriptor isn't 
supported on Windows");
 #endif
@@ -987,7 +981,7 @@
   REQUIRE_CONNECTED(wrapper);
 
   args.mysql = wrapper->client;
-  args.db = StringValuePtr(db);
+  args.db = StringValueCStr(db);
 
   if (rb_thread_call_without_gvl(nogvl_select_db, &args, RUBY_UBF_IO, 0) == 
Qfalse)
     rb_raise_mysql2_error(wrapper);
@@ -1183,11 +1177,11 @@
   GET_CLIENT(self);
 
   mysql_ssl_set(wrapper->client,
-      NIL_P(key) ? NULL : StringValuePtr(key),
-      NIL_P(cert) ? NULL : StringValuePtr(cert),
-      NIL_P(ca) ? NULL : StringValuePtr(ca),
-      NIL_P(capath) ? NULL : StringValuePtr(capath),
-      NIL_P(cipher) ? NULL : StringValuePtr(cipher));
+      NIL_P(key)    ? NULL : StringValueCStr(key),
+      NIL_P(cert)   ? NULL : StringValueCStr(cert),
+      NIL_P(ca)     ? NULL : StringValueCStr(ca),
+      NIL_P(capath) ? NULL : StringValueCStr(capath),
+      NIL_P(cipher) ? NULL : StringValueCStr(cipher));
 
   return self;
 }
@@ -1254,12 +1248,12 @@
   rb_define_alloc_func(cMysql2Client, allocate);
 
   rb_define_singleton_method(cMysql2Client, "escape", rb_mysql_client_escape, 
1);
+  rb_define_singleton_method(cMysql2Client, "info", rb_mysql_client_info, 0);
 
   rb_define_method(cMysql2Client, "close", rb_mysql_client_close, 0);
   rb_define_method(cMysql2Client, "query", rb_mysql_client_query, -1);
   rb_define_method(cMysql2Client, "abandon_results!", 
rb_mysql_client_abandon_results, 0);
   rb_define_method(cMysql2Client, "escape", rb_mysql_client_real_escape, 1);
-  rb_define_method(cMysql2Client, "info", rb_mysql_client_info, 0);
   rb_define_method(cMysql2Client, "server_info", rb_mysql_client_server_info, 
0);
   rb_define_method(cMysql2Client, "socket", rb_mysql_client_socket, 0);
   rb_define_method(cMysql2Client, "async_result", 
rb_mysql_client_async_result, 0);
@@ -1293,6 +1287,7 @@
 
   sym_id              = ID2SYM(rb_intern("id"));
   sym_version         = ID2SYM(rb_intern("version"));
+  sym_header_version  = ID2SYM(rb_intern("header_version"));
   sym_async           = ID2SYM(rb_intern("async"));
   sym_symbolize_keys  = ID2SYM(rb_intern("symbolize_keys"));
   sym_as              = ID2SYM(rb_intern("as"));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ext/mysql2/extconf.rb new/ext/mysql2/extconf.rb
--- old/ext/mysql2/extconf.rb   1970-01-01 01:00:00.000000000 +0100
+++ new/ext/mysql2/extconf.rb   1970-01-01 01:00:00.000000000 +0100
@@ -2,7 +2,14 @@
 require 'mkmf'
 
 def asplode lib
-  abort "-----\n#{lib} is missing.  please check your installation of mysql 
and try again.\n-----"
+  if RUBY_PLATFORM =~ /mingw|mswin/
+    abort "-----\n#{lib} is missing. please check your installation of mysql 
and try again.\n-----"
+  elsif RUBY_PLATFORM =~ /darwin/
+    abort "-----\n#{lib} is missing. Try 'brew install mysql', check your 
installation of mysql and try again.\n-----"
+  else
+    abort "-----\n#{lib} is missing. Try 'apt-get install libmysqlclient-dev' 
or
+'yum install mysql-devel', check your installation of mysql and try 
again.\n-----"
+  end
 end
 
 # 2.0-only
@@ -29,7 +36,7 @@
   /usr/local/lib/mysql5*
 ].map{|dir| "#{dir}/bin" }
 
-GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5}"
+GLOB = "{#{dirs.join(',')}}/{mysql_config,mysql_config5,mariadb_config}"
 
 # If the user has provided a --with-mysql-dir argument, we must respect it or 
fail.
 inc, lib = dir_config('mysql')
@@ -67,10 +74,14 @@
 else
   inc, lib = dir_config('mysql', '/usr/local')
   libs = ['m', 'z', 'socket', 'nsl', 'mygcc']
+  found = false
   while not find_library('mysqlclient', 'mysql_query', lib, "#{lib}/mysql") do
     exit 1 if libs.empty?
-    have_library(libs.shift)
+    found ||= have_library(libs.shift)
   end
+
+  asplode("mysql client") unless found
+
   rpath_dir = lib
 end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ext/mysql2/result.c new/ext/mysql2/result.c
--- old/ext/mysql2/result.c     1970-01-01 01:00:00.000000000 +0100
+++ new/ext/mysql2/result.c     1970-01-01 01:00:00.000000000 +0100
@@ -50,6 +50,10 @@
 #define MYSQL2_MIN_TIME 62171150401ULL
 #endif
 
+#define GET_RESULT(obj) \
+  mysql2_result_wrapper *wrapper; \
+  Data_Get_Struct(self, mysql2_result_wrapper, wrapper);
+
 static VALUE cMysql2Result;
 static VALUE cBigDecimal, cDate, cDateTime;
 static VALUE opt_decimal_zero, opt_float_zero, opt_time_year, opt_time_month, 
opt_utc_offset;
@@ -103,9 +107,8 @@
 }
 
 static VALUE rb_mysql_result_fetch_field(VALUE self, unsigned int idx, short 
int symbolize_keys) {
-  mysql2_result_wrapper * wrapper;
   VALUE rb_field;
-  GetMysql2Result(self, wrapper);
+  GET_RESULT(self);
 
   if (wrapper->fields == Qnil) {
     wrapper->numberOfFields = mysql_num_fields(wrapper->result);
@@ -193,7 +196,6 @@
 
 static VALUE rb_mysql_result_fetch_row(VALUE self, ID db_timezone, ID 
app_timezone, int symbolizeKeys, int asArray, int castBool, int cast, 
MYSQL_FIELD * fields) {
   VALUE rowVal;
-  mysql2_result_wrapper * wrapper;
   MYSQL_ROW row;
   unsigned int i = 0;
   unsigned long * fieldLengths;
@@ -202,7 +204,7 @@
   rb_encoding *default_internal_enc;
   rb_encoding *conn_enc;
 #endif
-  GetMysql2Result(self, wrapper);
+  GET_RESULT(self);
 
 #ifdef HAVE_RUBY_ENCODING_H
   default_internal_enc = rb_default_internal_encoding();
@@ -413,12 +415,11 @@
 }
 
 static VALUE rb_mysql_result_fetch_fields(VALUE self) {
-  mysql2_result_wrapper * wrapper;
   unsigned int i = 0;
   short int symbolizeKeys = 0;
   VALUE defaults;
 
-  GetMysql2Result(self, wrapper);
+  GET_RESULT(self);
 
   defaults = rb_iv_get(self, "@query_options");
   Check_Type(defaults, T_HASH);
@@ -443,13 +444,12 @@
 static VALUE rb_mysql_result_each(int argc, VALUE * argv, VALUE self) {
   VALUE defaults, opts, block;
   ID db_timezone, app_timezone, dbTz, appTz;
-  mysql2_result_wrapper * wrapper;
   unsigned long i;
   const char * errstr;
-  int symbolizeKeys = 0, asArray = 0, castBool = 0, cacheRows = 1, cast = 1, 
streaming = 0;
+  int symbolizeKeys, asArray, castBool, cacheRows, cast;
   MYSQL_FIELD * fields = NULL;
 
-  GetMysql2Result(self, wrapper);
+  GET_RESULT(self);
 
   defaults = rb_iv_get(self, "@query_options");
   Check_Type(defaults, T_HASH);
@@ -459,32 +459,14 @@
     opts = defaults;
   }
 
-  if (rb_hash_aref(opts, sym_symbolize_keys) == Qtrue) {
-    symbolizeKeys = 1;
-  }
-
-  if (rb_hash_aref(opts, sym_as) == sym_array) {
-    asArray = 1;
-  }
-
-  if (rb_hash_aref(opts, sym_cast_booleans) == Qtrue) {
-    castBool = 1;
-  }
-
-  if (rb_hash_aref(opts, sym_cache_rows) == Qfalse) {
-    cacheRows = 0;
-  }
-
-  if (rb_hash_aref(opts, sym_cast) == Qfalse) {
-    cast = 0;
-  }
-
-  if (rb_hash_aref(opts, sym_stream) == Qtrue) {
-    streaming = 1;
-  }
+  symbolizeKeys = RTEST(rb_hash_aref(opts, sym_symbolize_keys));
+  asArray       = rb_hash_aref(opts, sym_as) == sym_array;
+  castBool      = RTEST(rb_hash_aref(opts, sym_cast_booleans));
+  cacheRows     = RTEST(rb_hash_aref(opts, sym_cache_rows));
+  cast          = RTEST(rb_hash_aref(opts, sym_cast));
 
-  if (streaming && cacheRows) {
-    rb_warn("cacheRows is ignored if streaming is true");
+  if (wrapper->is_streaming && cacheRows) {
+    rb_warn(":cache_rows is ignored if :stream is true");
   }
 
   dbTz = rb_hash_aref(opts, sym_database_timezone);
@@ -508,23 +490,12 @@
     app_timezone = Qnil;
   }
 
-  if (wrapper->lastRowProcessed == 0) {
-    if (streaming) {
-      /* We can't get number of rows if we're streaming, */
-      /* until we've finished fetching all rows */
-      wrapper->numberOfRows = 0;
+  if (wrapper->is_streaming) {
+    /* When streaming, we will only yield rows, not return them. */
+    if (wrapper->rows == Qnil) {
       wrapper->rows = rb_ary_new();
-    } else {
-      wrapper->numberOfRows = mysql_num_rows(wrapper->result);
-      if (wrapper->numberOfRows == 0) {
-        wrapper->rows = rb_ary_new();
-        return wrapper->rows;
-      }
-      wrapper->rows = rb_ary_new2(wrapper->numberOfRows);
     }
-  }
 
-  if (streaming) {
     if (!wrapper->streamingComplete) {
       VALUE row;
 
@@ -532,16 +503,15 @@
 
       do {
         row = rb_mysql_result_fetch_row(self, db_timezone, app_timezone, 
symbolizeKeys, asArray, castBool, cast, fields);
-
-        if (block != Qnil && row != Qnil) {
-          rb_yield(row);
-          wrapper->lastRowProcessed++;
+        if (row != Qnil) {
+          wrapper->numberOfRows++;
+          if (block != Qnil) {
+            rb_yield(row);
+          }
         }
       } while(row != Qnil);
 
       rb_mysql_result_free_result(wrapper);
-
-      wrapper->numberOfRows = wrapper->lastRowProcessed;
       wrapper->streamingComplete = 1;
 
       // Check for errors, the connection might have gone out from under us
@@ -554,6 +524,15 @@
       rb_raise(cMysql2Error, "You have already fetched all the rows for this 
query and streaming is true. (to reiterate you must requery).");
     }
   } else {
+    if (wrapper->lastRowProcessed == 0) {
+      wrapper->numberOfRows = mysql_num_rows(wrapper->result);
+      if (wrapper->numberOfRows == 0) {
+        wrapper->rows = rb_ary_new();
+        return wrapper->rows;
+      }
+      wrapper->rows = rb_ary_new2(wrapper->numberOfRows);
+    }
+
     if (cacheRows && wrapper->lastRowProcessed == wrapper->numberOfRows) {
       /* we've already read the entire dataset from the C result into our */
       /* internal array. Lets hand that over to the user since it's ready to 
go */
@@ -598,17 +577,19 @@
 }
 
 static VALUE rb_mysql_result_count(VALUE self) {
-  mysql2_result_wrapper *wrapper;
+  GET_RESULT(self);
+
+  if (wrapper->is_streaming) {
+    /* This is an unsigned long per result.h */
+    return ULONG2NUM(wrapper->numberOfRows);
+  }
 
-  GetMysql2Result(self, wrapper);
   if (wrapper->resultFreed) {
-    if (wrapper->streamingComplete){
-      return LONG2NUM(wrapper->numberOfRows);
-    } else {
-      return LONG2NUM(RARRAY_LEN(wrapper->rows));
-    }
+    /* Ruby arrays have platform signed long length */
+    return LONG2NUM(RARRAY_LEN(wrapper->rows));
   } else {
-    return INT2FIX(mysql_num_rows(wrapper->result));
+    /* MySQL returns an unsigned 64-bit long here */
+    return ULL2NUM(mysql_num_rows(wrapper->result));
   }
 }
 
@@ -616,6 +597,7 @@
 VALUE rb_mysql_result_to_obj(VALUE client, VALUE encoding, VALUE options, 
MYSQL_RES *r) {
   VALUE obj;
   mysql2_result_wrapper * wrapper;
+
   obj = Data_Make_Struct(cMysql2Result, mysql2_result_wrapper, 
rb_mysql_result_mark, rb_mysql_result_free, wrapper);
   wrapper->numberOfFields = 0;
   wrapper->numberOfRows = 0;
@@ -634,6 +616,10 @@
 
   rb_iv_set(obj, "@query_options", options);
 
+  /* Options that cannot be changed in results.each(...) { |row| }
+   * should be processed here. */
+  wrapper->is_streaming = (rb_hash_aref(options, sym_stream) == Qtrue ? 1 : 0);
+
   return obj;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ext/mysql2/result.h new/ext/mysql2/result.h
--- old/ext/mysql2/result.h     1970-01-01 01:00:00.000000000 +0100
+++ new/ext/mysql2/result.h     1970-01-01 01:00:00.000000000 +0100
@@ -12,12 +12,11 @@
   unsigned int numberOfFields;
   unsigned long numberOfRows;
   unsigned long lastRowProcessed;
+  char is_streaming;
   char streamingComplete;
   char resultFreed;
   MYSQL_RES *result;
   mysql_client_wrapper *client_wrapper;
 } mysql2_result_wrapper;
 
-#define GetMysql2Result(obj, sval) (sval = 
(mysql2_result_wrapper*)DATA_PTR(obj));
-
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mysql2/client.rb new/lib/mysql2/client.rb
--- old/lib/mysql2/client.rb    1970-01-01 01:00:00.000000000 +0100
+++ new/lib/mysql2/client.rb    1970-01-01 01:00:00.000000000 +0100
@@ -82,6 +82,10 @@
       info_hash
     end
 
+    def info
+      self.class.info
+    end
+
     private
       def self.local_offset
         ::Time.local(2010).utc_offset.to_r / 86400
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mysql2/error.rb new/lib/mysql2/error.rb
--- old/lib/mysql2/error.rb     1970-01-01 01:00:00.000000000 +0100
+++ new/lib/mysql2/error.rb     1970-01-01 01:00:00.000000000 +0100
@@ -30,7 +30,7 @@
     # variable.
     #
     # See http://dev.mysql.com/doc/refman/5.5/en/charset-errors.html for
-    # more contetx.
+    # more context.
     #
     # Before MySQL 5.5 error message template strings are in whatever encoding
     # is associated with the error message language.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/lib/mysql2/version.rb new/lib/mysql2/version.rb
--- old/lib/mysql2/version.rb   1970-01-01 01:00:00.000000000 +0100
+++ new/lib/mysql2/version.rb   1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +1,3 @@
 module Mysql2
-  VERSION = "0.3.18"
+  VERSION = "0.3.19"
 end
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/metadata new/metadata
--- old/metadata        1970-01-01 01:00:00.000000000 +0100
+++ new/metadata        1970-01-01 01:00:00.000000000 +0100
@@ -1,14 +1,14 @@
 --- !ruby/object:Gem::Specification
 name: mysql2
 version: !ruby/object:Gem::Version
-  version: 0.3.18
+  version: 0.3.19
 platform: ruby
 authors:
 - Brian Lopez
 autorequire: 
 bindir: bin
 cert_chain: []
-date: 2015-02-17 00:00:00.000000000 Z
+date: 2015-07-30 00:00:00.000000000 Z
 dependencies:
 - !ruby/object:Gem::Dependency
   name: rake-compiler
@@ -59,6 +59,7 @@
 - ext/mysql2/extconf.rb
 extra_rdoc_files: []
 files:
+- LICENSE
 - README.md
 - ext/mysql2/client.c
 - ext/mysql2/client.h
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/mysql2/client_spec.rb 
new/spec/mysql2/client_spec.rb
--- old/spec/mysql2/client_spec.rb      1970-01-01 01:00:00.000000000 +0100
+++ new/spec/mysql2/client_spec.rb      1970-01-01 01:00:00.000000000 +0100
@@ -66,12 +66,13 @@
       end
     end
     client = klient.new
-    (client.connect_args.last[6] & (Mysql2::Client::REMEMBER_OPTIONS |
-                                     Mysql2::Client::LONG_PASSWORD |
-                                     Mysql2::Client::LONG_FLAG |
-                                     Mysql2::Client::TRANSACTIONS |
-                                     Mysql2::Client::PROTOCOL_41 |
-                                     
Mysql2::Client::SECURE_CONNECTION)).should be_true
+    client_flags = Mysql2::Client::REMEMBER_OPTIONS |
+                   Mysql2::Client::LONG_PASSWORD |
+                   Mysql2::Client::LONG_FLAG |
+                   Mysql2::Client::TRANSACTIONS |
+                   Mysql2::Client::PROTOCOL_41 |
+                   Mysql2::Client::SECURE_CONNECTION
+    client.connect_args.last[6].should eql(client_flags)
   end
 
   it "should execute init command" do
@@ -614,6 +615,21 @@
 
         @multi_client.more_results?.should be_false
       end
+
+      it "#more_results? should work with stored procedures" do
+        @multi_client.query("DROP PROCEDURE IF EXISTS test_proc")
+        @multi_client.query("CREATE PROCEDURE test_proc() BEGIN SELECT 1 AS 
'set_1'; SELECT 2 AS 'set_2'; END")
+        @multi_client.query("CALL test_proc()").first.should eql({ 'set_1' => 
1 })
+        @multi_client.more_results?.should be_true
+
+        @multi_client.next_result
+        @multi_client.store_result.first.should eql({ 'set_2' => 2 })
+
+        @multi_client.next_result
+        @multi_client.store_result.should be_nil # this is the result from 
CALL itself
+
+        @multi_client.more_results?.should be_false
+      end
     end
   end
 
@@ -700,6 +716,19 @@
         @client.escape ""
       }.should raise_error(Mysql2::Error)
     end
+
+    context 'when mysql encoding is not utf8' do
+      before { pending('Encoding is undefined') unless defined?(Encoding) }
+
+      let(:client) { 
Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => "ujis")) }
+
+      it 'should return a internal encoding string if 
Encoding.default_internal is set' do
+        with_internal_encoding Encoding::UTF_8 do
+          client.escape("\u{30C6}\u{30B9}\u{30C8}").should 
eql("\u{30C6}\u{30B9}\u{30C8}")
+          client.escape("\u{30C6}'\u{30B9}\"\u{30C8}").should 
eql("\u{30C6}\\'\u{30B9}\\\"\u{30C8}")
+        end
+      end
+    end
   end
 
   it "should respond to #info" do
@@ -715,26 +744,21 @@
     info[:version].class.should eql(String)
   end
 
-  if defined? Encoding
-    context "strings returned by #info" do
-      it "should default to the connection's encoding if 
Encoding.default_internal is nil" do
-        with_internal_encoding nil do
-          @client.info[:version].encoding.should eql(Encoding.find('utf-8'))
+  context "strings returned by #info" do
+    before { pending('Encoding is undefined') unless defined?(Encoding) }
 
-          client2 = 
Mysql2::Client.new(DatabaseCredentials['root'].merge(:encoding => 'ascii'))
-          client2.info[:version].encoding.should eql(Encoding.find('us-ascii'))
-        end
-      end
+    it "should be tagged as ascii" do
+      @client.info[:version].encoding.should eql(Encoding::US_ASCII)
+      @client.info[:header_version].encoding.should eql(Encoding::US_ASCII)
+    end
+  end
 
-      it "should use Encoding.default_internal" do
-        with_internal_encoding 'utf-8' do
-          @client.info[:version].encoding.should eql(Encoding.default_internal)
-        end
+  context "strings returned by .info" do
+    before { pending('Encoding is undefined') unless defined?(Encoding) }
 
-        with_internal_encoding 'us-ascii' do
-          @client.info[:version].encoding.should eql(Encoding.default_internal)
-        end
-      end
+    it "should be tagged as ascii" do
+      Mysql2::Client.info[:version].encoding.should eql(Encoding::US_ASCII)
+      Mysql2::Client.info[:header_version].encoding.should 
eql(Encoding::US_ASCII)
     end
   end
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/spec/mysql2/result_spec.rb 
new/spec/mysql2/result_spec.rb
--- old/spec/mysql2/result_spec.rb      1970-01-01 01:00:00.000000000 +0100
+++ new/spec/mysql2/result_spec.rb      1970-01-01 01:00:00.000000000 +0100
@@ -6,6 +6,14 @@
     @result = @client.query "SELECT 1"
   end
 
+  it "should raise a TypeError exception when it doesn't wrap a result set" do
+    r = Mysql2::Result.new
+    expect { r.count }.to raise_error(TypeError)
+    expect { r.fields }.to raise_error(TypeError)
+    expect { r.size }.to raise_error(TypeError)
+    expect { r.each }.to raise_error(TypeError)
+  end
+
   it "should have included Enumerable" do
     Mysql2::Result.ancestors.include?(Enumerable).should be_true
   end
@@ -107,18 +115,19 @@
 
   context "streaming" do
     it "should maintain a count while streaming" do
-      result = @client.query('SELECT 1')
-
-      result.count.should eql(1)
+      result = @client.query('SELECT 1', :stream => true, :cache_rows => false)
+      result.count.should eql(0)
       result.each.to_a
       result.count.should eql(1)
     end
 
-    it "should set the actual count of rows after streaming" do
-      result = @client.query("SELECT * FROM mysql2_test", :stream => true, 
:cache_rows => false)
+    it "should retain the count when mixing first and each" do
+      result = @client.query("SELECT 1 UNION SELECT 2", :stream => true, 
:cache_rows => false)
       result.count.should eql(0)
-      result.each {|r|  }
+      result.first
       result.count.should eql(1)
+      result.each.to_a
+      result.count.should eql(2)
     end
 
     it "should not yield nil at the end of streaming" do


Reply via email to