Skip to content

Commit e496123

Browse files
morozovramsey
authored andcommitted
[Bug #77120] Handle OCI_SUCCESS_WITH_INFO returned from OCIStmtExecute
1. Backup last_error before replacing it with the error code 2. Continue normal operations if last_error is OCI_SUCCESS_WITH_INFO
1 parent ee51eac commit e496123

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
lines changed

ext/pdo_oci/oci_driver.c

+6-2
Original file line numberDiff line numberDiff line change
@@ -336,9 +336,13 @@ static zend_long oci_handle_doer(pdo_dbh_t *dbh, const zend_string *sql) /* {{{
336336
H->last_err = OCIStmtExecute(H->svc, stmt, H->err, 1, 0, NULL, NULL,
337337
(dbh->auto_commit && !dbh->in_txn) ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT);
338338

339-
if (H->last_err) {
339+
sword last_err = H->last_err;
340+
341+
if (last_err) {
340342
H->last_err = oci_drv_error("OCIStmtExecute");
341-
} else {
343+
}
344+
345+
if (!last_err || last_err == OCI_SUCCESS_WITH_INFO) {
342346
/* return the number of affected rows */
343347
H->last_err = OCIAttrGet(stmt, OCI_HTYPE_STMT, &rowcount, 0, OCI_ATTR_ROW_COUNT, H->err);
344348
ret = rowcount;

ext/pdo_oci/tests/oci_success_with_info.phpt

+37
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,17 @@ SQL
4343
);
4444
}
4545

46+
function triggerCompilationError(PDO $conn): void {
47+
$conn->exec(<<<'SQL'
48+
CREATE OR REPLACE FUNCTION BUG77120(INT A) RETURN INT
49+
AS
50+
BEGIN
51+
RETURN 0;
52+
END;
53+
SQL
54+
);
55+
}
56+
4657
require __DIR__ . '/../../pdo/tests/pdo_test.inc';
4758

4859
$conn = connectAsAdmin();
@@ -66,6 +77,14 @@ $conn = connectAsAdmin();
6677
dropUser($conn);
6778
dropProfile($conn);
6879

80+
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
81+
triggerCompilationError($conn);
82+
var_dump($conn->errorInfo());
83+
84+
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
85+
triggerCompilationError($conn);
86+
var_dump($conn->errorInfo());
87+
6988
?>
7089
--EXPECTF--
7190
array(3) {
@@ -77,3 +96,21 @@ array(3) {
7796
string(%d) "OCISessionBegin: OCI_SUCCESS_WITH_INFO: ORA-28002: %s
7897
(%s:%d)"
7998
}
99+
array(3) {
100+
[0]=>
101+
string(5) "HY000"
102+
[1]=>
103+
int(24344)
104+
[2]=>
105+
string(%d) "OCIStmtExecute: OCI_SUCCESS_WITH_INFO: ORA-24344: %s
106+
(%s:%d)"
107+
}
108+
array(3) {
109+
[0]=>
110+
string(5) "HY000"
111+
[1]=>
112+
int(24344)
113+
[2]=>
114+
string(%d) "OCIStmtExecute: OCI_SUCCESS_WITH_INFO: ORA-24344: %s
115+
(%s:%d)"
116+
}

0 commit comments

Comments
 (0)