[freetds] Connection timeout
Suren A. Chilingaryan
csa at dside.dyndns.org
Thu Jul 10 09:30:22 EDT 2008
Dear James and Frediano,
I'm not completely sure, but it seems to me there is a minor mistake in
the FreeTDS ODBC driver which is violating ODBC specification.
Basically, 3 different timeouts are defined in the ODBC spec:
c) and query timeout, which is not important in this case
The MSDN states (http://msdn.microsoft.com/en-us/library/ms713605.aspx):
a) SQL_ATTR_CONNECTION_TIMEOUT: An SQLUINTEGER value corresponding to
the number of seconds to wait for any request on the connection to
complete before returning to the application. The driver should return
SQLSTATE HYT00 (Timeout expired) anytime that it is possible to time out
in a situation not associated with query execution or login.
b) SQL_ATTR_LOGIN_TIMEOUT: An SQLUINTEGER value corresponding to the
number of seconds to wait for a login request to complete before
returning to the application. The default is driver-dependent. If
ValuePtr is 0, the timeout is disabled and a connection attempt will
This, means what SQL_ATTR_LOGIN_TIMEOUT should define timeout for
The FreeTDS library (src/tds/login.c, 'tds_connect' function) uses
'connection->connect_timeout' to define timeout for tds_connect. This
'connection->connect_timeout' is defined by FreeTDS configuration file
or by FreeTDS ODBC driver (src/odbc/odbc.c, 'odbc_connect' function).
In the last case the 'dbc->attr.connection_timeout' is used. However,
'connection_timeout' is actually related 'SQL_ATTR_CONNECTION_TIMEOUT'
ODBC connection attribute.
From my point of view, the 'dbc->attr.login_timeout' (related to
'SQL_ATTR_LOGIN_TIMEOUT') should be used instead.
Since, 'connection->connect_timeout' is only used by ;tds_connect', just
changing it's initialization from 'dbc->attr.connection_timeout' to
If you'll accept that, the patch could be found:
More information about the FreeTDS