[freetds] FreeTDS dbwillconvert discrepancy
Joe Losco
joe at sqpuv.com
Wed Nov 26 12:56:11 EST 2008
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.
--
Joe L
More information about the FreeTDS
mailing list