[freetds] TDS_DONE_TOKEN

Thompson, Bill D (London) ThompBil at exchange.uk.ml.com
Wed Apr 30 12:01:16 EDT 2003


Aaah Freddy,

I'm working on very similar stuff, although other work (at my end) and the
charset stuff has caused me to set it aside for a while.

What I've done is to change tds_process_result_tokens so that it returns to
the calling function both the type of done token processed (so I've got
TDS_DONE_RESULT, TDS_DONEPROC_RESULT and TDS_DONEINPROC result types) and
also the done_flags ( a new parameter to tds_process_result_tokens). The
calling API (in my case ctlibrary) can make more informed decisions about
what to do.
TDS_CMD_DONE (and TDS_CMD_SUCCEED and TDS_CMD_FAIL) have been stripped out
of tds_process_result_tokens, and the processing (working out whether a
command succeeded or failed) is devolved to the calling API.

This is important as dblibrary and ctlibrary behave differently, and tryinfg
to handle the different behaviours in the generic function was causing any
number of problems.

I am pretty sure that after these changes, it will be possible to free the
result structure(s) at the proper time, and not when a query is submitted.

I was holding back on finishing these changes until James is finished and
the code settles down a bit after the charset changes....

Bill




> -----Original Message-----
> From:	ZIGLIO Frediano [SMTP:Frediano.Ziglio at vodafoneomnitel.it]
> Sent:	30 April 2003 16:50
> To:	Freetds (E-mail)
> Subject:	[freetds] TDS_DONE_TOKEN
> 
> There are some problem that seem to raise at every version of FreeTDS :
>  cancelling and done handling
> 
> See this report (from last CVS trying dynamic with ODBC)
> 
> Sending packet @ 2003-04-30 17:36:48.582873
> 0000  03 01 00 52 00 00 01 00  72 ed 68 e3 5e d9 54 cf   |...R....
> r.h.^.T.|
> 0010  4a c5 40 bb 36 b1 2c a7  22 9d 18 93 0e 89 04 7f   |J. at .6.,.
> ".......|
> 0020  fa 75 f0 6b e6 61 dc 57  d2 4d c8 43 be 39 b4 2f   |.u.k.a.W
> .M.C.9./|
> 0030  aa 25 a0 1b 96 11 8c 07  82 fd 78 f3 6e e9 64 df   |.%......
> ..x.n.d.|
> 0040  5a d5 50 cb 46 c1 3c b7  32 ad 28 a3 1e 99 14 8f   |Z.P.F.<.
> 2.(.....|
> 0050  0a 85                                              |..|
> 
> 
> Received header @ 2003-04-30 17:36:48.846462
> 0000  04 01 00 1f 00 37 01 00                            |.....7..|
> 
> 
> Received packet @ 2003-04-30 17:36:48.846617
> 0000  ff 11 00 c3 00 01 00 00  00 79 00 00 00 00 fe 00   |........
> .y......|
> 0010  00 e0 00 01 00 00 00                               |.......|
> 
> 
> 2003-04-30 17:36:48.846826 processing result tokens.  marker is
> ff(DONEINPROC)
> 2003-04-30 17:36:48.846920 inside tds_process_end() more_results = 1,
> was_cancelled = 0
> SQLFreeHandle(3, 0x8075970)
> 2003-04-30 17:36:48.847929 tds_put_string converting 26 bytes of "select *
> from #binary_test"
> 2003-04-30 17:36:48.848070 tds_put_string wrote 52 bytes
> Sending packet @ 2003-04-30 17:36:48.848159
> 0000  01 01 00 3c 00 00 01 00  73 00 65 00 6c 00 65 00   |...<....
> s.e.l.e.|
> 0010  63 00 74 00 20 00 2a 00  20 00 66 00 72 00 6f 00   |c.t. .*.
> .f.r.o.|
> 0020  6d 00 20 00 23 00 62 00  69 00 6e 00 61 00 72 00   |m. .#.b.
> i.n.a.r.|
> 0030  79 00 5f 00 74 00 65 00  73 00 74 00               |y._.t.e. s.t.|
> 
> 
> 2003-04-30 17:36:48.848590 processing result tokens.  marker is
> 79(RETURNSTATUS)
> 2003-04-30 17:36:48.848713 processing result tokens.  marker is
> fe(DONEPROC)
> 2003-04-30 17:36:48.848800 inside tds_process_end() more_results = 0,
> was_cancelled = 0
> 2003-04-30 17:36:48.848900 inside tds_process_result_tokens() state is
> COMPLETED
> SQLFreeHandle(3, 0x8072da0)
> SQLFreeHandle(3, 0x8073850)
> 
> Why libTDS send a query if there are still results ??? (see select and
> then RETURNSTATUS and DONEPROC processing)
> 
> We have 5 state
> 	TDS_QUERYING,
> 	TDS_PENDING,
> 	TDS_COMPLETED,
> 	TDS_CANCELED,
> 	TDS_DEAD
> (CANCELED never used... I added this state, if I remember)
> Before sending a query we test if state is PENDING. However PENDING is set
> in token.c (processing some data) while after a query state is QUERING
> (why two different states??). I think test should be changed from "if
> (tds->state != TDS_PENDING) ..." to "if (tds->state != TDS_COMPLETED)
> ...". Does this sound ok (so we don't send query in DEAD state too...) ?
> 
> IMHO we should discard result receiving TDS_DONE, not on next query. What
> do you think about?
> 
> Also TDS_CMD_DONE is returned for both ending DONE and internal DONE (like
> DONE from statements in RPC). How to distinguish the two cases? Test
> TDS_COMPLETED state? For example in the above dump I insert a row using
> dynamic. Server return
> - DONE, 1 row (insert)
> - RETURNSTATUS (using dynamic is like creating a store procedure)
> - DONE, no row (end of dummy store)
> (perhaps I should return on first and ignore all below...)
> 
> freddy77
> _______________________________________________
> FreeTDS mailing list
> FreeTDS at lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds



More information about the FreeTDS mailing list