Bug #72311 SQLCloseCursor Does Not Return Correct Error
Submitted: 10 Apr 2014 19:25
Reporter: Lawrenty Novitsky Email Updates:
Status: Verified Impact on me:
None 
Category:Connector / ODBC Severity:S3 (Non-critical)
Version:5.3.2 OS:Any
Assigned to: CPU Architecture:Any

[10 Apr 2014 19:25] Lawrenty Novitsky
Description:
SQLCloseCursor simply forwards request to SQLFreeStmt(SQL_CLOSE)

But "SQLCloseCursor returns SQLSTATE 24000 (Invalid cursor state) if no cursor is open. Calling SQLCloseCursor is equivalent to calling SQLFreeStmt with the SQL_CLOSE option, with the exception that SQLFreeStmt with SQL_CLOSE has no effect on the application if no cursor is open on the statement, while SQLCloseCursor returns SQLSTATE 24000 (Invalid cursor state)."

(http://msdn.microsoft.com/en-us/library/ms709301%28v=vs.85%29.aspx)

How to repeat:
SQLExecDirect(hstmt, <any ddl statement>);
SQLCloseCursor(hstmt);

Supposed to return SQL_ERROR and 24000 sql state

Suggested fix:
Add check of resultset existence to SQLClosrCursor