[freetds] Done handling

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Mon Jul 4 03:40:12 EDT 2005


I'm doing some test with token processing. The reason is to discover
when proprietary libraries process tokens. I used dblib cause is the
oldest and native library (also cause is simpler than ODBC).
I attacched the program I used for test. Mainly it issue a query and try
to detect the state, particularly:
- row count available (valid number means DONE processed)
- if possible to send another query (means state IDLE)
- if error readed (means ERROR token readed)
- if status present (PARAMRESULT token readed)
- if parameter prosent (PARAM token readed)

Here is results (I used a Sybase 11.9.2 server):

----- start -----
Msg 5701, Level 0, State 2
Line 1
	Changed database context to 'master'.
Msg 5703, Level 0, State 1
Line 1
	Changed language setting to 'us_english'.
query: create table #dummy (s char(10))
query: insert into #dummy values('xxx')
query: drop proc done_test
query: create proc done_test @a varchar(10) output as select * from
#dummy

test query "select * from #dummy"
sqlexec State 
nextrow State 
nextrow State 
results State COLS(1) 
nextrow State COLS(1) ROWS(1) IDLE 
nextrow State IDLE 
results State IDLE 
query: set nocount on

test query "select * from #dummy"
sqlexec State 
nextrow State 
nextrow State 
results State COLS(1) 
nextrow State COLS(1) IDLE 
nextrow State IDLE 
results State IDLE 
query: set nocount off

test query "select * from #dummy where 0=1"
sqlexec State 
nextrow State 
nextrow State 
results State COLS(1) ROWS(0) IDLE 
nextrow State IDLE 
nextrow State IDLE 
results State IDLE 

test query "select (1/(3-3)) from #dummy"
sqlexec State 
nextrow State 
nextrow State 
results State ERROR COLS(1) IDLE 
nextrow State IDLE 
nextrow State IDLE 
results State IDLE 

test query "select dklghdlgkh from #dummy"
sqlexec State ERROR IDLE 
nextrow State IDLE 
nextrow State IDLE 
results State IDLE 

test query "declare @s varchar(10) exec done_test @s output"
sqlexec State 
nextrow State 
nextrow State 
results State COLS(1) 
nextrow State COLS(1) ROWS(1) PARAMS IDLE 
nextrow State IDLE 
results State IDLE 

test query "declare @i int"
sqlexec State IDLE 
nextrow State IDLE 
nextrow State IDLE 
results State IDLE 
query: set nocount on

test query "select * from #dummy where 0=1 select * from #dummy where
0=1"
sqlexec State 
nextrow State 
nextrow State 
results State COLS(1) 
nextrow State COLS(1) 
nextrow State COLS(1) 
results State COLS(1) IDLE 
nextrow State IDLE 
nextrow State IDLE 
results State IDLE 

test query "select * from #dummy where 0=1 set nocount off select * from
#dummy where 0=1"
sqlexec State 
nextrow State 
nextrow State 
results State COLS(1) 
nextrow State COLS(1) 
nextrow State COLS(1) 
results State 
nextrow State 
nextrow State 
results State COLS(1) ROWS(0) IDLE 
nextrow State IDLE 
nextrow State IDLE 
results State IDLE 

test query "select * from #dummy where 0=1 select (1/(3-3)) from #dummy"
sqlexec State 
nextrow State 
nextrow State 
results State COLS(1) ROWS(0) 
nextrow State COLS(1) ROWS(0) 
nextrow State COLS(1) ROWS(0) 
results State ERROR COLS(1) IDLE 
nextrow State IDLE 
nextrow State IDLE 
results State IDLE 

test query "select (1/(3-3)) from #dummy insert into #dummy
values('aaa')"
sqlexec State 
nextrow State 
nextrow State 
results State ERROR COLS(1) IDLE 
nextrow State IDLE 
nextrow State IDLE 
results State IDLE 

test query "insert into #dummy values('aaa') delete #dummy where s =
'bbb' insert into #dummy values('bbb') select * from #dummy where 0=1"
sqlexec State ROWS(1) 
nextrow State ROWS(1) 
nextrow State ROWS(1) 
results State ROWS(1) 
nextrow State ROWS(1) 
nextrow State ROWS(1) 
results State ROWS(0) 
nextrow State ROWS(0) 
nextrow State ROWS(0) 
results State ROWS(1) 
nextrow State ROWS(1) 
nextrow State ROWS(1) 
results State COLS(1) ROWS(0) IDLE 
nextrow State IDLE 
nextrow State IDLE 
results State IDLE 

test query "delete #dummy where s = 'bbb'"
sqlexec State ROWS(1) IDLE 
nextrow State IDLE 
nextrow State IDLE 
results State IDLE 
query: drop proc done_test
----- end -----

as you can note issuing a no row query (delete/insert/update) dblib read
DONE token and we can issue another query however the first dbresults
return SUCCEED. Note also the executing the store procedure library read
also tokens following DONE (like parameters).
Our library read much less tokens (I got a lot of "Attempt to initiate a
new SQL Server operation with results pending.").

freddy77
-------------- next part --------------
A non-text attachment was scrubbed...
Name: done_handling.c
Type: application/octet-stream
Size: 5229 bytes
Desc: done_handling.c
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20050704/6e5994a4/done_handling.obj


More information about the FreeTDS mailing list