[DRE-commits] [ruby-mysql] 08/08: Release to unstable

Antonio Terceiro terceiro at moszumanska.debian.org
Mon Oct 6 11:54:35 UTC 2014


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to branch master
in repository ruby-mysql.

commit 9ee741acae068db1d645e3516147cdc95dcc948a
Author: Antonio Terceiro <terceiro at debian.org>
Date:   Mon Oct 6 08:53:07 2014 -0300

    Release to unstable
---
 debian/changelog      |  4 +--
 ext/mysql_api/mysql.c | 67 +++++++++++++++++++++++++++++++++------------------
 test/test_mysql.rb    |  9 ++++---
 3 files changed, 52 insertions(+), 28 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 6fcedb5..b84f6df 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,4 +1,4 @@
-ruby-mysql (2.9.1-1) UNRELEASED; urgency=medium
+ruby-mysql (2.9.1-1) unstable; urgency=medium
 
   * Team upload.
   * New upstream release.
@@ -7,7 +7,7 @@ ruby-mysql (2.9.1-1) UNRELEASED; urgency=medium
   * Added DEP-8 testsuite using the upstream test suite, against a local MySQL
     server.
 
- -- Antonio Terceiro <terceiro at debian.org>  Sun, 05 Oct 2014 16:04:40 -0300
+ -- Antonio Terceiro <terceiro at debian.org>  Mon, 06 Oct 2014 08:53:04 -0300
 
 ruby-mysql (2.8.2+gem2deb-4) unstable; urgency=medium
 
diff --git a/ext/mysql_api/mysql.c b/ext/mysql_api/mysql.c
index 4b61f13..1bd2268 100644
--- a/ext/mysql_api/mysql.c
+++ b/ext/mysql_api/mysql.c
@@ -42,6 +42,27 @@
 #define GetMysqlRes(obj)	(Check_Type(obj, T_DATA), ((struct mysql_res*)DATA_PTR(obj))->res)
 #define GetMysqlStmt(obj)	(Check_Type(obj, T_DATA), ((struct mysql_stmt*)DATA_PTR(obj))->stmt)
 
+#include <ruby/encoding.h>
+#define DEFAULT_ENCODING (rb_enc_get(rb_enc_default_external()))
+
+VALUE
+rb_mysql_enc_tainted_str_new(const char *ptr, long len)
+{
+    VALUE str = rb_enc_str_new(ptr, len, DEFAULT_ENCODING);
+
+    OBJ_TAINT(str);
+    return str;
+}
+
+VALUE
+rb_mysql_enc_tainted_str_new2(const char *ptr)
+{
+    VALUE str = rb_enc_str_new(ptr, strlen(ptr), DEFAULT_ENCODING);
+
+    OBJ_TAINT(str);
+    return str;
+}
+
 VALUE cMysql;
 VALUE cMysqlRes;
 VALUE cMysqlField;
@@ -170,7 +191,7 @@ static void mysql_raise(MYSQL* m)
     VALUE e = rb_exc_new2(eMysql, mysql_error(m));
     rb_iv_set(e, "errno", INT2FIX(mysql_errno(m)));
 #if MYSQL_VERSION_ID >= 40101
-    rb_iv_set(e, "sqlstate", rb_tainted_str_new2(mysql_sqlstate(m)));
+    rb_iv_set(e, "sqlstate", rb_mysql_enc_tainted_str_new2(mysql_sqlstate(m)));
 #endif
     rb_exc_raise(e);
 }
@@ -197,9 +218,9 @@ static VALUE make_field_obj(MYSQL_FIELD* f)
     if (f == NULL)
 	return Qnil;
     obj = rb_obj_alloc(cMysqlField);
-    rb_iv_set(obj, "name", f->name? rb_str_freeze(rb_tainted_str_new2(f->name)): Qnil);
-    rb_iv_set(obj, "table", f->table? rb_str_freeze(rb_tainted_str_new2(f->table)): Qnil);
-    rb_iv_set(obj, "def", f->def? rb_str_freeze(rb_tainted_str_new2(f->def)): Qnil);
+    rb_iv_set(obj, "name", f->name? rb_str_freeze(rb_mysql_enc_tainted_str_new2(f->name)): Qnil);
+    rb_iv_set(obj, "table", f->table? rb_str_freeze(rb_mysql_enc_tainted_str_new2(f->table)): Qnil);
+    rb_iv_set(obj, "def", f->def? rb_str_freeze(rb_mysql_enc_tainted_str_new2(f->def)): Qnil);
     rb_iv_set(obj, "type", INT2NUM(f->type));
     rb_iv_set(obj, "length", INT2NUM(f->length));
     rb_iv_set(obj, "max_length", INT2NUM(f->max_length));
@@ -286,7 +307,7 @@ static VALUE escape_string(VALUE klass, VALUE str)
 {
     VALUE ret;
     Check_Type(str, T_STRING);
-    ret = rb_str_new(0, (RSTRING_LEN(str))*2+1);
+    ret = rb_enc_str_new(0, (RSTRING_LEN(str))*2+1, DEFAULT_ENCODING);
     rb_str_set_len(ret, mysql_escape_string(RSTRING_PTR(ret), RSTRING_PTR(str), RSTRING_LEN(str)));
     return ret;
 }
@@ -294,7 +315,7 @@ static VALUE escape_string(VALUE klass, VALUE str)
 /*	client_info()	*/
 static VALUE client_info(VALUE klass)
 {
-    return rb_tainted_str_new2(mysql_get_client_info());
+    return rb_mysql_enc_tainted_str_new2(mysql_get_client_info());
 }
 
 #if MYSQL_VERSION_ID >= 32332
@@ -430,7 +451,7 @@ static VALUE real_escape_string(VALUE obj, VALUE str)
     MYSQL* m = GetHandler(obj);
     VALUE ret;
     Check_Type(str, T_STRING);
-    ret = rb_str_new(0, (RSTRING_LEN(str))*2+1);
+    ret = rb_enc_str_new(0, (RSTRING_LEN(str))*2+1, DEFAULT_ENCODING);
     rb_str_set_len(ret, mysql_real_escape_string(m, RSTRING_PTR(ret), RSTRING_PTR(str), RSTRING_LEN(str)));
     return ret;
 }
@@ -469,7 +490,7 @@ static VALUE change_user(int argc, VALUE* argv, VALUE obj)
 /*	character_set_name()	*/
 static VALUE character_set_name(VALUE obj)
 {
-    return rb_tainted_str_new2(mysql_character_set_name(GetHandler(obj)));
+    return rb_mysql_enc_tainted_str_new2(mysql_character_set_name(GetHandler(obj)));
 }
 #endif
 
@@ -534,7 +555,7 @@ static VALUE field_count(VALUE obj)
 /*	host_info()	*/
 static VALUE host_info(VALUE obj)
 {
-    return rb_tainted_str_new2(mysql_get_host_info(GetHandler(obj)));
+    return rb_mysql_enc_tainted_str_new2(mysql_get_host_info(GetHandler(obj)));
 }
 
 /*	proto_info()	*/
@@ -546,14 +567,14 @@ static VALUE proto_info(VALUE obj)
 /*	server_info()	*/
 static VALUE server_info(VALUE obj)
 {
-    return rb_tainted_str_new2(mysql_get_server_info(GetHandler(obj)));
+    return rb_mysql_enc_tainted_str_new2(mysql_get_server_info(GetHandler(obj)));
 }
 
 /*	info()		*/
 static VALUE info(VALUE obj)
 {
     const char* p = mysql_info(GetHandler(obj));
-    return p? rb_tainted_str_new2(p): Qnil;
+    return p? rb_mysql_enc_tainted_str_new2(p): Qnil;
 }
 
 /*	insert_id()	*/
@@ -588,7 +609,7 @@ static VALUE list_dbs(int argc, VALUE* argv, VALUE obj)
     n = mysql_num_rows(res);
     ret = rb_ary_new2(n);
     for (i=0; i<n; i++)
-	rb_ary_store(ret, i, rb_tainted_str_new2(mysql_fetch_row(res)[0]));
+	rb_ary_store(ret, i, rb_mysql_enc_tainted_str_new2(mysql_fetch_row(res)[0]));
     mysql_free_result(res);
     return ret;
 }
@@ -633,7 +654,7 @@ static VALUE list_tables(int argc, VALUE* argv, VALUE obj)
     n = mysql_num_rows(res);
     ret = rb_ary_new2(n);
     for (i=0; i<n; i++)
-	rb_ary_store(ret, i, rb_tainted_str_new2(mysql_fetch_row(res)[0]));
+	rb_ary_store(ret, i, rb_mysql_enc_tainted_str_new2(mysql_fetch_row(res)[0]));
     mysql_free_result(res);
     return ret;
 }
@@ -697,7 +718,7 @@ static VALUE my_stat(VALUE obj)
     const char* s = mysql_stat(m);
     if (s == NULL)
 	mysql_raise(m);
-    return rb_tainted_str_new2(s);
+    return rb_mysql_enc_tainted_str_new2(s);
 }
 
 /*	store_result()	*/
@@ -864,7 +885,7 @@ static VALUE set_server_option(VALUE obj, VALUE option)
 static VALUE sqlstate(VALUE obj)
 {
     MYSQL *m = GetHandler(obj);
-    return rb_tainted_str_new2(mysql_sqlstate(m));
+    return rb_mysql_enc_tainted_str_new2(mysql_sqlstate(m));
 }
 #endif
 
@@ -1029,7 +1050,7 @@ static VALUE fetch_row(VALUE obj)
 	return Qnil;
     ary = rb_ary_new2(n);
     for (i=0; i<n; i++)
-	rb_ary_store(ary, i, row[i]? rb_tainted_str_new(row[i], lengths[i]): Qnil);
+	rb_ary_store(ary, i, row[i]? rb_mysql_enc_tainted_str_new(row[i], lengths[i]): Qnil);
     return ary;
 }
 
@@ -1053,7 +1074,7 @@ static VALUE fetch_hash2(VALUE obj, VALUE with_table)
         if (colname == Qnil) {
             colname = rb_ary_new2(n);
             for (i=0; i<n; i++) {
-                VALUE s = rb_tainted_str_new2(fields[i].name);
+                VALUE s = rb_mysql_enc_tainted_str_new2(fields[i].name);
                 rb_obj_freeze(s);
                 rb_ary_store(colname, i, s);
             }
@@ -1066,7 +1087,7 @@ static VALUE fetch_hash2(VALUE obj, VALUE with_table)
             colname = rb_ary_new2(n);
             for (i=0; i<n; i++) {
                 int len = strlen(fields[i].table)+strlen(fields[i].name)+1;
-                VALUE s = rb_tainted_str_new(NULL, len);
+                VALUE s = rb_mysql_enc_tainted_str_new(NULL, len);
                 snprintf(RSTRING_PTR(s), len+1, "%s.%s", fields[i].table, fields[i].name);
                 rb_obj_freeze(s);
                 rb_ary_store(colname, i, s);
@@ -1076,7 +1097,7 @@ static VALUE fetch_hash2(VALUE obj, VALUE with_table)
         }
     }
     for (i=0; i<n; i++) {
-        rb_hash_aset(hash, rb_ary_entry(colname, i), row[i]? rb_tainted_str_new(row[i], lengths[i]): Qnil);
+        rb_hash_aset(hash, rb_ary_entry(colname, i), row[i]? rb_mysql_enc_tainted_str_new(row[i], lengths[i]): Qnil);
     }
     return hash;
 }
@@ -1198,7 +1219,7 @@ static VALUE field_hash(VALUE obj)
 static VALUE field_inspect(VALUE obj)
 {
     VALUE n = rb_iv_get(obj, "name");
-    VALUE s = rb_str_new(0, RSTRING_LEN(n) + 16);
+    VALUE s = rb_enc_str_new(0, RSTRING_LEN(n) + 16, DEFAULT_ENCODING);
     sprintf(RSTRING_PTR(s), "#<Mysql::Field:%s>", RSTRING_PTR(n));
     return s;
 }
@@ -1257,7 +1278,7 @@ static void mysql_stmt_raise(MYSQL_STMT* s)
 {
     VALUE e = rb_exc_new2(eMysql, mysql_stmt_error(s));
     rb_iv_set(e, "errno", INT2FIX(mysql_stmt_errno(s)));
-    rb_iv_set(e, "sqlstate", rb_tainted_str_new2(mysql_stmt_sqlstate(s)));
+    rb_iv_set(e, "sqlstate", rb_mysql_enc_tainted_str_new2(mysql_stmt_sqlstate(s)));
     rb_exc_raise(e);
 }
 
@@ -1573,7 +1594,7 @@ static VALUE stmt_fetch(VALUE obj)
             case MYSQL_TYPE_NEWDECIMAL:
             case MYSQL_TYPE_BIT:
 #endif
-                v = rb_tainted_str_new(s->result.bind[i].buffer, s->result.length[i]);
+                v = rb_mysql_enc_tainted_str_new(s->result.bind[i].buffer, s->result.length[i]);
                 break;
             default:
                 rb_raise(rb_eTypeError, "unknown buffer_type: %d", s->result.bind[i].buffer_type);
@@ -1762,7 +1783,7 @@ static VALUE stmt_send_long_data(VALUE obj, VALUE col, VALUE data)
 static VALUE stmt_sqlstate(VALUE obj)
 {
     struct mysql_stmt* s = DATA_PTR(obj);
-    return rb_tainted_str_new2(mysql_stmt_sqlstate(s->stmt));
+    return rb_mysql_enc_tainted_str_new2(mysql_stmt_sqlstate(s->stmt));
 }
 
 /*-------------------------------
diff --git a/test/test_mysql.rb b/test/test_mysql.rb
index c40004f..16f4b56 100644
--- a/test/test_mysql.rb
+++ b/test/test_mysql.rb
@@ -342,7 +342,7 @@ class TC_MysqlRes < Test::Unit::TestCase
     assert_equal("t", f.table)
     assert_equal(nil, f.def)
     assert_equal(Mysql::Field::TYPE_STRING, f.type)
-    assert_equal(30, f.length)
+    assert_equal(10, f.length)
     assert_equal(4, f.max_length)
     assert_equal(0, f.flags)
     assert_equal(0, f.decimals)
@@ -399,7 +399,7 @@ class TC_MysqlRes < Test::Unit::TestCase
       "table" => "t",
       "def" => nil,
       "type" => Mysql::Field::TYPE_STRING,
-      "length" => 30,
+      "length" => 10,
       "max_length" => 4,
       "flags" => 0,
       "decimals" => 0,
@@ -1234,7 +1234,9 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
       @s.execute
       assert_equal([nil], @s.fetch)
       assert_equal([""], @s.fetch)
-      assert_equal(["abc"], @s.fetch)
+      row = @s.fetch
+      assert_equal(Encoding.default_external, row[0].encoding) if RUBY_VERSION >= '1.9'
+      assert_equal(["abc"], row)
       assert_equal(["def"], @s.fetch)
       assert_equal(["abc"], @s.fetch)
       assert_equal(["def"], @s.fetch)
@@ -1271,6 +1273,7 @@ class TC_MysqlStmt2 < Test::Unit::TestCase
         case c
         when 0
           assert_equal([1,"abc",Mysql::Time.new(1970,12,24,23,59,05)], a)
+          assert_equal(Encoding.default_external, a[1].encoding) if RUBY_VERSION >= '1.9'
         when 1
           assert_equal([2,"def",Mysql::Time.new(2112,9,3,12,34,56)], a)
         when 2

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/ruby-mysql.git



More information about the Pkg-ruby-extras-commits mailing list