[freetds] "DB-lib error, no 20050, Attempt to convert data stopped by syntax error in source field" - FreeTDS trying to convert to SYBMONEY for some reason?

Karen Pease Karen.Pease at isavia.is
Tue Aug 9 04:11:47 EDT 2016

Then again, perhaps Sybase would have messed up on this as well.  (I'll reiterate that this is old code that I didn't write that I've been tasked to deal with).  The last platform it was on was 32 bit where long int was indeed 4 bytes / 32 bits.  But on the new platform "long int" is 8 bytes / 64 bits.  So maybe that's the problem if, as you say, INTBND is designed to only write 4 bytes but there's an 8 byte value on hand.  I'll try correcting our local definition to use an actual 32 bit value and see if that solves the problem.

 - kv, Karen

Frá: FreeTDS <freetds-bounces at lists.ibiblio.org> fyrir hönd Frediano Ziglio <freddy77 at gmail.com>
Sent: 7. ágúst 2016 15:00
Til: FreeTDS Development Group
Efni: Re: [freetds] "DB-lib error, no 20050, Attempt to convert data stopped by syntax error in source field" - FreeTDS trying to convert to SYBMONEY for some reason?

2016-08-06 18:58 GMT+01:00 Karen Pease <Karen.Pease at isavia.is>:
> That indeed was the problem - thanks a bunch  :)  I didn't have the sybase package installed, which was confusing, but apparently our app has some of the sybase headers in its include directory; I had to remove them.
> One more piece of weirdness I'm hitting... and it took me a long time to track down:
>         int32 count;
> ...
>         dbcmd (ET_fillas_dbp1, " select count(*) ");
>         dbcmd (ET_fillas_dbp1, " from AIRSPACE_BOUND ");
>         dbfcmd (ET_fillas_dbp1, " where Airspace_Vol_Name = '%s' ", volname);
>         dbsqlexec (ET_fillas_dbp1);
>         if (dbresults (ET_fillas_dbp1) != SUCCEED)
>             return;
>         dbbind (ET_fillas_dbp1, 1, INTBIND, (DBINT) 0, &count);
>         dbnextrow (ET_fillas_dbp1);
>         printf("%d, %X, %lX\n", __LINE__, count, count, count);
> So, obviously, count is just an integer, it should never be negative.  For example, if I run that query in in tsql, it returns '4'.  But the output in the code is:
> 4 4 7FFF00000004
> ... as if it's doing some sort of weird negative conversion (???).  It took a long time to catch because when I was just printing it out with "%d" it looked fine, but it was crashing me in a calloc statement.

I don't know your system but I suppose that sizeof(int) == 4 and
sizeof(long) == 8 and you are doing something bad with printf. INTBIND
is supposed to write a 4 byte integer. Explaining what's going on
requires to understand how does variadic functions work and the
architecture you are using.
I cannot see the calloc call.
How is defined the int32? Usually DBINT is safer.

> Any clue what's going on there?  The dump ends:
> dblib.c:2031:dbnextrow(0x1afeb80)
> dblib.c:2043:dbnextrow() dbresults_state = 2 (_DB_RES_RESULTSET_ROWS)
> token.c:549:tds_process_tokens(0x1aff550, 0x7ffe79928be4, (nil), 0x1508)
> util.c:165:Changed query state from PENDING to READING
> token.c:564:processing result tokens.  marker is  d1(ROW)
> token.c:1951:tds_process_row(): reading column 0
> data.c:534:tds_get_data: type 56, varint size 0
> data.c:587:tds_get_data(): wire column size is 4
> util.c:165:Changed query state from READING to PENDING
> buffering.h:305:buffer_transfer_bound_data(0x1afeb90 4040 -1 0x1afeb80 0)
> dblib.c:7210:copy_data_to_host_var(56 [SYBINT4] len 4 => 56 [SYBINT4] len 0)
> dblib.c:7252:copy_data_to_host_var() srctype == desttype
> dblib.c:2117:leaving dbnextrow() returning REG_ROW/MORE_ROWS
>  - kv, Karen

FreeTDS mailing list
FreeTDS at lists.ibiblio.org

More information about the FreeTDS mailing list