summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2005-09-10 21:38:07 +0000
committerWez Furlong <wez@php.net>2005-09-10 21:38:07 +0000
commitf4007c8f6bccd7e1783d8852665efdf55fc071bd (patch)
treed5d1efaf5702d32077abb05cc6fac6fc443470e8
parentedc39221c0ba803218bd7d834ecf8b199c65726e (diff)
downloadphp-git-f4007c8f6bccd7e1783d8852665efdf55fc071bd.tar.gz
closes #33707: error information was not passed up to PDO::query().
-rwxr-xr-xext/pdo_oci/oci_driver.c12
-rw-r--r--ext/pdo_oci/tests/bug_33707.phpt30
2 files changed, 42 insertions, 0 deletions
diff --git a/ext/pdo_oci/oci_driver.c b/ext/pdo_oci/oci_driver.c
index 50113c4790..d3824d360c 100755
--- a/ext/pdo_oci/oci_driver.c
+++ b/ext/pdo_oci/oci_driver.c
@@ -144,6 +144,18 @@ ub4 _oci_error(OCIError *err, pdo_dbh_t *dbh, pdo_stmt_t *stmt, char *what, swor
}
}
+ if (stmt) {
+ /* always propogate the error code back up to the dbh,
+ * so that we can catch the error information when execute
+ * is called via query. See Bug #33707 */
+ if (H->einfo.errmsg) {
+ efree(H->einfo.errmsg);
+ }
+ H->einfo = *einfo;
+ H->einfo.errmsg = einfo->errmsg ? estrdup(einfo->errmsg) : NULL;
+ strcpy(dbh->error_code, stmt->error_code);
+ }
+
/* little mini hack so that we can use this code from the dbh ctor */
if (!dbh->methods) {
zend_throw_exception_ex(php_pdo_get_exception(), 0 TSRMLS_CC, "SQLSTATE[%s]: %s", *pdo_err, einfo->errmsg);
diff --git a/ext/pdo_oci/tests/bug_33707.phpt b/ext/pdo_oci/tests/bug_33707.phpt
new file mode 100644
index 0000000000..78d3419b60
--- /dev/null
+++ b/ext/pdo_oci/tests/bug_33707.phpt
@@ -0,0 +1,30 @@
+--TEST--
+PDO OCI Bug #33707
+--SKIPIF--
+<?php
+if (!extension_loaded('pdo') || !extension_loaded('pdo_oci')) die('skip not loaded');
+require 'ext/pdo_oci/tests/config.inc';
+require 'ext/pdo/tests/pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+require 'ext/pdo/tests/pdo_test.inc';
+$db = PDOTest::test_factory('ext/pdo_oci/tests/common.phpt');
+$db->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_SILENT);
+
+$rs = $db->query('select blah from a_table_that_doesnt_exist');
+var_dump($rs);
+var_dump($db->errorInfo());
+
+--EXPECTF--
+bool(false)
+array(3) {
+ [0]=>
+ string(5) "HY000"
+ [1]=>
+ int(942)
+ [2]=>
+ string(113) "OCIStmtExecute: ORA-00942: table or view does not exist
+ (%s:%d)"
+}