[freetds] dblib buffering problem

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Fri Jul 9 08:34:07 EDT 2004

Today I tried regression tests with a mssql2k and I discovered that
patch for STATUSRESULT causes some problems to dblib and buffering.
Assuming client issue a simple select server can reply with

In dbsqlok we test if next token it's a result, if not it calls
trs_process_results_token however doing so it process token but do not
init buffer so at next dbnextrow it just core at dblib.c:337
(assert(row_size <= buf->element_size)).
IMHO there are two fixes: 
1- add TDS_STATUSRESULT_TOKEN in is_result_token macro (include/tds.h);
2- initialize buffer in dbsqlok

1 works perfectly, 2 it's not so easy cause next dbresults want to
handle ROWFMT... from my point of view is something too complicated in
dblib... I readed dbsqlok docs on Sybase site but I don't understand
what should this function do... it has to detect if there are errors on
query but it hasn't to process any results... so what class of tokens
it's expected to handle??

Also buffering has some problems:
- it simply can't run with text/image, it copy just buffer without any
text/image, pointer to garbage and memory errors are just waiting... it
can work only with maximun 1 row and row in TDSSOCKET freed _after_
dblib one...
- what happen if compute row is bigger than result row ?? Or it this


More information about the FreeTDS mailing list