Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

status_exception thrown and caught on every access due to trying to close already closed cursor (patch) [ODBC29] #30

Closed
firebird-automations opened this issue Jul 19, 2007 · 8 comments

Comments

@firebird-automations
Copy link

Submitted by: Vaclav Slavik (vslavik)

Assigned to: Vladimir Tsvigun (praktik)

Attachments:
IscStatement.cpp.HEAD.patch

When using ODBC driver against embedded Firebird server, my application would throw and catch status_exception during every ODBC query. The exception was caught, so this was only annoying because it polluted debug log when running under VC++ debugger, plus it has performance impact, but it's not fatal.

Turns out that it happens because for auto-commit transactions, IscStatement::deleteResultSet() first calls commitAuto(), which closes the cursor, and then calls _dsql_free_statement() with DSQL_close flag, i.e. it requests that the cursor is closed. This fails because the cursor was already closed and status_exception is thrown.

Attached patch (against CVS HEAD) fixes this.

Commits: f06d8f2

@firebird-automations
Copy link
Author

Commented by: Vaclav Slavik (vslavik)

Patch with the fix.

@firebird-automations
Copy link
Author

Modified by: Vaclav Slavik (vslavik)

Attachment: IscStatement.cpp.HEAD.patch [ 10490 ]

@firebird-automations
Copy link
Author

Commented by: Vladimir Tsvigun (praktik)

Hi!

> + USHORT option = 0;
> if (connection->autoCommit)
> connection->commitAuto();
> - // Close cursors too.
> + else
> + option = DSQL_close; // Close cursors too.

It's bad variant. If the execute connection->commitAuto(); and
typeStmt == stmtSelect && openCursor (it's use commitRetaining)
then the cursor will be never closed

Check up
if ( isActiveCursor() )
{
ISC_STATUS statusVector [20];
connection->GDS->_dsql_free_statement (statusVector, &statementHandle, DSQL_close);
if ( statusVector[1] )
THROW_ISC_EXCEPTION (connection, statusVector);
}

And please use FbODBC ver 2.0
And please inform result
Thanks
--
Best regards,
Vladimir Tsvigun

@firebird-automations
Copy link
Author

Commented by: Vaclav Slavik (vslavik)

Works for me, thanks!

@firebird-automations
Copy link
Author

Commented by: Pabloj (pabloj_sourceforge)

Did this go into the official code?

@firebird-automations
Copy link
Author

Commented by: @samofatov

Yes, it seems so.

cvs diff -u -r 1.18.2.15 -r 1.18.2.16 IscStatement.cpp

Index: IscStatement.cpp

RCS file: /cvsroot/firebird/OdbcJdbc/IscDbc/IscStatement.cpp,v
retrieving revision 1.18.2.15
retrieving revision 1.18.2.16
diff -u -u -r1.18.2.15 -r1.18.2.16
--- IscStatement.cpp 22 Mar 2007 17:44:27 -0000 1.18.2.15
+++ IscStatement.cpp 26 Aug 2007 17:21:05 -0000 1.18.2.16
@@ -559,8 +559,6 @@
resultSets.deleteItem (resultSet);
if (resultSets.isEmpty())
{
- openCursor = false;
- typeStmt = stmtNone;
if ( connection )
{
if ( transactionLocal )
@@ -570,13 +568,20 @@
}
else if ( connection->transactionInfo.autoCommit )
connection->commitAuto();
- // Close cursors too.
- ISC_STATUS statusVector[20];
- connection->GDS->_dsql_free_statement( statusVector, &statementHandle, DSQL_close );
- // Cursor already closed or not assigned
- if ( statusVector[1] && statusVector[1] != 335544569 )
- THROW_ISC_EXCEPTION (connection, statusVector);
+
+ if ( isActiveCursor() )
+ {
+ // Close cursors too.
+ ISC_STATUS statusVector[20];
+ connection->GDS->_dsql_free_statement( statusVector, &statementHandle, DSQL_close );
+ // Cursor already closed or not assigned
+ if ( statusVector[1] && statusVector[1] != 335544569)
+ THROW_ISC_EXCEPTION (connection, statusVector);
+ }
}
+
+ openCursor = false;
+ typeStmt = stmtNone;
}
}

@firebird-automations
Copy link
Author

Modified by: @alexpotapchenko

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Fixed [ 1 ]

Fix Version: 2.0 Beta [ 10043 ]

@firebird-automations
Copy link
Author

Modified by: @alexpotapchenko

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant