[freetds] Setting ODBC timeouts

James K. Lowden jklowden at freetds.org
Mon Aug 18 20:58:25 EDT 2008

Chris Reeves wrote:
> attributes using SQLSetConnectAttr and later calls to SQLGetConnectAttr
> suggest that these attributes have indeed been changed. Despite this, no
> matter what I set these two attributes to, the login always takes 40
> seconds to time out and the connection timeout appears to be 'infinite'.
> The timeouts in /etc/freetds/freetds.conf are both set to 1. The code
> I'm using runs along the following lines (but with additional error
> checking included - all calls return SQL_SUCCESS).

It works that way because that's the way the code was written.  :-/  

ODBC distinguishes between timeouts for connecting and logging in.  db-lib
does not, and the underlying function, tds_connect() appears not to,
either.  You are able to set and get SQL_ATTR_LOGIN_TIMEOUT and
SQL_ATTR_CONNECTION_TIMEOUT, but they're not used by tds_connect().  

I identified this area as something that needs to be addressed a little
while back.  Basically, we need one function that connects and one that
logs in, and each one can use its own timer.  I haven't had time to work
on it.  Patches welcome.  

Once the support functions are in place, wiring the ODBC layer to them
will be signficantly easier.  


More information about the FreeTDS mailing list