php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #51291 oci_error dont report last error when called two times
Submitted: 2010-03-13 16:04 UTC Modified: 2010-03-26 20:24 UTC
From: sumariva at gmail dot com Assigned: sixd (profile)
Status: Closed Package: OCI8 related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2010-03-13 16:04 UTC] sumariva at gmail dot com
Description:
------------
The documentation should add a note that the function or oracle change/resets the oracle error flag at each call when a resource statement passed in. If you call it two times with same statement resource parameter the second call get no error.

Test script:
---------------
<?php $ociUser = 'system';
$ociPass = 'mudar123';
$hostAddress = '192.168.1.43';
$ociConnString = '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST='.$hostAddress.')(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=XE)))';

$ociDbHandler = oci_connect( $ociUser, $ociPass, $ociConnString );

if ( !$ociDbHandler )
{ #call oci_error without args to check for connection errors
	 var_dump( __LINE__, oci_error() );
	 exit();
}

//sample from website
$stmt = @oci_parse( $ociDbHandler, "select ' from dual");  // note mismatched quote
if ( !$stmt )
{
  var_dump( __LINE__, oci_error( $ociDbHandler ) ); // For oci_parse errors pass the connection handle
  var_dump( __LINE__, oci_error( $ociDbHandler ) );
}
$stmt = 'select TABLE_NAME from ALL_TAB_COLUMNS, ALL_TAB_COLUMNS clone where ALL_TAB_COLUMNS.TABLE_NAME = clone.TABLE_NAME';
$stmt = @oci_parse( $ociDbHandler, $stmt );
$flag = @oci_execute( $stmt, OCI_DEFAULT );  // note duplicated column name
if ( !$flag )
{ #here the error message is not displayed on second call
  var_dump( __LINE__, oci_error(), oci_error( $ociDbHandler ), oci_error( $stmt ), $stmt ); // For oci_parse errors pass the connection handle
  var_dump( __LINE__, oci_error(), oci_error( $ociDbHandler ), oci_error( $stmt ), $stmt ); // For oci_parse errors pass the connection handle
  exit;
}
exit( 'end' );  ?>

Expected result:
----------------
Expected that each call on same resource reported the same errors.

Actual result:
--------------
int(27) bool(false) bool(false) array(4) { ["code"]=> int(918) ["message"]=> string(37) "ORA-00918: column ambiguously defined" ["offset"]=> int(7) ["sqltext"]=> string(113) "select TABLE_NAME from ALL_TAB_COLUMNS, ALL_TAB_COLUMNS clone where ALL_TAB_COLUMNS.TABLE_NAME = clone.TABLE_NAME" } resource(2) of type (oci8 statement)

int(28) bool(false) bool(false) bool(false) resource(2) of type (oci8 statement) 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-03-14 22:46 UTC] kalle@php.net
-Assigned To: +Assigned To: sixd
 [2010-03-14 22:46 UTC] kalle@php.net
Chris, is this a documentation issue or a bug in OCI8?
 [2010-03-14 22:46 UTC] kalle@php.net
-Package: Documentation problem +Package: OCI8 related
 [2010-03-24 23:08 UTC] sixd@php.net
Automatic comment from SVN on behalf of sixd
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=296754
Log: Fixed bug #51291 (oci_error doesn't report last error when called two times)
 [2010-03-24 23:18 UTC] sixd@php.net
-Status: Assigned +Status: Closed
 [2010-03-24 23:18 UTC] sixd@php.net
This bug has been fixed in SVN.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.

Fixed in OCI8 1.4.2 onwards.
 [2010-03-26 20:24 UTC] sixd@php.net
-Type: Documentation Problem +Type: Feature/Change Request
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 04:01:31 2024 UTC