From:             bmr at comtime dot com
Operating system: Linux
PHP version:      4.3.10
PHP Bug Type:     OCI8 related
Bug description:  NVARCHAR2 columns are truncated

Description:
------------
NVARCHAR2 columns can be used to store UTF-8 or UTF-16 characters.  When
using UTF-8 it can take 3 (or more??) bytes to represent one character. 
PHP truncates strings that have byte representations longer than 2 times
the character length.    This is actually an Oracle bug because the OCI
call returns the wrong byte length.

Here's my patch:
--- php-4.3.10/ext/oci8/oci8.c  Wed Nov  3 08:35:56 2004
+++ php-4.3.10.cti/ext/oci8/oci8.c      Mon Feb 28 15:37:54 2005
@@ -1443,6 +1443,7 @@
        ub4 iters;
        ub4 colcount;
        ub2 dynamic;
+       ub1 charset_form;
        int dtype;
        dvoid *buf;
        oci_descriptor *descr;
@@ -1573,6 +1574,21 @@
                                return 0; /* XXX we loose memory!!! */
                        }

+                       if(outcol->data_type == SQLT_CHR) {
+                                CALL_OCI_RETURN(error, OCIAttrGet(
+                                                                (dvoid
*)param,
+                                                               
OCI_DTYPE_PARAM,
+                                                                (dvoid
*)&charset_form,
+                                                                (dvoid
*)0,
+                                                               
OCI_ATTR_CHARSET_FORM,
+                                                               
statement->pError));
+                                statement->error =
oci_error(statement->pError, "OCIAttrGet OCI_DTYPE_PARAM/OCI_ATTR_CHARS
ET_FORM", error);
+                                if (statement->error) {
+                                        
oci_handle_error(statement->conn, statement->error);
+                                         return 0; /* XXX we loose
memory!!! */
+                                }
+                       }
+
                        CALL_OCI_RETURN(error, OCIAttrGet(
                                                (dvoid *)param,
                                                OCI_DTYPE_PARAM,
@@ -1700,6 +1716,9 @@
                                                ) {
                                                outcol->storage_size4 =
512; /* XXX this should fit "most" NLS date-formats
 and Numbers */
                                        } else {
+                                               if(charset_form ==
SQLCS_NCHAR)
+                                                       
outcol->storage_size4 *=2; /* double for unicode */
+
                                                outcol->storage_size4++;
/* add one for string terminator */
                                        }
                                        if (outcol->data_type == SQLT_BIN)
{

Reproduce code:
---------------
ocifetchinto()


-- 
Edit bug report at http://bugs.php.net/?id=32140&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=32140&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=32140&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=32140&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=32140&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=32140&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=32140&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=32140&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=32140&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=32140&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=32140&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=32140&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=32140&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=32140&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=32140&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=32140&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=32140&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=32140&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=32140&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=32140&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=32140&r=mysqlcfg

Reply via email to