Re: [PATCH] Problem with VARCHAR in sybase.

Eddy Pronk <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
James K. Lowden wrote:
>
> The basic question is: How should ct_fetch() react when the
> datafmt.maxlength argument indicates a length *exactly* equal to the
> length of the returned data and datafmt.format is CS_FMT_NULLTERM?  
>   
The way I solved it for now inside libdbi right now is like this:

    case CS_CHAR_TYPE:
    case CS_TEXT_TYPE:
    case CS_VARCHAR_TYPE:
    _type = DBI_TYPE_STRING;
    datafmt->format = CS_FMT_NULLTERM;
    ++datafmt->maxlength; /* 1 extra byte for \0 */
    break;

Increase the maxlength with 1 byte before calling bind.
see: *http://thread.gmane.org/gmane.comp.db.libdbi.drivers/225*
>
> ct_fetch() copies 16 bytes, discovers there's no room for the NULL
> terminator, and returns the error.  Exactly as should be.  
>
> I'm interested to hear if CVS HEAD resolves the original problem.  
>   
I'll try it with CVS HEAD.

Eddy
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.