[freetds] empty strings select as null bug
James K. Lowden
james.k.lowden at icloud.com
Wed Jun 10 22:07:13 EDT 2015
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:
> 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.
More information about the FreeTDS