summaryrefslogtreecommitdiff
path: root/ext/odbc
diff options
context:
space:
mode:
authorAntony Dovgal <tony2001@php.net>2007-02-19 20:22:38 (GMT)
committerAntony Dovgal <tony2001@php.net>2007-02-19 20:22:38 (GMT)
commit19c517938e8bcfc59d3d1c91fb562bf00992fedb (patch)
treec0edb0cec3d47ecddc4cb516262df19c517e1d11 /ext/odbc
parent13ca6ed9fa4a410839026585d252d3e0a9bd05b1 (diff)
downloadphp-19c517938e8bcfc59d3d1c91fb562bf00992fedb.tar.gz
MFH: check SQLError() return value and output a meaningful errmsg when it fails
Diffstat (limited to 'ext/odbc')
-rw-r--r--ext/odbc/php_odbc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/ext/odbc/php_odbc.c b/ext/odbc/php_odbc.c
index 0937443..bb97e27 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;
}