fix seg fault

This commit is contained in:
v-kaywon 2017-03-29 11:26:45 -07:00
parent 20806e6872
commit 0fd7ebb6d3

View file

@ -2041,19 +2041,19 @@ namespace core {
SQLSMALLINT num_cols;
r = ::SQLNumResultCols( stmt->handle(), &num_cols );
// Workaround for a bug in unixODBC: after SQLExecDirect returns SQL_NO_DATA,
// r = ::SQLNumResultCols( stmt->handle(), &num_cols );
// returns r=-1 (SQL_ERROR) and error HY010 (Function sequence error)
// but it should have succeeded with r=0 (SQL_SUCCESS) and no error
// instead of throwing an exception, return 0 if the r=-1, stament has been executed, and has a HY010 error
// (HY010 error should not return if stmt->execute is true)
// Workaround for a bug in unixODBC: after SQLExecDirect returns SQL_NO_DATA,
// r = ::SQLNumResultCols( stmt->handle(), &num_cols );
// returns r=-1 (SQL_ERROR) and error HY010 (Function sequence error)
// but it should have succeeded with r=0 (SQL_SUCCESS) and no error
// instead of throwing an exception, return 0 if the r=-1, stament has been executed, and has a HY010 error
// (HY010 error should not return if stmt->execute is true)
#ifndef _WIN32
sqlsrv_error_auto_ptr error;
if ( stmt->current_results != NULL ) {
error = stmt->current_results->get_diag_rec( 1 );
}
if ( r == -1 && stmt->executed && strcmp( reinterpret_cast<const char*>( error->sqlstate ), "HY010" ) == 0 )
return 0;
sqlsrv_error_auto_ptr error;
if ( stmt->current_results != NULL ) {
error = stmt->current_results->get_diag_rec( 1 );
if ( r == -1 && stmt->executed && strcmp( reinterpret_cast<const char*>( error->sqlstate ), "HY010" ) == 0 )
return 0;
}
#endif // !_WIN32
CHECK_SQL_ERROR_OR_WARNING( r, stmt ) {
throw CoreException();