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: > Eddy Pronk wrote: > >> 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; >> > > That will make ct-lib happy, but I would worry the cure might be worse > than the disease. If datafmt->maxlength represents the size of an > allocated buffer, increasing it without reallocating will write the NULL > to unallocated memory, with predictable unpredictable [sic] results. > > Looking forward to your results. > In dbd_freetds.c inside libdbi the allocation is done. I allocated 1byte extra as well, so that is fine. I've seen your recent changes. I would expect with your changes if I remove the ++datafmt->maxlength; it would still work but it breaks. So, from the way I use the API the behavior looks still the same. I've seen you added a new file to the unittests. Are you willing to look at libdbi? I can send you a self contained example for libdbi with the same 'select name from destinations'. The latest cvs code of libdbi-drivers contains my changes. One question. Is the ctlib supposed to be bug-compatible with the libraries shipped with Sybase? I mean, do you think it is possible to run the unittests on Solaris with the Sybase libraries? Eddy