Bug #68498 [Fbk]: oci_error returns false after ORA-00001
| From: | sixd@php.net | Date: | Wed, 26 Nov 2014 02:56:13 +0000 |
| Subject: | Bug #68498 [Fbk]: oci_error returns false after ORA-00001 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-188795@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68498&edit=1
ID: 68498
Updated by: sixd@php.net
Reported by: joe at thook dot me
Summary: oci_error returns false after ORA-00001
Status: Feedback
Type: Bug
Package: OCI8 related
Operating System: CentOS
PHP Version: 5.5.19
Assigned To: sixd
Block user comment: N
Private report: N
New Comment:
Looks OK in my testcase.
<?php
/*
create table cjt (c1 number unique);
insert into cj1 values (1);
commit;
*/
error_reporting(E_ALL);
ini_set('display_errors', 'Off');
$c = oci_connect('hr', 'welcome', 'localhost/orcl');
if (!$c) {
$m = oci_error();
trigger_error('oci_connect error: Could not connect to database: '.
$m['message'], E_USER_ERROR);
}
$s = oci_parse($c, "insert into cjt values (1)");
if (!$s) {
$m = oci_error($c);
trigger_error('oci_parse error: Could not parse statement: '. $m['message'],
E_USER_ERROR);
}
$r = oci_execute($s);
if (!$r) {
$m = oci_error($s);
trigger_error('oci_execute error: Could not execute statement: '.
$m['message'], E_USER_ERROR);
}
?>
Gives:
$ php56 uc.php
PHP Warning: oci_execute(): ORA-00001: unique constraint (HR.SYS_C0010813) violated in uc.php on
line 25
PHP Fatal error: oci_execute error: Could not execute statement: ORA-00001: unique constraint
(HR.SYS_C0010813) violated in uc.php on line 28
Previous Comments:
------------------------------------------------------------------------
[2014-11-26 02:38:12] sixd@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.
Please give the SQL to create the table and a non-ZFW testcase. Thanks.
------------------------------------------------------------------------
[2014-11-25 17:15:54] joe at thook dot me
Description:
------------
Behavior seems similar to this (resolved) issue: https://bugs.php.net/bug.php?id=42134
Project using ZF1 fails to handle ORA-00001 (Unique constraint violation) warning as an error.
1. SQL statement is sent to Oracle DB adapter using OCI driver (2.0.8)
2. oci_execute() of INSERT statement would cause unique constraint violation, statement fails
correctly.
3. PHP Warning is issued (verified with FirePHP and in Apache logs). PHP error_reporting is E_ALL on
this development server.
4. ZF1 attempts to generate Exception thus:
throw new Zend_Db_Statement_Oracle_Exception(oci_error($this->_stmt));
5. oci_error returns false. Exception is not generated correctly because error array is not
produced.
Expected result:
----------------
When oci_execute() throws ORA-00001 and issues a PHP Warning, oci_error should produce the error
array in accordance with PHP's error_reporting setting.
Actual result:
--------------
oci_error() returns false despite Warning issued.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68498&edit=1