From: Christopher Jones Date: Thu, 1 Oct 2009 05:51:11 +0000 (+0000) Subject: PECL Bug #16842 (oci_error return false when NO_DATA_FOUND is raised) X-Git-Tag: php-5.4.0alpha1~191^2~2556 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d1df1c4ba7ac6f2732599b255701e691d703013a;p=php PECL Bug #16842 (oci_error return false when NO_DATA_FOUND is raised) --- diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 28fdea4555..491fee1b85 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -1371,6 +1371,12 @@ sb4 php_oci_error(OCIError *err_p, sword status TSRMLS_DC) break; case OCI_NO_DATA: php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCI_NO_DATA"); + errcode = php_oci_fetch_errmsg(err_p, &errbuf TSRMLS_CC); + if (errbuf) { + efree(errbuf); + } else { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "OCI_NO_DATA: failed to fetch error message"); + } break; case OCI_ERROR: errcode = php_oci_fetch_errmsg(err_p, &errbuf TSRMLS_CC); diff --git a/ext/oci8/tests/pecl_bug16842.phpt b/ext/oci8/tests/pecl_bug16842.phpt new file mode 100644 index 0000000000..d796d2506e --- /dev/null +++ b/ext/oci8/tests/pecl_bug16842.phpt @@ -0,0 +1,69 @@ +--TEST-- +PECL Bug #16842 (NO_DATA_FOUND exception is a warning) +--SKIPIF-- + +--INI-- +error_reporting = E_WARNING +--FILE-- + +===DONE=== + +--EXPECTF-- +Test 1 +Raises NO_DATA_FOUND + +Warning: oci_execute(): OCI_NO_DATA in %s on line 11 +bool(false) +array(4) { + [%u|b%"code"]=> + int(1403) + [%u|b%"message"]=> + %unicode|string%(45) "ORA-01403: %s +ORA-06512: at line 1" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(31) "begin raise NO_DATA_FOUND; end;" +} +Test 2 +Raises ZERO_DIVIDE + +Warning: oci_execute(): ORA-01476: %s +ORA-06512: at line 1 in %s on line 19 +bool(false) +array(4) { + [%u|b%"code"]=> + int(1476) + [%u|b%"message"]=> + %unicode|string%(56) "ORA-01476: %s +ORA-06512: at line 1" + [%u|b%"offset"]=> + int(0) + [%u|b%"sqltext"]=> + %unicode|string%(29) "begin raise ZERO_DIVIDE; end;" +} +===DONE===