php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55138 PDO_OCI cannot insert more than 1332 one byte chars in al32utf8 varchar2 field
Submitted: 2011-07-05 15:16 UTC Modified: 2014-01-01 12:43 UTC
Votes:6
Avg. Score:5.0 ± 0.0
Reproduced:6 of 6 (100.0%)
Same Version:2 (33.3%)
Same OS:4 (66.7%)
From: an0nym at narod dot ru Assigned:
Status: Open Package: PDO OCI
PHP Version: 5.3.6 OS: Linux
Private report: No CVE-ID:
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-07-05 15:16 UTC] an0nym at narod dot ru
Description:
------------
PDO_OCI cannot insert more than 1332 one byte chars in al32utf8 varchar2(4000 
CHAR) field. 

Additional info
$ php -v
PHP 5.3.6 (cli) (built: Apr 27 2011 23:46:11)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
$ uname -a
Linux ... 2.6.18-194.32.1.el5 #1 SMP Wed Jan 5 17:52:25 EST 2011 x86_64 x86_64 
x86_64 GNU/Linux

Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production

Test script:
---------------
<?php
$DB = new PDO("oci:dbname=//host:port/dbname;charset=AL32UTF8", "...", "...",
              array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
foreach ($DB->query("SELECT value FROM nls_database_parameters WHERE parameter = 'NLS_CHARACTERSET'") as $row)
    echo $row["VALUE"], "\n";
$DB->exec("CREATE TABLE test(test VARCHAR2(4000 CHAR))");
$statement = $DB->prepare("INSERT INTO test VALUES(:test)");
$test = str_repeat(chr(97), 1332);
$statement->bindParam(":test", $test);
$statement->execute();
$test .= chr(97);
try {
    $statement->execute();
} catch (PDOException $e) {
    $DB->exec("DROP TABLE test");
    exit("Error\n");
}
exit("Ok\n");


Expected result:
----------------
$ php test.php
AL32UTF8
Ok


Actual result:
--------------
$ php test.php
AL32UTF8
Error


Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-05 15:26 UTC] an0nym at narod dot ru
This issue can be worked around by adding $statement->bindParam(":test", 
$test>>>, PDO::PARAM_STR, 4000<<<), however this does not fix the bug itself.
 [2012-10-01 18:08 UTC] dernelson at corelogic dot com
This issue also affects PDOStatement::bindValue(), which does not have the 4th parameter "length" like bindParam() does, so the workaround is not always possible.
 [2014-01-01 12:43 UTC] felipe@php.net
-Package: PDO related +Package: PDO OCI
 
PHP Copyright © 2001-2017 The PHP Group
All rights reserved.
Last updated: Sat Feb 25 00:01:41 2017 UTC