On Tue, Sep 16, 2008 at 1:32 PM, Markus Hoenicka <
[EMAIL PROTECTED]> wrote:
> Hi,
>
> Quoting Oscar Martinez <[EMAIL PROTECTED]>:
>
> I don't know if this is the best way to fix this or the problem itself has
>> to do with this, but doing this gives me the result I need.
>>
>> Another problem is that, libdbi itself has a function to check for null
>> strings. It checks the size and a flag (DBI_VALUE_NULL) and both
>> conditions
>> have to be met. But the flag is no set so, for libdbi, it seems that a
>> string that has 0 size and the flat not set, is not a null string. Is it a
>> task of the freetds dbd module to set that flag?
>>
>>
> I assume that the first problem which you "fixed" by bzero'ing the buffer
> is a consequence of the second problem. It is indeed the drivers' job to set
> the NULL flag appropriately. If it is set, libdbi should never attempt to
> access a buffer which contains a NULL value. However, someone familiar with
> the FreeTDS driver should provide a second opinion.
>
> If no one else jumps in, please have a look at e.g. the MySQL driver. The
> _get_row_data() uses exactly the double check you mentioned (size is zero
> and raw has the NULL value) to set the flag appropriately. You may want to
> experiment with similar code to fix the FreeTDS driver. I'll be happy to
> integrate whatever you come up with into the cvs version.
>
That's it. I've been looking at the driver source more closely. It's
sybase's libct task to fill the program variables when doing a ct_fetch().It
seems that, if the data fetched from the SQL Server is NULL, libct doesn´t
fill the program variable binded. So, if after the malloc we didn´t clear
the contents of the returned buffer, what was there still will be after the
fetch. Later on, the driver does a strlen() on the string to get the size of
the fetched data.
About the DBI_VALUE_NULL flag: Libct fills an array provided by the program
with the status ("indicator") of the field values of each row fetched. The
status is one of two possible values: 0 == Good data, -1 == Null data.
Checking that indicators array we are able to set the proper flag for every
field.
I have implemented those changes and it works as expected. Libdbi now tells
correctly wether a string is NULL (size == 0 and null flag set).
The driver source was a bit messed up so I've also done a reindent work.
By the way, surely this is a bit offtopic but, how often the list at
sourceforge is updated?
Regards
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Libdbi-drivers-devel mailing list
Libdbi-drivers-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libdbi-drivers-devel