[ruby-oci8-commit] [307] trunk/ruby-oci8: * ext/oci8/lob.c: concatenate read data at the end, instead of

nobody at rubyforge.org nobody at rubyforge.org
Sun Jan 11 03:38:04 EST 2009


Revision: 307
Author:   kubo
Date:     2009-01-11 03:38:04 -0500 (Sun, 11 Jan 2009)

Log Message:
-----------
* ext/oci8/lob.c: concatenate read data at the end, instead of
    appending them for each pieces when reading LOB data.
* test/test_oranumber.rb: fix for ruby 1.9.

Modified Paths:
--------------
    trunk/ruby-oci8/ChangeLog
    trunk/ruby-oci8/ext/oci8/lob.c
    trunk/ruby-oci8/test/test_oranumber.rb

Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog	2009-01-04 13:54:56 UTC (rev 306)
+++ trunk/ruby-oci8/ChangeLog	2009-01-11 08:38:04 UTC (rev 307)
@@ -1,3 +1,8 @@
+2009-01-11  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/lob.c: concatenate read data at the end, instead of
+	    appending them for each pieces when reading LOB data.
+	* test/test_oranumber.rb: fix for ruby 1.9.
+
 2009-01-04  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/oci8.c: delete OCI8.oracle_client_version implemented
 	    in C. add OCI8.oracle_client_vernum whose value is retrieved

Modified: trunk/ruby-oci8/ext/oci8/lob.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/lob.c	2009-01-04 13:54:56 UTC (rev 306)
+++ trunk/ruby-oci8/ext/oci8/lob.c	2009-01-11 08:38:04 UTC (rev 307)
@@ -282,7 +282,7 @@
     char buf[8192];
     size_t buf_size_in_char;
     VALUE size;
-    VALUE v = Qnil;
+    VALUE v = rb_ary_new();
 
     rb_scan_args(argc, argv, "01", &size);
     length = oci8_lob_get_length(lob);
@@ -348,17 +348,17 @@
         if (amt > buf_size_in_char)
             rb_raise(eOCIException, "Too large buffer fetched or you set too large size of a character.");
         amt *= lob->char_width;
-        if (v == Qnil)
-            v = rb_str_new(buf, amt);
-        else
-            v = rb_str_cat(v, buf, amt);
+        rb_ary_push(v, rb_str_new(buf, amt));
     } while (rv == OCI_NEED_DATA);
     lob->pos += nchar;
     if (nchar == length) {
         lob_close(lob);
         bfile_close(lob);
     }
-    return v;
+    if (RARRAY_LEN(v) == 0) {
+        return Qnil;
+    }
+    return rb_ary_join(v, Qnil);
 }
 
 static VALUE oci8_lob_write(VALUE self, VALUE data)

Modified: trunk/ruby-oci8/test/test_oranumber.rb
===================================================================
--- trunk/ruby-oci8/test/test_oranumber.rb	2009-01-04 13:54:56 UTC (rev 306)
+++ trunk/ruby-oci8/test/test_oranumber.rb	2009-01-11 08:38:04 UTC (rev 307)
@@ -101,7 +101,7 @@
         # explicity convert actual_val to a Float to prevent
         # SEGV in OCINumberSub() if the Oracle client vesion
         # is less than 10.2.0.4.
-        if defined? ::MiniTest and OCI8.oracle_client_version < 0x0a200400
+        if defined? ::MiniTest and OCI8.oracle_client_version < OCI8::OracleVersion.new('10.2.0.4')
           actual_val = actual_val.to_f
         end
         assert_in_delta(expected_val, actual_val, delta, x)




More information about the ruby-oci8-commit mailing list