From 7ef91de9b84537e3486816915391139cda1d7cab Mon Sep 17 00:00:00 2001 From: Gina Peter Banyard Date: Mon, 13 Jan 2025 13:31:49 +0000 Subject: [PATCH] ext/pdo_odbc: Do not populate message if there is no driver error --- ext/pdo/tests/bug_38253.phpt | 6 +++--- ext/pdo_odbc/odbc_driver.c | 12 ++++++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ext/pdo/tests/bug_38253.phpt b/ext/pdo/tests/bug_38253.phpt index d40c1b6e9746a..91d94d31aeef8 100644 --- a/ext/pdo/tests/bug_38253.phpt +++ b/ext/pdo/tests/bug_38253.phpt @@ -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) { } diff --git a/ext/pdo_odbc/odbc_driver.c b/ext/pdo_odbc/odbc_driver.c index 1ddce74f3f92c..640de63774d9b 100644 --- a/ext/pdo_odbc/odbc_driver.c +++ b/ext/pdo_odbc/odbc_driver.c @@ -41,10 +41,14 @@ static void pdo_odbc_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *in einfo = &S->einfo; } - message = strpprintf(0, "%s (%s[%ld] at %s:%d)", - einfo->last_err_msg, - einfo->what, (long) einfo->last_error, - einfo->file, einfo->line); + if (einfo->last_err_msg != NULL) { + message = strpprintf(0, "%s (%s[%ld] at %s:%d)", + einfo->last_err_msg, + einfo->what, (long) einfo->last_error, + einfo->file, einfo->line); + } else { + message = ZSTR_EMPTY_ALLOC(); + } add_next_index_long(info, einfo->last_error); add_next_index_str(info, message);