Hi all

I've been playing around with libdbi and found a little problem when it
comes to get NULL fields from a SQL Server.

The SQL Server version I am using is 8.0. libdbi and libdbi-drivers are
versions 0.8.3-1 <http://0.8.3./>

The problem is that I am getting trashed data from from a VARCHAR field that
only contains NULL values.

I manage to workaround this problem adding a bzero() after the malloc()
here:

dbi_row_t *_dbd_freetds_buffers_binding(dbi_conn_t * conn, dbi_result_t *
result,
                    CS_DATAFMT ** datafmt, CS_INT * datalength,
                    CS_SMALLINT * ind, CS_RETCODE * ret)
{
...
...
...
...

    case DBI_TYPE_STRING:
        /*
         * Result is more that 8 bytes -
         * allocate additional memory
         */
        addr = row->field_values[idx].d_string = (char *)
malloc(row->field_sizes[idx]);

        //clean up the reserved buffer.
        bzero(addr, row->field_sizes[idx]);

        break;
..
..
..
}

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?

Thank you very much for your time.
-------------------------------------------------------------------------
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

Reply via email to