[freetds] Bug in ct_get_data

Edward Macnaghten eddy at edlsystems.com
Mon Jan 17 04:05:24 EST 2005


I am new to this list so please forgive me if this is out of order....

I have 2 pieces of news -
	1 - I have found a bug
	2 - I think I have fixed it

The bug is in ct_get_data.  It manifests when you are returning a row 
set, and a character type is null when the same column in the preceding 
row was not.  ct_get_data does not check the "Null" mask so therefore 
the same value is returned again (as it still is in the buffer).

The fix..., in ctlib/ct.c - in th ct_get_data() function, about line 
1988 replace

                srclen = curcol->column_cur_size;


                  * Fix by eddy at edlsystems.com
                  * To take notice if column is null

                         int bytenum = ((unsigned int) item - 1) / 8u;
                         int bit = ((unsigned int) item - 1) % 8u;
                         unsigned char mask = 1 << bit;

                         if(resinfo->current_row[bytenum] & mask)
                                 srclen = 0;
                                 srclen = curcol->column_cur_size;


                  * End of FIX by eddy at edlsystems.com

seems to do the trick.

This is not a propper "patch" as there are probably better ways of doing 
this.  Also, I am not that familiar with freetds internals, and although 
it may work for me, it may not be the "comprehensive" solution required.

I apologize if this has been covered, or if this is the wrong place for 
this, or I have submitted this the wrong way...



More information about the FreeTDS mailing list