[ruby-oci8-commit] [508] trunk/ruby-oci8: OCI8::LOB#read() returns an empty string '' when it is an empty lob.
nobody at rubyforge.org
nobody at rubyforge.org
Sat Apr 21 06:26:27 UTC 2012
Revision: 508
Author: kubo
Date: 2012-04-21 06:26:26 +0000 (Sat, 21 Apr 2012)
Log Message:
-----------
OCI8::LOB#read() returns an empty string '' when it is an empty lob.
Modified Paths:
--------------
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/ext/oci8/lob.c
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2012-04-21 05:02:52 UTC (rev 507)
+++ trunk/ruby-oci8/ChangeLog 2012-04-21 06:26:26 UTC (rev 508)
@@ -1,4 +1,8 @@
2012-04-21 KUBO Takehiro <kubo at jiubao.org>
+ * ext/oci8/lob.c: OCI8::LOB#read() returns an empty string '' when
+ it is an empty lob.
+
+2012-04-21 KUBO Takehiro <kubo at jiubao.org>
* custom-rdoc.rb: delete an unused file.
2012-04-21 KUBO Takehiro <kubo at jiubao.org>
Modified: trunk/ruby-oci8/ext/oci8/lob.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/lob.c 2012-04-21 05:02:52 UTC (rev 507)
+++ trunk/ruby-oci8/ext/oci8/lob.c 2012-04-21 06:26:26 UTC (rev 508)
@@ -473,10 +473,14 @@
*
* Reads <i>length</i> characters for CLOB and NCLOB or <i>length</i>
* bytes for BLOB and BILF from the current position.
- * When <i>length</i> is nil, it reads data until EOF.
+ * If <i>length</i> is <code>nil</code>, it reads data until EOF.
*
+ * It returns a string or <code>nil</code>. <code>nil</code> means it
+ * met EOF at beginning. As a special exception, when <i>length</i> is
+ * <code>nil</code> and the lob length is zero, it returns an empty string ''.
+ *
* @param [Integer] length
- * @return [String]
+ * @return [String or nil]
*/
static VALUE oci8_lob_read(int argc, VALUE *argv, VALUE self)
{
@@ -493,6 +497,9 @@
rb_scan_args(argc, argv, "01", &size);
length = oci8_lob_get_length(lob);
+ if (length == 0 && NIL_P(size)) {
+ return rb_usascii_str_new("", 0);
+ }
if (length <= lob->pos) /* EOF */
return Qnil;
length -= lob->pos;
More information about the ruby-oci8-commit
mailing list