Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS creating all fields as not null

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Edward Macnaghten <eddy AT edlsystems.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS creating all fields as not null
  • Date: Thu, 21 Sep 2006 19:05:04 +0100

Eloy Lafuente wrote:

Hi,


<snip>

Everytime I create one table having NULL fields, they become NOT NULL in the target DB.


I do not know exactly what you mean. Is the table being created with the NOT NULL attribute set? Or are rows with NULL in that field being inserted with data in it? If it is the latter a README I created for shellsql may come in use....

FreeTDS Installation
~~~~~~~~~~~~~~~~~~~~

To install this you need the FreeTDS package from http://www.freetds.org.
However - there are complications that warrant it's own README file...

Firstly, at time of writing, there is a bug in the ct library of FreeTDS -
The version used is FreeTDS 0.62.4. It may be ficed in future dates, though
as I am writing this it is impossible to know that (Yes - I HAVE submitted a
patch to the project...).

The bug is where the old field buffer is not cleared when a row returns a NULL
value from a select fetch, so in that case the previous value of the row is
retained and returned to the user as being the value of the current row. To
fix it the following program needs to be changed (from the FreeTDS installation
directory)....

src/ctlib/ct.c

It is in the ct_get_data() function, at about line 1988. Here you should
replace the line..

srclen = curcol->column_cur_size;

with...

if (tds_get_null(resinfo->current_row, (item - 1)))
srclen = 0;
else
srclen = curcol->column_cur_size;

and then (re)compile and install it as per the documentation.


<snip>

Enjoy.

Edward Macnaghten - eddy (at) edlsystems (dot) com





Archive powered by MHonArc 2.6.24.

Top of Page