[ruby-oci8-commit] [281] trunk/ruby-oci8: * ext/oci8/lob.c: add workaround code for a losing character problem
nobody at rubyforge.org
nobody at rubyforge.org
Sun Aug 10 09:27:27 EDT 2008
Revision: 281
Author: kubo
Date: 2008-08-10 09:27:26 -0400 (Sun, 10 Aug 2008)
Log Message:
-----------
* ext/oci8/lob.c: add workaround code for a losing character problem
when reading CLOB. The problem is happened at the following condition.
1. Oracle client version is 10.2.0.4 or 11.1.0.6.
(It doesn't depend on Oracle server version.)
2. The character set is a variable-length one (e.g. AL32UTF8).
* dist-files: add lib/oci8/datetime.rb and .document files.
Modified Paths:
--------------
trunk/ruby-oci8/ChangeLog
trunk/ruby-oci8/dist-files
trunk/ruby-oci8/ext/oci8/lob.c
Modified: trunk/ruby-oci8/ChangeLog
===================================================================
--- trunk/ruby-oci8/ChangeLog 2008-08-10 12:42:51 UTC (rev 280)
+++ trunk/ruby-oci8/ChangeLog 2008-08-10 13:27:26 UTC (rev 281)
@@ -1,3 +1,11 @@
+2008-08-10 KUBO Takehiro <kubo at jiubao.org>
+ * ext/oci8/lob.c: add workaround code for a losing character problem
+ when reading CLOB. The problem is happened at the following condition.
+ 1. Oracle client version is 10.2.0.4 or 11.1.0.6.
+ (It doesn't depend on Oracle server version.)
+ 2. The character set is a variable-length one (e.g. AL32UTF8).
+ * dist-files: add lib/oci8/datetime.rb and .document files.
+
2008-08-09 KUBO Takehiro <kubo at jiubao.org>
* ext/oci8/lob.c: fix OCI8::LOB#size= when using a lob over 2GB.
fix the return value of OCI8::LOB#write when writing a string
Modified: trunk/ruby-oci8/dist-files
===================================================================
--- trunk/ruby-oci8/dist-files 2008-08-10 12:42:51 UTC (rev 280)
+++ trunk/ruby-oci8/dist-files 2008-08-10 13:27:26 UTC (rev 281)
@@ -10,6 +10,7 @@
doc/api.ja.html
doc/api.ja.rd
doc/manual.css
+ext/oci8/.document
ext/oci8/MANIFEST
ext/oci8/apiwrap.c.tmpl
ext/oci8/apiwrap.h.tmpl
@@ -34,9 +35,12 @@
ext/oci8/stmt.c
ext/oci8/object.c
ext/oci8/xmldb.c
+lib/.document
lib/oci8.rb.in
lib/DBD/OCI8/OCI8.rb
+lib/oci8/.document
lib/oci8/compat.rb
+lib/oci8/datetime.rb
lib/oci8/metadata.rb
lib/oci8/object.rb
lib/oci8/oci8.rb
Modified: trunk/ruby-oci8/ext/oci8/lob.c
===================================================================
--- trunk/ruby-oci8/ext/oci8/lob.c 2008-08-10 12:42:51 UTC (rev 280)
+++ trunk/ruby-oci8/ext/oci8/lob.c 2008-08-10 13:27:26 UTC (rev 281)
@@ -279,7 +279,7 @@
ub4 nchar;
ub4 amt;
sword rv;
- char buf[4096];
+ char buf[8192];
size_t buf_size_in_char;
VALUE size;
VALUE v = Qnil;
@@ -320,6 +320,8 @@
oci8_raise(oci8_errhp, rv, NULL);
lob->state = S_BFILE_OPEN;
}
+ /* initialize buf in zeros everytime to check a nul characters. */
+ memset(buf, 0, sizeof(buf));
rv = OCILobRead_nb(svcctx, svcctx->base.hp.svc, oci8_errhp, lob->base.hp.lob, &amt, lob->pos + 1, buf, sizeof(buf), NULL, NULL, 0, lob->csfrm);
if (rv == OCI_ERROR && oci8_get_error_code(oci8_errhp) == 22289) {
/* ORA-22289: cannot perform FILEREAD operation on an unopened file or LOB */
@@ -328,6 +330,18 @@
}
if (rv != OCI_SUCCESS && rv != OCI_NEED_DATA)
oci8_raise(oci8_errhp, rv, NULL);
+
+ /* Workaround when using Oracle 10.2.0.4 or 11.1.0.6 client and
+ * variable-length character set (e.g. AL32UTF8).
+ *
+ * When the above mentioned condition, amt may be shorter. So
+ * amt is increaded until a nul character to know the actually
+ * read size.
+ */
+ while (amt < sizeof(buf) && buf[amt] != '\0') {
+ amt++;
+ }
+
if (amt == 0)
break;
/* for fixed size charset, amt is the number of characters stored in buf. */
More information about the ruby-oci8-commit
mailing list