From: Antony Dovgal Date: Mon, 19 Feb 2007 20:22:38 +0000 (+0000) Subject: MFH: check SQLError() return value and output a meaningful errmsg when it fails X-Git-Tag: php-5.2.2RC1~360 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=19c517938e8bcfc59d3d1c91fb562bf00992fedb;p=php MFH: check SQLError() return value and output a meaningful errmsg when it fails --- diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c index 09374431c8..bb97e27c59 100644 --- a/ext/odbc/php_odbc.c +++ b/ext/odbc/php_odbc.c @@ -587,6 +587,10 @@ void odbc_sql_error(ODBC_SQL_ERROR_PARAMS) do { */ rc = SQLError(henv, conn, stmt, state, &error, errormsg, sizeof(errormsg)-1, &errormsgsize); + if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) { + sprintf(state, "HY000"); + sprintf(errormsg, "Failed to fetch error message"); + } if (conn_resource) { memcpy(conn_resource->laststate, state, sizeof(state)); memcpy(conn_resource->lasterrormsg, errormsg, sizeof(errormsg)); @@ -1224,7 +1228,7 @@ PHP_FUNCTION(odbc_data_source) if (rc != SQL_SUCCESS) { /* ummm.... he did it */ - odbc_sql_error(conn, NULL, "SQLDataSources"); + odbc_sql_error(conn, SQL_NULL_HSTMT, "SQLDataSources"); RETURN_FALSE; }