. Fixed bug #74159 (Writing a large buffer to a non-blocking encrypted stream
fails with "bad write retry"). (trowski)
+- PDO_OCI:
+ . Fixed bug #54379 (PDO_OCI: UTF-8 output gets truncated). (gureedo / Oracle)
+
- Standard:
. Fixed bug #74148 (ReflectionFunction incorrectly reports the number of
arguments). (Laruence)
goto cleanup;
}
+ /* Get max character width */
+ H->last_err = OCINlsNumericInfoGet(H->env, H->err, &H->max_char_width, OCI_NLS_CHARSET_MAXBYTESZ);
+ if (H->last_err) {
+ oci_drv_error("OCINlsNumericInfoGet: OCI_NLS_CHARSET_MAXBYTESZ");
+ goto cleanup;
+ }
+
dbh->methods = &oci_methods;
dbh->alloc_own_columns = 1;
dbh->native_case = PDO_CASE_UPPER;
} else if (dtype == SQLT_IBFLOAT || dtype == SQLT_IBDOUBLE) {
S->cols[colno].datalen = 1024;
#endif
+ } else if (dtype == SQLT_BIN) {
+ S->cols[colno].datalen = (ub4) col->maxlen * 2; // raw characters to hex digits
} else {
- S->cols[colno].datalen = (ub4) col->maxlen;
- }
- if (dtype == SQLT_BIN) {
- S->cols[colno].datalen *= 3;
+ S->cols[colno].datalen = (ub4) (col->maxlen * S->H->max_char_width);
}
+
S->cols[colno].data = emalloc(S->cols[colno].datalen + 1);
dtype = SQLT_CHR;
--- /dev/null
+--TEST--
+Bug #54379 (PDO_OCI: UTF-8 output gets truncated)
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_oci'))
+die('skip not loaded');
+require dirname(__FILE__).'/../../pdo/tests/pdo_test.inc';
+if (!preg_match('/charset=.*utf8/i', getenv('PDOTEST_DSN')))
+die('skip not UTF8 DSN');
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require 'ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt');
+$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+try {
+ $db->exec("DROP TABLE test");
+} catch (Exception $e) {
+}
+$db->exec("CREATE TABLE test (col1 NVARCHAR2(20))");
+$db->exec("INSERT INTO test VALUES('12345678901234567890')");
+$db->exec("INSERT INTO test VALUES('あいうえおかきくけこさしすせそたちつてと')");
+$stmt = $db->prepare("SELECT * FROM test");
+$stmt->execute();
+var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));
+$db->exec("DROP TABLE test");
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ array(1) {
+ ["col1"]=>
+ string(20) "12345678901234567890"
+ }
+ [1]=>
+ array(1) {
+ ["col1"]=>
+ string(60) "あいうえおかきくけこさしすせそたちつてと"
+ }
+}