Re: Bug in bcp.c

"James K. Lowden" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
Libin Qi wrote:
> 
> When I call bcp_sendrow()
> If I pass a non-numeric string e.g. "xx" to an integer field in
> database, the conversion would fail, but instead of returning a -1, the
> library core-dumped.
> 
> Line 3485 in bcp.c, the assertion failed.
> 
> After modifying code like this, it started working:
> 3483:        bindcol->bcp_column_data->datalen = converted_data_size;
> 3484:        if(bindcol->bcp_column_data->datalen < 0)
> 3485:            return (FAIL) ;
> 3486:        bindcol->bcp_column_data->is_null = 0;
> 3487:        assert(converted_data_size > 0);
> 

Thanks for pointing this out.  I committed a simpler change.  

Sybase says dbconvert may return FAIL or -1 in case of error; Microsoft
says -1.  bcp.c assumed only FAIL was possible.  It now tests for both.  

Memo to file: dbconvert currently implements Microsoft semantics, which is
wrong because FreeTDS promises Sybase semantics.  Possibly it should
follow --with-msdblib, but at least it should return FAIL according to
Sybase's specifications.  (The value of Sybase's distinction between -1
and FAIL is lost on me, though.)  

--jkl
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.