MS-SQL 7.0, sqsh, not returning null values
Brian Bruns
camber at umcc.ais.org
Fri Feb 18 18:48:30 EST 2000
I found this problem. It affects only TDS 7.0 as you have guessed.
With 7.0, Microsoft introduced long char types (char, varchar, etc...).
These have a two byte (16 bit) length. For 8 bit length types, NULL is
represented by 0. Problem is you can't tell the difference between a zero
length varchar and a null one (insert '' into a varchar and it is actually
represented by a single space ' ').
So microsoft's (not bad) solution is to to represent NULL with 65355
(0xFFFF or -1 using signed int). So, here is a little patch to fix
it...in tds_process_row() (token.c):
} else if (is_large_type(curcol->column_xtype)) {
colsize = tds_get_smallint(tds);
+ if (colsize==-1) colsize=0;
} else if (!is_fixed_type(curcol->column_type)) {
I also checked it into CVS.
Cheers,
Brian
On Fri, 18 Feb 2000, Bill Doulass wrote:
> I tried downsizing to TDSVER=42, and the NULL problem went away. I will
> continue to work with this version for the time being.
>
> Thanks again, all.
>
More information about the FreeTDS
mailing list