Re: Problem with FreeTDS validating SQL commands (actually a ct_cancel() error)
"James K. Lowden" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
Stephane Magne wrote: > Comparing the two, I noticed that the highlighted lines in the code > below appeared in the CS_CANCEL_ATTN block, but didn't appear in the > equivalent locations in the CS_CANCEL_ALL block. So I just added the > two lines to the proper locations in the CS_CANCEL_ALL block of code > and it cancelled the query properly. Really, "diff -u ct.c ct.c-orig" would have been clearer. :-) Mine's attached. Is that what you meant? I was confused because the CS_CANCEL_ALL branches all end with tds_process_cancel(cmd_conn->tds_socket); _ct_initialise_cmd(cmd); One might think that processing a cancel and initializing a command would not be enhanced by tacking on cmd->cancel_state = _CS_CANCEL_PENDING; leaving the connection in "cancel pending" state. But in fact the tds layer -- i.e. tds_process_cancel only handles the cancel packet. It doesn't set the command state, which it shouldn't, because libtds doesn't know which library called it or what state the ct-lib command should be in. There's a cleanup function it has to call before it can send another query, and that state serves to notify the next-called function to do that cleanup. So yours looks like a good fix. Thanks! Unfortunately, src/unittests/cancel.c doesn't try CS_CANCEL_ALL. I'd like to see the test improved to verify the bug and the fix. Any chance I could persuade you to extend the unit test? If not, thanks anyway for pointing out the problem. I updated TODO. --jkl _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds
ct_cancel.diff
(application/octet-stream, 726 B)
Index: src/ctlib/ct.c =================================================================== RCS file: /cvsroot/freetds/freetds/src/ctlib/ct.c,v retrieving revision 1.178 diff -u -r1.178 ct.c --- src/ctlib/ct.c 6 May 2008 00:14:02 -0000 1.178 +++ src/ctlib/ct.c 22 May 2008 01:11:18 -0000 @@ -2242,6 +2242,7 @@ tds_send_cancel(cmd_conn->tds_socket); tds_process_cancel(cmd_conn->tds_socket); _ct_initialise_cmd(cmd); + cmd->cancel_state = _CS_CANCEL_PENDING; break; } } @@ -2263,6 +2264,7 @@ tds_send_cancel(conn->tds_socket); tds_process_cancel(conn->tds_socket); _ct_initialise_cmd(conn_cmd); + conn_cmd->cancel_state = _CS_CANCEL_PENDING; break; } }