Skip to content

Commit af3d66c

Browse files
committed
Report errors with SQLGetDiagRec
This is usually a symptom of worse problems, like a libdb400/ODBC conflict, or broken libdb400. We should really report these kinds of issues, so they can be reported to us.
1 parent 2983984 commit af3d66c

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ibm_db2.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1016,14 +1016,15 @@ static void _php_db2_check_sql_errors( SQLHANDLE handle, SQLSMALLINT hType, int
10161016
SQLINTEGER sqlcode = 0;
10171017
SQLSMALLINT length = 0;
10181018
SQLCHAR *p = NULL;
1019+
SQLRETURN sqlrc;
10191020

10201021
memset(msg, '\0', SQL_MAX_MESSAGE_LENGTH + 1);
10211022
memset(sqlstate, '\0', SQL_SQLSTATE_SIZE + 1);
10221023
memset(errMsg, '\0', DB2_MAX_ERR_MSG_LEN);
10231024

1024-
if ( SQLGetDiagRec(hType, handle, recno, sqlstate, &sqlcode, msg,
1025-
SQL_MAX_MESSAGE_LENGTH + 1, &length) == SQL_SUCCESS ) {
1026-
1025+
sqlrc = SQLGetDiagRec(hType, handle, recno, sqlstate, &sqlcode, msg,
1026+
SQL_MAX_MESSAGE_LENGTH + 1, &length);
1027+
if (sqlrc == SQL_SUCCESS) {
10271028
#ifdef PHP_WIN32
10281029
if (msg[length-2] == '\r') {
10291030
p = &msg[length-2];
@@ -1080,6 +1081,8 @@ static void _php_db2_check_sql_errors( SQLHANDLE handle, SQLSMALLINT hType, int
10801081
default:
10811082
break;
10821083
}
1084+
} else {
1085+
php_error_docref(NULL, E_WARNING, "SQLGetDiagRec failed (is the driver working?)");
10831086
}
10841087
}
10851088
/* }}} */

0 commit comments

Comments
 (0)