Skip to Content.
Sympa Menu

freetds - RE: [freetds] SQLExec still succeeds too much

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: ZIGLIO Frediano <Frediano.Ziglio AT vodafoneomnitel.it>
  • To: "'FreeTDS Development Group'" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] SQLExec still succeeds too much
  • Date: Tue, 1 Apr 2003 14:27:08 +0200



> -----Original Message-----
> From: Peter Deacon [mailto:peterd AT iea-software.com]
> Sent: martedì 1 aprile 2003 11.52
> To: FreeTDS Development Group
> Subject: [freetds] SQLExec still succeeds too much
>
>
> I've been doing a little more testing and if you yank the
> network cable
> after connecting but just prior to runing a query... the last
> query has
> the nerve to return success.
>
> tds_get_byte can fail and it would really cramp style to check it all
> the time. I added a few IS_TDSDEAD in places that I think
> needed it and
> fixed a bug where res_info was referenced but didn't exist.
>
> This diff also includes the pid patch I posted earlier...
>
> Have Fun!
> Peter
>

Some about the patch

diff -ur \freetds_bak\src/tds/token.c ./tds/token.c
--- \freetds_bak\src/tds/token.c Sun Mar 30 20:52:39 2003
+++ ./tds/token.c Tue Apr 1 01:35:03 2003
@@ -424,7 +424,12 @@
for (;;) {

marker = tds_get_byte(tds);
tdsdump_log(TDS_DBG_INFO1, "%L processing result tokens.
marker is %x(%s)\n", marker, _tds_token_name(marker));
+
+ if (IS_TDSDEAD(tds)) {
+ *result_type = TDS_CMD_FAIL;
+ return TDS_FAIL;
+ }

switch (marker) {
case TDS7_RESULT_TOKEN:
@@ -509,7 +514,8 @@
return TDS_SUCCEED;
break;
default:
if (tds_process_default_tokens(tds, marker) ==
TDS_FAIL) {
+ *result_type = TDS_CMD_FAIL;
return TDS_FAIL;
}
break;
@@ -559,8 +565,11 @@
while (1) {

marker = tds_get_byte(tds);
tdsdump_log(TDS_DBG_INFO1, "%L processing row tokens.
marker is %x(%s)\n", marker, _tds_token_name(marker));

+ if (IS_TDSDEAD(tds))
+ return TDS_FAIL;
+
switch (marker) {
case TDS_RESULT_TOKEN:
case TDS7_RESULT_TOKEN:
@@ -645,7 +654,11 @@
while(tds->state != TDS_COMPLETED) {

marker = tds_get_byte(tds);
tdsdump_log(TDS_DBG_INFO1, "%L processing trailing tokens.
marker is %x(%s)\n", marker, _tds_token_name(marker));
+
+ if (IS_TDSDEAD(tds))
+ return TDS_FAIL;
+
switch (marker) {
case TDS_DONE_TOKEN:
case TDS_DONEPROC_TOKEN:

Setting result_type before sending TDS_FAIL is not useful. Returning
TDS_FAIL mean a conversation error or a packet error (garbage from server)
while result_type == TDS_CMD_FAIL and TDS_SUCCEED mean last command fail.

I think all tests for IS_TDSDEAD is for eliminating loop or something...
however in this case tds_get_byte return 0, tds_process_default is called,
tds_process_default return TDS_FAIL and function return TDS_FAIL... So your
code do nothing...

freddy77

=================================
"STRICTLY PERSONAL AND CONFIDENTIAL

This message may contain confidential and proprietary material for the sole
use of the intended recipient. Any review or distribution by others is
strictly prohibited. If you are not the intended recipient please contact
the sender and delete all copies.
The contents of this message that do not relate to the official business of
our company shall be understood as neither given nor endorsed by it."

=================================




Archive powered by MHonArc 2.6.24.

Top of Page