1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

ext/pdo_odbc: Do not populate message if there is no driver error (#17478)

This commit is contained in:
Gina Peter Banyard
2025-01-15 20:46:08 +00:00
committed by GitHub
parent 951d2f81c7
commit df8ac4af91
2 changed files with 8 additions and 3 deletions

View File

@@ -43,18 +43,18 @@ PDOTest::dropTableIfExists($db, "test38253");
--EXPECTF--
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: No fetch class specified in %s on line %d
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error%s on line %d
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
array(0) {
}
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: No fetch function specified in %s on line %d
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error%s on line %d
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
array(0) {
}
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error: No fetch-into object specified. in %s on line %d
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error%s on line %d
Warning: PDOStatement::fetchAll(): SQLSTATE[HY000]: General error in %s on line %d
array(0) {
}

View File

@@ -41,6 +41,11 @@ static void pdo_odbc_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *in
einfo = &S->einfo;
}
/* If we don't have a driver error do not populate the info array */
if (strlen(einfo->last_err_msg) == 0) {
return;
}
message = strpprintf(0, "%s (%s[%ld] at %s:%d)",
einfo->last_err_msg,
einfo->what, (long) einfo->last_error,