[unixODBC-support] Why does SQLDisconnect trigger a call to SQLFreeHandle(SQL_HANDLE_ENV) ?

Nick Gorham nick at lurcher.org
Fri Jun 24 07:56:43 BST 2011

On 24/06/2011 05:05, Andy Grove wrote:
> Hi,
> I'm using unixODBC 2.3.0 with a custom ODBC driver that I have 
> developed and I've encountered a confusing issue in one customer 
> environment where it appears that unixODBC is calling 
> SQLFreeHandle(SQL_HANDLE_ENV) immediately after a call to 
> SQLDisconnect() even though the application hasn't requested that the 
> environment be freed.
> I've been debugging this for several hours and can't see any other 
> possibility but this doesn't seem like correct behavior. I'd 
> appreciate any suggestions/feedback on this. Is it possible that 
> unixODBC would be doing this? The call to SQLDisconnect would bring 
> the connection count down to zero if that is any help. The customer's 
> environment is a Python/Django application deployed in the fastcgi 
> application server.
> I can provided detailed debug logs as well if that helps.

Well, I will take a look, but remember you do have the unixODBC code 
available to check exactly what its doing.

My guess is that the SQLDisconnect is unloading the library as its the 
last connection that has it open, so It will be disconnecting the app 
and driver handles from each other, they are only linked between a 
conect untill a disconnect. Even though the app still has a conn handle, 
its not connected to the driver, and could be used to connect next to a 
entirly different driver, so at a guess I can understand why I coded it 
to calls free handle on the driver conn and env handle at a all 


More information about the unixODBC-support mailing list