[freetds] TDS_DONE_TOKEN

ZIGLIO Frediano Frediano.Ziglio at vodafoneomnitel.it
Wed Apr 30 11:49:48 EDT 2003


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



More information about the FreeTDS mailing list