Problem in odbc.pyd
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
hi,
I was trying to use the odbc.pyd provinded in the win32 , but faces with a interesting problem, when ever the sql server goes down or the lan connection between my python program to the SQL server goes down, my python program seems to crash. While troubleshooting the odbc code, i came across the usage of SQLFreeStmt function. This function seems to be removed after odbc V3.0 (http://msdn2.microsoft.com/en-us/library/ms131681.aspx). And this is the same statements that is causing the pyd file to crash too. How can i get around this problem???
regards
Satish
Logged In: YES
user_id=771074
Originator: NO
SQLFreeStmt should probably be replaced, but the main problem is
with the reconnect logic. In attemptReconnect, cur->hstmt is freed
unconditionally using this function but the value is never reset.
A second attempt to reconnect will crash since the handle is already
invalidated. One solution would be to set the hstmt to NULL when it's
freed, and check for NULL before using it or trying to free it again.
As a workaround in Python code, you might be able to just create a
new cursor when you get disconnected. However, it might still crash
when deallocating the original cursor since the cursor destructor
will also call SQLFreeStmt with the invalid handle.
Logged In: YES
user_id=771074
Originator: NO
Rev 1.20 of odbc.cpp should fix this.