Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug #54379 PDO_OCI: UTF-8 output gets truncated #59

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/pdo_oci/oci_statement.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ static int oci_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* {{{ */
(param, OCI_DTYPE_PARAM, &colname, &namelen, OCI_ATTR_NAME, S->err));

col->precision = scale;
col->maxlen = data_size;
col->maxlen = ( data_size + 1 ) * sizeof(utext);
col->namelen = namelen;
col->name = estrndup((char *)colname, namelen);

Expand Down
48 changes: 48 additions & 0 deletions ext/pdo_oci/tests/bug54379.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
--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';
PDOTest::skip();
?>
--FILE--
<?php
putenv('PDO_OCI_TEST_DSN', 'oci:dbname=localhost/xe;charset=AL32UTF8');
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_utf8_trunc");
} catch (Exception $e) {
}


$db->exec("CREATE TABLE test_utf8_trunc (col1 NVARCHAR2(20))");
$db->exec("INSERT INTO test_utf8_trunc VALUES('12345678901234567890')");
$db->exec("INSERT INTO test_utf8_trunc VALUES('あいうえおかきくけこさしすせそたちつてと')");

$stmt = $db->prepare("SELECT * FROM test_utf8_trunc");

$stmt->execute();
var_dump($stmt->fetchAll(PDO::FETCH_ASSOC));

$db->exec("DROP TABLE test_utf8_trunc");

?>
--EXPECTF--
array(2) {
[0]=>
array(1) {
["COL1"]=>
string(20) "12345678901234567890"
}
[1]=>
array(1) {
["COL1"]=>
string(40) "あいうえおかきくけこさしすせそたちつてと"
}
}