Re: empty strings select as null bug

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
On Wed, 10 Jun 2015 15:37:59 -0700
Geoff Montee <[email protected]> wrote:

> tds_fdw assumes a column is NULL if dbdatlen() returns 0:
> 
> https://github.com/GeoffMontee/tds_fdw/blob/fd4696695149b0be143e11b70df14b42acdd899d/src/tds_fdw.c#L1816
> 
> http://www.freetds.org/reference/a00341.html#gae666d141533126babb0235af21bdca0f
> 
> I implemented it this way because I assumed dbdatlen() should be equal
> to 1 for a null terminator character if a string is empty. Let me know
> if this is a bad null test.

Using dbdatlen, you cannot distinguish between a zero-length string and
NULL.  In some versions of TDS, there is no difference between the
two: at the protocol level, a NULL CHAR column was indicated by having
a length of zero.  Later versions indicated NULL explicitly.  That
opened the possibilty of a non-NULL CHAR field having no data, a very
strange situtation indeed.  

IIRC NULL can be more accurately detected with dbnullbind.  

HTH.  

--jkl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.