[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
Sat Aug 6 13:58:22 EDT 2016


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.

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


________________________________________
Frá: FreeTDS <freetds-bounces at lists.ibiblio.org> fyrir hönd Frediano Ziglio <freddy77 at gmail.com>
Sent: 5. ágúst 2016 17:24
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-05 18:03 GMT+01:00 Karen Pease <Karen.Pease at isavia.is>:
> Hi, all. I'm trying to get a piece of software to work on 64 bit and as a consequence I can no longer use the "sybase-ocsd" package that we'd been using, since I can only locate it in 32 bit.  So I'm trying FreeTDS.  But I can't make heads or tails of the error I'm getting.
>
> In my code, I'm running:
>
>     dbcmd (ET_dbproc, " select distinct a.program_name, b.name ");
>     dbcmd (ET_dbproc, " from sysprocesses a, sysdatabases b");
>     dbcmd (ET_dbproc, " where a.dbid = b.dbid");
>     dbsqlexec (ET_dbproc);
>     SYDBRESULT (ET_dbproc);
>     dbbind (ET_dbproc, 1, NTBSTRINGBIND, (DBCHAR) 0, program);
>     dbbind (ET_dbproc, 2, NTBSTRINGBIND, (DBCHAR) 0, dname);
>     printf("%d\n", __LINE__);
>     dbnextrow(ET_dbproc);
>     printf("%d\n", __LINE__);
>     printf ("program %s, dname %s", program, dname);
>
> Program and dname are of course character arrays.  On the database end, a.program_name is a char(8) and name is sysname(30).
>
> From that, I see:
>
>     421
>     syeh: DB-lib error, no 20050, Attempt to convert data stopped by syntax error in source field
>              os error, Success
>     423
>     program , dname
>
>
> Dumping the debug output to a file, it ends like:
>
> -------
> 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 47, varint size 1
> data.c:587:tds_get_data(): wire column size is 16
> token.c:1951:tds_process_row(): reading column 1
> data.c:534:tds_get_data: type 39, varint size 1
> data.c:587:tds_get_data(): wire column size is 6
> util.c:165:Changed query state from READING to PENDING
> buffering.h:305:buffer_transfer_bound_data(0x24c2670 4040 -1 0x24c2660 0)
> dblib.c:7210:copy_data_to_host_var(47 [SYBCHAR] len 16 => 60 [SYBMONEY] len 0)
> dblib.c:7364:copy_data_to_host_var(): tds_convert returned 8
> dblib.c:7210:copy_data_to_host_var(39 [SYBVARCHAR] len 6 => 60 [SYBMONEY] len 0)
> dblib.c:7364:copy_data_to_host_var(): tds_convert returned -3
> dblib.c:7925:dbperror(0x24c2660, 20050, 0)
> dblib.c:7993:dbperror: Calling dblib_err_handler with msgno = 20050; msg->msgtext = "Attempt to convert data stopped by syntax error in source field"
> dblib.c:4865:dbdead(0x24c2660) [alive]
> dblib.c:8015:dbperror: dblib_err_handler for msgno = 20050; msg->msgtext = "Attempt to convert data stopped by syntax error in source field" -- returns 2 (INT_CANCEL)
> dblib.c:2117:leaving dbnextrow() returning REG_ROW/MORE_ROWS
> -------
>
> Huh? SYBMONEY?  How did money come into the picture here?
>
> Lots more errors are coming up, but let's start at the beginning with this, because it's sure left me scratching my head...
>
> (Full disclosure: I'm a newbie at Sybase; my experience lies mainly with postgres. But the task at hand for me involves porting our app to 64 bit, so....)
>
>
>  - kv, Karen
>


Simple, you are using Sybase headers and linking with FreeTDS.
NTBSTRINGBIND is 13 under Sybase headers but 13 is MONEYBIND in
FreeTDS headers.
There is no ABI compatibility.

Frediano
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds


More information about the FreeTDS mailing list