microsoft / ODBC-Specification

Microsoft ODBC Specification
Other
121 stars 40 forks source link

How timeouts work, and how different timeouts (Connection/Login/Query) interact is not clear #137

Open matthew-wozniczka opened 6 years ago

matthew-wozniczka commented 6 years ago

SQL_ATTR_CONNECTION_TIMEOUT has the following description (on https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlsetconnectattr-function?view=sql-server-2017)

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.

From this, I had assumed that 'request on the connection' referred to any ODBC API function called on the connection handle (or one of it's child statements or descriptors), since it followed with 'before returning to the application'), but then I realized it was strange that many ODBC functions were documented to return, for example, both HYT00 and HYT01.

Is this a documentation error? Or does it use the minimum of the timeouts, and use that?

Also, the documentation for SQL_ATTR_QUERY_TIMEOUT (on https://docs.microsoft.com/en-us/sql/odbc/reference/syntax/sqlsetstmtattr-function?view=sql-server-2017 ) says

An SQLULEN value corresponding to the number of seconds to wait for an SQL statement to execute before returning to the application. If ValuePtr is equal to 0 (default), there is no timeout.

But it never really defines what counts as a SQL statement executing. I had thought it referred to SQLExecute & SQLExecDirect (and probably also SQLPrepare), but it shows up on a lot of other functions.