Skip to Content.
Sympa Menu

freetds - Re: [freetds] empty strings select as null bug

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Geoff Montee <geoff.montee AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] empty strings select as null bug
  • Date: Wed, 10 Jun 2015 15:37:59 -0700

On Wed, Jun 10, 2015 at 7:27 AM, Jeffrey Shaw <shawjef3 AT gmail.com> 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




Archive powered by MHonArc 2.6.24.

Top of Page