Re: FreeTDS dbwillconvert discrepancy

Joe Losco <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
Wow that very much did not retain its formatting.. I apologize for the 
broken text.


Joe L


Joe Losco wrote:
> Hello all,
> I'm in the process of writing an application for OS X using FreeTDS 
> and objective c.  I have come to a point however, that I am pretty 
> confused. My application at this point is still using the sample 
> provided with FreeTDS as in 
> http://www.freetds.org/userguide/samplecode.htm but I am beginning to 
> convert it to be part of a GUI application in Cocoa.
> I first used the sample to make sure that I can use it as shown, and 
> with a specific query.  The sample as shown works completely.  I took 
> the same code and with minor modifications put it into the GUI app and 
> it does not work.  Now to give some more detailed information.
> My problem that I've narrowed it down to is with this stub of code
> if (SYBCHAR != pcol->type) {                          pcol->size = 
> dbwillconvert(pcol->type, SYBCHAR);
>            }
>
> I've placed  "printf("name:%s type:%d size:%d\n", pcol->name, 
> pcol->type, pcol->size);" around this piece of code so that I can see 
> the before and after effects.  In the command line pure C application 
> dbwillconvert returns the size of the would be data converted to the 
> correct type.  This then lets the memory be allocated properly in the 
> later calloc that uses pcol->size+1, as well as everything else to 
> work as intended.
> However, in the Objective C/GUI version it appears to return a Bool.  
> It seems to return 1 if it is convertable and 0 if it is not.  This 
> obviously messes up the rest of the allocations in the sample 
> resulting in truncation and overflow errors.  I then looked into this 
> farther and found http://www.freetds.org/reference/a00275.html#ga24 
> which from what I can tell is that the desired effect of that function 
> is to return the bool.
> I'm not sure where to go to look for any more information.  Any advice 
> is greatly appreciated.
>
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.