[freetds] [PATCH] Problem with VARCHAR in sybase.

Eddy Pronk epronk at muftor.com
Sat Jul 5 19:08:52 EDT 2008


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



More information about the FreeTDS mailing list