Re: empty strings select as null bug

Geoff Montee <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAA7biFN97sziEBV9c-q3RKcwsmA=Fsdgk3qXWu=MMPWdM2RWzA@mail.gmail.com>
On Wed, Jun 10, 2015 at 7:27 AM, Jeffrey Shaw <[email protected]> wrote:
>
> I can use PostgreSQL's tds_fdw to use dblib to select from SQL Server. The
> query is
>
> select id, string is null from distribution.dbo_strings;
>
> TDS Version = 4.2
> id | ?column?
> ----+----------
>   1 | f
>
> TDS Version = 7.0
>  id | ?column?
> ----+----------
>   1 | t

As the developer of tds_fdw, I should probably point out to the
FreeTDS developers where my null test code is in case this is a bug on
my end.

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.

Could this behavior be related to iconv or character set conversions
in TDS 7.0 and higher?

Thanks,

Geoff
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.