php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39820 ORA-03131: an invalid buffer was provided for the next piece
Submitted: 2006-12-13 17:09 UTC Modified: 2016-03-08 01:38 UTC
Votes:6
Avg. Score:4.7 ± 0.7
Reproduced:4 of 4 (100.0%)
Same Version:1 (25.0%)
Same OS:0 (0.0%)
From: alien at mosfasad dot ru Assigned: wez (profile)
Status: No Feedback Package: PDO OCI
PHP Version: 5.2.0 OS: win xp
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2006-12-13 17:09 UTC] alien at mosfasad dot ru
Description:
------------
when i execute procedure(ORACLE 10 R2) with out param. i catch error
in the version 5.1.4 all is ok.

Procedure wb_utils.ReportOrder is VALID  !

PHP Version 5.2.1-dev

PHP API 	20041225 
PHP Extension 	20060613 
Zend Extension 	220060519

OCI Revision 	$Revision: 1.269.2.16.2.26 $

PDO Driver for OCI 8 and later: enabled


Reproduce code:
---------------
$sSql =  'call wb_utils.ReportOrder(:var0,:out0,:var1,:var2,:var3)';
$aArguments = Array
(
    [var0] => 24277102
    [var1] => 
    [var2] => args
    [var3] => cols
)

$oStat = $this->oPDOs->prepare($sSql);
.....
$oStat->bindParam('out0',$this->Out0, PDO::PARAM_STR,4096);
.....
$oStat->execute($aArguments);


Expected result:
----------------
[13-дек-2006 19:49:57] PHP Fatal error:  Uncaught in C:\prj\web\include\db.2.inc.php at 410 code :pdo_execute Param [HY000,SQLSTATE[HY000]: General error: 3131 OCIStmtExecute: ORA-03131: an invalid buffer was provided for the next piece
 (ext\pdo_oci\oci_statement.c:142),
call wb_utils.ReportOrder(:var0,:out0,:var1,:var2,:var3)
] thrown in C:\prj\web\include\db.2.inc.php on line 410



Actual result:
--------------
execute procedure and get out param

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-18 08:40 UTC] tony2001@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.


 [2006-12-25 11:18 UTC] alien at mosfasad dot ru
ini_set('display_errors','on');
$sSql =  'call wb_utils.ReportOrder(:var0,:out0,:var1,:var2,:var3)';
$sOut = '                    ';
$aArguments = Array
(
'var0' => 24277102,
'var1' => '',
'var2' => 'args',
'var3' => 'cols'
);

$sDsn = 'oci:dbname=//saturn.icon3.ru/mito';
$sUser = 'XXX';
$sPass  = 'XXXXXX';
$aArgs = array();

$oPDOs = new PDO($sDsn,$sUser,$sPass,$aArgs);
/* !!! IF COMMENT LINE BELOW, NO ERROR */
$oPDOs->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
/**/
$oStat = $oPDOs->prepare( $sSql );
$oStat->bindParam('out0',$sOut, PDO::PARAM_STR,strlen( $sOut ) );
$oStat->execute($aArguments);
echo '['.$sOut.']';
 [2006-12-25 11:21 UTC] tony2001@php.net
>If the script requires a database to demonstrate the issue,
>please make sure it creates all necessary tables, stored >procedures etc.
 [2006-12-25 12:12 UTC] alien at mosfasad dot ru
$sSql =  'call ReportOrder(:var0,:out0,:var1,:var2,:var3)';

CREATE OR REPLACE PROCEDURE ReportOrder
(
	dFormId NUMBER, dCalcId OUT VARCHAR2, sUnionDescr VARCHAR2, sArgsName VARCHAR2, sColsName VARCHAR2
) IS
BEGIN
	dCalcId := '1';
END;
 [2007-01-09 15:10 UTC] alien at mosfasad dot ru
!!! WRONG !!! :
/* !!! IF COMMENT LINE BELOW, NO ERROR */
$oPDOs->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
/**/
if i comment this lines error i can look error, when i call method errorInfo( )!

print_r( $oStat->errorInfo( ) );
 [2007-01-09 15:59 UTC] alien at mosfasad dot ru
i can temporary resolve this problem by this code:

$sSql =  'call ReportOrder( :out0, :var0 , :var1)';
$sOut = '                    ';
$sVar0 = null;

$aArguments = Array ('var0' =>'asdasasdasd','var1' =>'3242424' );

$sDsn = 'oci:dbname=********';
$sUser = '***';
$sPass  = '*******';
$aArgs = array();

$oPDOs = new PDO($sDsn,$sUser,$sPass,$aArgs);

$oStat = $oPDOs->prepare( $sSql );
$oStat->bindParam('out0', $sOut, PDO::PARAM_STR,strlen( $sOut ) );
/* !!!!!! this CODE  !!!!*/
$oStat->bindParam('var0',$sVar0 );
$oStat->bindParam('var1',$sVar0 );
/* !!!!!!********!!!!*/
$oStat->execute($aArguments);
echo '['.$sOut.']';
?>

PLSQL PROC :

CREATE OR REPLACE PROCEDURE ReportOrder
(
	dCalcId OUT VARCHAR2, dFormId VARCHAR2, dFormId1 VARCHAR2
) IS
BEGIN
	dCalcId := dFormId || dFormId1;
END;
 [2009-04-25 14:40 UTC] jani@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/


 [2009-05-03 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2010-02-01 13:39 UTC] symphony dot group at yahoo dot com
This bug is still exists in both PHP versions (5.2.12 & 5.3.1)

I've set up two test VMs and am quite willing to help get this working. 

the following simple code easily re-produces the bug:

try {
                $dbConn = new PDO('oci:dbname=.....);
                $dbConn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                $sql = $dbConn->prepare("
                                BEGIN
                                        SELECT  username
                                        INTO    :chkId
                                        FROM    USERS
                                        WHERE   username = 'fred';
                                END;
                                ");
                $sql->bindParam('chkId', $chkId);
                $sql->execute();
                var_dump($chkId);
        } catch (Exception $e) {
                var_dump($e);
        }

obviously I've censored our connection info.

as the other user mentioned if I alter the bindParam to:

$sql->bindParam('chkId', $chkId, PDO::PARAM_STR, 10);

it works. however even missing off the variable length causes a error
 [2016-03-08 01:38 UTC] sixd@php.net
-Package: PDO related +Package: PDO OCI
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 11:01:30 2024 UTC