[freetds] [ freetds-Patches-744992 ] Empty result-sets ignored in dbresults

SourceForge.net noreply at sourceforge.net
Wed May 28 12:18:44 EDT 2003


Patches item #744992, was opened at 2003-05-28 16:18
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=407808&aid=744992&group_id=33106

Category: db-lib
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Arnar Birgisson (arnar)
Assigned to: Nobody/Anonymous (nobody)
Summary: Empty result-sets ignored in dbresults

Initial Comment:
Following is a summary from a post to the mailinglist. 
The post was possibly rejected due to it's size.

The following code produces different results when 
linked against freetds and ms-dblib in the case of the 
stored procedure returning an empty result-set.

  dbrpcinit(dbproc, "sp_get_athugasemdir_starfsmanns", 
0);
   dbrpcparam(dbproc, "@kennitala", 0, SQLCHAR, 10, 
10, kt);
   dbrpcsend(dbproc);
   dbsqlok(dbproc);

   while (dbresults(dbproc) == SUCCEED) {
      printf("Got resultset %d\n", ++i);
      j = 0;
      while (dbnextrow(dbproc) != NO_MORE_ROWS) {
         printf("   -> line %d\n", ++j);
      }
   }


The tested procedure returns for result sets, with 0, 1, 2 
and 1 rows, respectively. The program output when run 
with ms-dblib is

Got resultset 1
Got resultset 2
   -> line 1
Got resultset 3
   -> line 1
   -> line 2
Got resultset 4
   -> line 1

but when run with freetds it yields

Got resultset 1
   -> line 1
Got resultset 2
   -> line 1
   -> line 2
Got resultset 3
   -> line 1

effectively ignoring the first resultset. Attached is a 
TDSDUMP log of one execution of the program. This 
shows that after the first result set's 
TDS_ROWFMT_RESULT is recieved, an 
TDS_CMD_DONE indicates that there are no rows in 
the resultset. dbresults_r ignores the TDS_CMD_DONE 
and and goes straight to fetching the next resultset.

Attached is a patch for a quick fix of this. It basically 
adds a variable indicating whether 
TDS_ROWFMT_RESULT has been recieved, and if so, 
bails out on a TDS_CMD_DONE.

Again.. I'm not familiar enough with the rest of the code 
to know if this breaks anything, or if this is the correct 
way of doing things.

Arnar

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=407808&aid=744992&group_id=33106



More information about the FreeTDS mailing list