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

Nick Gorham nick at lurcher.org
Fri Jun 24 09:34:51 BST 2011

On 24/06/11 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.
> Thanks,
> Andy.

Yep, just checked the code. Once the count of connections to a driver 
reduces to zero that driver is disconnected. I don't see any other 
action the driver manager could take, hold onto the driver (and possibly 
100 others) just in case the app decides to use it again. If thats a 
problem for your driver then you can disable it by enabling pooling into 
the driver manager.


More information about the unixODBC-support mailing list