freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: Frediano Ziglio <freddy77 AT gmail.com>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] ct-lib error handling
- Date: Sun, 5 Jul 2015 17:16:14 +0100
2015-07-01 15:25 GMT+01:00 Fergus Smith <fergus_smith111 AT hotmail.com>:
> Hi,
>
>
>
> I've come across this same problem in every version of FreeTDS I've tried.
>
> https://lists.ibiblio.org/sympa/arc/freetds/2007q3/022165.html
> Running against MSSQL the error isn't trapped.
> I think the ct-lib error handler isn't working properly.
>
>
>
> The test environments are;
>
> TDS version: 4.2
>
I hope you are not really using this version :)
At least 5.0 (Sybase) or 7.1 (mssql)
> Version: freetds vdev.0.96.85
>
> Windows 7 SP1
>
> Sybase ASE 12.5.4
>
> Microsoft SQL Server 2012 (SP1)
>
>
>
>
>
> Running on windows against sybase this is the relevant part of the dump
> file;
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> ct.c:994:ct_send() succeeded
>
> ct.c:1129:ct_results(0058B5C0, 0031A910)
>
> token.c:549:tds_process_tokens(00588068, 0031A768, 0031A75C, 0x6914)
>
> util.c:165:Changed query state from PENDING to READING
>
> packet.c:639:Received packet
>
> 0000 04 01 00 dd 00 00 00 00-e5 c9 00 fc 0a 00 00 05 |........ ........|
>
> 0010 10 05 5a 5a 5a 5a 5a 00-01 00 ae 00 53 74 6f 72 |..ZZZZZ. ....Stor|
>
> 0020 65 64 20 70 72 6f 63 65-64 75 72 65 20 27 63 75 |ed proce dure 'cu|
>
> 0030 73 74 6f 6d 65 72 64 62-5f 74 73 74 2e 2e 73 70 |stomerdb _tst..sp|
>
> 0040 44 6f 65 73 4e 6f 74 45-78 69 73 74 27 20 6e 6f |DoesNotE xist' no|
>
> 0050 74 20 66 6f 75 6e 64 2e-20 53 70 65 63 69 66 79 |t found. Specify|
>
> 0060 20 6f 77 6e 65 72 2e 6f-62 6a 65 63 74 6e 61 6d | owner.o bjectnam|
>
> 0070 65 20 6f 72 20 75 73 65-20 73 70 5f 68 65 6c 70 |e or use sp_help|
>
> 0080 20 74 6f 20 63 68 65 63-6b 20 77 68 65 74 68 65 | to chec k whethe|
>
> 0090 72 20 74 68 65 20 6f 62-6a 65 63 74 20 65 78 69 |r the ob ject exi|
>
> 00a0 73 74 73 20 28 73 70 5f-68 65 6c 70 20 6d 61 79 |sts (sp_ help may|
>
> 00b0 20 70 72 6f 64 75 63 65-20 6c 6f 74 73 20 6f 66 | produce lots of|
>
> 00c0 20 6f 75 74 70 75 74 29-2e 0a 06 61 73 65 63 64 | output) ...asecd|
>
> 00d0 74 00 01 00 fd 02 00 02-00 00 00 00 00 |t....... .....|
>
>
>
> token.c:564:processing result tokens. marker is e5(EED)
>
> token.c:115:tds_process_default_tokens() marker is e5(EED)
>
> token.c:2339:tds_process_msg() reading message 2812 from server
>
> token.c:2411:tds_process_msg() calling client msg handler
>
> ctutil.c:142:_ct_handle_server_message(005872A0, 00588068, 0031A660)
>
> ct.c:4330:ct_diag_storeservermsg(005871D8, 00587ED0, 0031A0F4)
>
> token.c:2424:tds_process_msg() returning TDS_SUCCESS
>
> token.c:564:processing result tokens. marker is fd(DONE)
>
> token.c:2075:tds_process_end: more_results = 0
>
> was_cancelled = 0
>
> error = 1
>
> done_count_valid = 0
>
> token.c:2092: rows_affected = 0
>
> token.c:2095:tds_process_end() state set to TDS_IDLE
>
> util.c:165:Changed query state from READING to IDLE
>
> util.c:83:logic error: cannot change query state from IDLE to PENDING
>
> util.c:165:Changed query state from IDLE to IDLE
>
> ct.c:1186:ct_results() process_result_tokens returned 0 (type 4052)
>
> ct.c:1292:ct_results() results state = 0
>
> ct.c:1293:ct_results() command type = 148
>
> ct.c:1294:ct_results() dynamic cmd = 0
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
>
> On windows against MS SQL this is the same part of the dump file;
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> ct.c:994:ct_send() succeeded
>
> ct.c:1129:ct_results(0084C658, 0032AB00)
>
> token.c:549:tds_process_tokens(00847FD0, 0032A958, 0032A94C, 0x6914)
>
> util.c:165:Changed query state from PENDING to READING
>
> packet.c:639:Received packet
>
> 0000 04 01 00 c8 00 3d 01 00-aa b4 00 fc 0a 00 00 3e |.....=.. .......>|
>
> 0010 10 45 00 43 00 6f 00 75-00 6c 00 64 00 20 00 6e |.E.C.o.u .l.d. .n|
>
> 0020 00 6f 00 74 00 20 00 66-00 69 00 6e 00 64 00 20 |.o.t. .f .i.n.d. |
>
Good, surely you are not using 4.2 here!
> 0030 00 73 00 74 00 6f 00 72-00 65 00 64 00 20 00 70 |.s.t.o.r .e.d. .p|
>
> 0040 00 72 00 6f 00 63 00 65-00 64 00 75 00 72 00 65 |.r.o.c.e .d.u.r.e|
>
> 0050 00 20 00 27 00 62 00 69-00 6c 00 6c 00 69 00 6e |. .'.b.i .l.l.i.n|
>
> 0060 00 67 00 5f 00 64 00 65-00 76 00 2e 00 2e 00 73 |.g._.d.e .v.....s|
>
> 0070 00 70 00 52 00 75 00 61-00 69 00 72 00 69 00 50 |.p.R.u.a .i.r.i.P|
>
> 0080 00 50 00 47 00 65 00 74-00 44 00 65 00 66 00 61 |.P.G.e.t .D.e.f.a|
>
> 0090 00 75 00 6c 00 74 00 73-00 27 00 2e 00 0f 41 00 |.u.l.t.s .'....A.|
>
> 00a0 4c 00 50 00 2d 00 4d 00-41 00 54 00 52 00 49 00 |L.P.-.M. A.T.R.I.|
>
> 00b0 58 00 53 00 51 00 4c 00-53 00 56 00 00 01 00 fe |X.S.Q.L. S.V.....|
>
> 00c0 02 00 e0 00 00 00 00 00- |........|
>
>
>
> token.c:564:processing result tokens. marker is aa(ERROR)
>
> token.c:115:tds_process_default_tokens() marker is aa(ERROR)
>
> token.c:2339:tds_process_msg() reading message 2812 from server
>
> token.c:2411:tds_process_msg() calling client msg handler
>
> ctutil.c:142:_ct_handle_server_message(008472A0, 00847FD0, 0032A850)
>
> ct.c:4330:ct_diag_storeservermsg(008471D8, 00847ED0, 0032A2E4)
>
> token.c:2424:tds_process_msg() returning TDS_SUCCESS
>
> token.c:564:processing result tokens. marker is fe(DONEPROC)
>
> token.c:2075:tds_process_end: more_results = 0
>
> was_cancelled = 0
>
> error = 1
>
> done_count_valid = 0
>
> token.c:2092: rows_affected = 0
>
> token.c:2095:tds_process_end() state set to TDS_IDLE
>
> util.c:165:Changed query state from READING to IDLE
>
> util.c:83:logic error: cannot change query state from IDLE to PENDING
>
> util.c:165:Changed query state from IDLE to IDLE
>
> ct.c:1186:ct_results() process_result_tokens returned 0 (type 4053)
>
> token.c:549:tds_process_tokens(00847FD0, 0032A958, 0032A94C, 0x6914)
>
> token.c:552:tds_process_tokens() state is COMPLETED
>
> ct.c:1186:ct_results() process_result_tokens returned 1 (type 4052)
>
> ct.c:235:ct_describe_cmd_state(3)
>
> ct.c:235:ct_describe_cmd_state(2)
>
> ct.c:223:setting command state to READY (from SENT)
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>
>
>
>
> I was wondering has anyone made an attempt to fix this?
>
>
>
> Thanks a million,
>
> Fergus
>
I actually cannot test if everything is ok, but in src/ctlib/ct.c
there are these lines
case TDS_DONEPROC_RESULT:
/*
* A DONEPROC result means the end of a logical
* command only if it was one of the commands
* directly sent from ct_send, not as a result
* of a nested stored procedure call. We know
* if this is the case if a STATUS_RESULT was
* received immediately prior to the DONE_PROC
*/
if (cmd->results_state == _CS_RES_STATUS) {
if (done_flags & TDS_DONE_ERROR)
*result_type = CS_CMD_FAIL;
else
*result_type = CS_CMD_SUCCEED;
cmd->results_state = _CS_RES_CMD_DONE;
return CS_SUCCEED;
} else {
if (cmd->command_type == CS_DYNAMIC_CMD) {
*result_type = CS_CMD_SUCCEED;
cmd->results_state = _CS_RES_CMD_DONE;
return CS_SUCCEED;
}
}
break;
which seems to me broken! There are some types of commands:
- LANG
- RPC
- SEND_DATA
- SEND_BULK
- CUR
- DYNAMIC
Now for LANG, SEND_DATA and SEND_BULK DONEPROC is not send back, you
are using RPC which should be returning some data, DYNAMIC is handled
by code above but error is not detected and if cursors probably are
using RPCs (for instance using mssql, I don't know Sybase but if they
are not using RPC they are not returning DONEPROC) should be handled.
So I would change the code to (much easier)
case TDS_DONEPROC_RESULT:
if (done_flags & TDS_DONE_ERROR)
*result_type = CS_CMD_FAIL;
else
*result_type = CS_CMD_SUCCEED;
cmd->results_state = _CS_RES_CMD_DONE;
return CS_SUCCEED;
I don't agree with the comment to check status as for instance in your
example status is not returned (as is returned when you call an RPC
but if the RPC does not exists status is not returned). Can you try if
this code solve the problem for you? I'll need to do some additional
tests (for instance with cursors, dynamic and so on).
Frediano
-
[freetds] ct-lib error handling,
Fergus Smith, 07/01/2015
-
Re: [freetds] ct-lib error handling,
Frediano Ziglio, 07/05/2015
-
Re: [freetds] ct-lib error handling,
Fergus Smith, 07/13/2015
-
Re: [freetds] ct-lib error handling,
Frediano Ziglio, 07/14/2015
- Re: [freetds] ct-lib error handling, Frediano Ziglio, 07/16/2015
- Re: [freetds] ct-lib error handling, Frediano Ziglio, 07/21/2015
-
Re: [freetds] ct-lib error handling,
Frediano Ziglio, 07/14/2015
-
Re: [freetds] ct-lib error handling,
Fergus Smith, 07/13/2015
-
Re: [freetds] ct-lib error handling,
Frediano Ziglio, 07/05/2015
Archive powered by MHonArc 2.6.24.