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: "James K. Lowden" <james.k.lowden AT icloud.com>
  • To: freetds AT lists.ibiblio.org
  • Subject: Re: [freetds] empty strings select as null bug
  • Date: Wed, 10 Jun 2015 22:07:13 -0400

On Wed, 10 Jun 2015 15:37:59 -0700
Geoff Montee <geoff.montee AT gmail.com> 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




Archive powered by MHonArc 2.6.24.

Top of Page