[freetds] FreeTDS and Ubuntu, iodbc

Dan Mohn mohnd at egolfscore.com
Thu Apr 19 13:26:42 EDT 2007


>> However, I decided to try something with iodbctest.  I connected to
the above dsn with iodbctest.  Then I did a select * from a table with
about 1000 rows, it returned the data.  I did the select again, but this
time after it started spitting stuff back, I pulled the network plug.
After waiting bout 20 minutes, it still had not responded back.<<

On the iodbctest I ran, I came back the next morning and it reported the
following;

1: Fetch = [FreeTDS] [SQL Server] Read from the server failed (20004)
SQLSTATE=08501   

result set 1 returned 251 rows.   

1: SQLMoreResults = [FreeTDS] [SQL Server] Unknown error (0)
SQLSTATE=HY000   


On bsqlodbc, after your clarification, I also found it doesn't like the
space in the dsn name, ie, "eGolfScore Prod", so I changed it to
eGolfScoreProd and it connected.

My ODBC.ini and freetds.conf are;

---------odbc.ini begin
[ODBC Data Sources]
eGolfScoreProd = FREETDS Connection

[eGolfScoreProd]
Driver          = /usr/local/freetds/lib/libtdsodbc.so
Description     = eGolfScore Prod
Trace           = No
;Server		= <x>.<x>.<x>.<x>
Servername	= eGolfScoreTDS

[SQL Server]
Driver          = /usr/local/freetds/lib/libtdsodbc.so
---------odbc.ini end
---------freetds.conf section begin
[eGolfScoreTDS]
	host = <x>.<x>.<x>.<x>
	port = 1433
	tds version = 7.0
	timeout = 10
	connect timeout = 10
---------freetds.conf section end

So I ran my first test with bsqlodbc;

administrator at ubuntu-edgy:~$ /usr/local/freetds/bin/bsqlodbc -S
eGolfScoreProd -U <XX> -P <XX> -i timeouttest_bodbc.sql
Name
rowstat
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  ----------
AWL - Centerton Event
1
"[FreeTDS][SQL Server]%READY TO FETCH NEXT%"
"[FreeTDS][SQL Server]%Orlando Show Event%"
"[FreeTDS][SQL Server]%READY TO FETCH NEXT%"
"[FreeTDS][SQL Server]%International Event%"
"[FreeTDS][SQL Server]Waiting 30 seconds for timeout."
"[FreeTDS][SQL Server]%READY TO FETCH NEXT%"
"[FreeTDS][SQL Server]%Rogers Presidents Golf Classic%"
"[FreeTDS][SQL Server]Waiting 30 seconds for timeout."
"[FreeTDS][SQL Server]%READY TO FETCH NEXT%"
"[FreeTDS][SQL Server]%Augusta Hooters Store Tournament%"
"[FreeTDS][SQL Server]%READY TO CLOSE%"
"[FreeTDS][SQL Server]%READY TO DEALLOCATE%"
"[FreeTDS][SQL Server]%DONE%"

timeouttest_bodbc.sql is ;

----------begin timeouttest_bodbc.sql
DECLARE @Count int
declare @NamePrint nvarchar(255)
SET @Count = 0

DECLARE c1 cursor
FOR
SELECT Name
   from eGolfOutings.dbo.Outing

OPEN c1
FETCH NEXT FROM c1

WHILE @@fetch_status = 0 AND @Count < 4
BEGIN
	SET @Count = @Count + 1
	IF @Count > 2
	BEGIN
	   PRINT 'Waiting 30 seconds for timeout.'
	   WAITFOR DELAY '00:00:30'
	END
	PRINT '%READY TO FETCH NEXT%'
	FETCH NEXT FROM c1 into @NamePrint
	PRINT '%' + @NamePrint + '%'

END

PRINT '%READY TO CLOSE%'
CLOSE c1

PRINT '%READY TO DEALLOCATE%'
DEALLOCATE c1

PRINT '%DONE%'
------------end timeouttest_bodbc.sql

Since the timeouts was set to 10, I would expect a timeout to have
occurred at the WAITFOR.  But it continues on ok.

For the 2nd test, I set the freetds.conf timeouts to 100, so they
wouldn't timeout at the WAITFOR, then after 20 seconds, (even though it
wasn't timing out anyway, but just to be safe) I pull the cable.  I did
this about an hour ago, but no response back.  I'll let it sit overnight
and see if it eventually comes back with an error.

I will note that on one of my previous tests while I was working on
getting the code correct I pulled the plug, and put it back in a few
minutes later, tsqlodbc reported back;

bsqlodbc: error -1: SQLExecute: SQL_ERROR: failed
bsqlodbc: error 20004: 08S01: [FreeTDS][SQL Server]Read from the server
failed

Which is what I expect to get from the current test if it ever returns
anything, but we'll see.

I hope this all isn't too confusing...

So is the question how does iodbc catch a timeout error?

Dan

On Tue, 2007-04-17 at 20:38 -0400, James K. Lowden wrote:
It could be the error handling (not generation).  I would like to know
> what bsqlodbc does.  Beyond that, I'm a little lost.  Freddy's unit
test
> works; I expect my bsqlodbc to work too.  If they do, that suggests
> problems *catching* the error, something that might exist in
RealBasic,
> too.  If bsqlodbc fails, then we clearly have work to do on our end. 
> 
> I appreciate your patience.  It's good feed back for us. 
> 
> Regards,
> 
> --jkl
> 


More information about the FreeTDS mailing list