develooper Front page | perl.dbi.users | Postings from February 2008

Re: DBD::ODBC - default timeout is 30 seconds instead of none

Thread Previous
From:
Martin Evans
Date:
February 21, 2008 01:58
Subject:
Re: DBD::ODBC - default timeout is 30 seconds instead of none
Dino Kern wrote:
> Hello,
> I'm using  DBD::ODBC Version 1.13 and had following problem:
> Te connection timed out after exactly 30 seconds even when
> "odbc_query_timeout" was not set.
> According to the documentation there should be no timeout in this case.
> After setting the timeout to a higher value it worked.
> 
> Maybe the documentation has to be rectified to:
> "Default timeout is 30 second".
> 
> Best regards,
> Dino
> 
> 

Don't confuse connection timeout and query timeout - they are not the 
same. Connection timeout only applies to non login and query execution 
ODBC APIS.

The default in DBD::ODBC is actually to not set it at all because the 
current DBD::ODBC code sets the default internal variable 
odbc_query_timeout to 0 and then does:

if (imp_dbh->odbc_query_timeout) {
       ret = odbc_set_query_timeout(dbh, stmt,
               imp_dbh->odbc_query_timeout);
}

in the execdirect and prepare methods which obviously does not get run 
if odbc_query_timeout is 0.

The ODBC spec says:

o the default is 0 which is no timeout
o the driver may implement minimum and maximum values the timeout may be 
set to.

so not setting the query timeout should use the default of 0 or no 
timeout. I believe the DBD::ODBC code is correct in this other than if 
you were to set it to N (where N <> 0) then set it to 0, the second set 
would not get executed - I will rectify this.

I suspect the ODBC driver you are using is defaulting it to 30 as 
DBD::ODBC is not setting the timeout by default.

I will attempt to make this clearer in the pod for the next DBD::ODBC.

Martin
-- 
Martin J. Evans
Easysoft Limited
http://www.easysoft.com

Thread Previous


Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About