[ruby-oci8-commit] [504] trunk/ruby-oci8: 1. fix an exception when OCI8::CLOB.new(conn, '') is called.

nobody at rubyforge.org nobody at rubyforge.org
Tue Apr 17 12:16:24 UTC 2012


Revision: 504
Author:   kubo
Date:     2012-04-17 12:16:23 +0000 (Tue, 17 Apr 2012)
Log Message:
-----------
1. fix an exception when OCI8::CLOB.new(conn, '') is called.
2. Reset the position of a newly created 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-17 11:15:49 UTC (rev 503)
+++ trunk/ruby-oci8/ChangeLog	2012-04-17 12:16:23 UTC (rev 504)
@@ -1,4 +1,8 @@
 2012-04-17  KUBO Takehiro  <kubo at jiubao.org>
+	* ext/oci8/lob.c: 1. fix an exception when OCI8::CLOB.new(conn, '')
+	    is called. 2. Reset the position of a newly created LOB.
+
+2012-04-17  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/oci8lib.c: fix core dump.
 	    See: https://github.com/kubo/ruby-oci8/issues/11
 	    (reported by Raimonds Simanovskis)

Modified: trunk/ruby-oci8/ext/oci8/lob.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/lob.c	2012-04-17 11:15:49 UTC (rev 503)
+++ trunk/ruby-oci8/ext/oci8/lob.c	2012-04-17 12:16:23 UTC (rev 504)
@@ -1,4 +1,4 @@
-/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
+o/* -*- c-file-style: "ruby"; indent-tabs-mode: nil -*- */
 #include "oci8.h"
 
 static ID id_plus;
@@ -234,6 +234,7 @@
                &svcctx->base);
         lob->svchp = oci8_get_oci_svcctx(svc);
         oci8_lob_write(self, val);
+        lob->pos = 0; /* reset the position */
     }
     return Qnil;
 }
@@ -601,6 +602,10 @@
     }
     RB_GC_GUARD(data);
     amt = RSTRING_LEN(data);
+    if (amt == 0) {
+        /* to avoid ORA-24801: illegal parameter value in OCI lob function */
+        return INT2FIX(0);
+    }
     chker2(OCILobWrite_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob, &amt, lob->pos + 1, RSTRING_PTR(data), amt, OCI_ONE_PIECE, NULL, NULL, 0, lob->csfrm),
            &svcctx->base);
     lob->pos += amt;



More information about the ruby-oci8-commit mailing list