Skip to Content.
Sympa Menu

freetds - Re: [freetds] Solaris/SPARC: SIGBUS in unittests/array_out.c

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Peter C. Norton" <spacey-freetds.org AT ssr.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Solaris/SPARC: SIGBUS in unittests/array_out.c
  • Date: Thu, 23 Sep 2010 11:56:08 -0400

On Thu, Sep 23, 2010 at 09:23:22AM +0200, Frediano Ziglio wrote:
> 2010/9/23 Peter C. Norton <spacey-freetds.org AT ssr.com>
> > (1) data fails in the following manner:
> >
> > SELECT CONVERT(INT, '-123') AS data
> > SELECT CONVERT(INT, '78654') AS data
> > SELECT CONVERT(VARCHAR(10), ' 51245 ') AS data
> > SELECT CONVERT(UNIVARCHAR(10), u&'\06A4\FBA5') AS data
> > Wrong result
> > Got: 2 \ua406\ua5fb
> > Expected: 2 \u06a4\ufba5
> > SELECT CONVERT(DECIMAL, '1234.5678') AS data
> > SELECT CONVERT(NUMERIC, '8765.4321') AS data
> > SELECT CONVERT(FLOAT, '1234.5678') AS data
> > SELECT CONVERT(REAL, '8765.4321') AS data
> > SELECT CONVERT(SMALLMONEY, '765.4321') AS data
> > SELECT CONVERT(MONEY, '4321234.5678') AS data
> > SELECT CONVERT(DATETIME, '2006-06-09 11:22:44') AS data
> > SELECT CONVERT(SMALLDATETIME, '2006-06-12 22:37:21') AS data
> > SELECT CONVERT(DATETIME, '2006-06-09 11:22:44') AS data
> > SELECT CONVERT(SMALLDATETIME, '2006-06-12 22:37:21') AS data
> > FAIL: data
> >
> > This looks like an endian problem, as the bytes appear to be swapped.
> > From googling around, it looks like in the case of ODBC, it specifies
> > that that SQL_W_CHAR is in host byte order. However, this SPARC is
> > connecting to an x86 server and I don't see any checks for byte
> > ordering being done in the test:
> >
> > case SQL_C_WCHAR:
> > assert(out_len >=0 && (out_len % sizeof(SQLWCHAR)) == 0);
> > sprintf(sbuf, "%u ", (unsigned int) (out_len /
> > sizeof(SQLWCHAR)));
> > wp = (SQLWCHAR*) out_buf;
> > for (i = 0; i < out_len / sizeof(SQLWCHAR); ++i)
> > if ((unsigned int) wp[i] < 256)
> > sprintf(strchr(sbuf, 0), "%c", (char)
> > wp[i]);
> > else
> > sprintf(strchr(sbuf, 0), "\\u%04x",
> > (unsigned int) wp[i]);
> > break;
> >
> >
> it's ok as ODBC should encode SQLWCHAR in proper order. Could you post
> TDSDUMP ?? Just to understand in which encoding server send data.

I'll start with the issue that I'm more concerned about for now. I'll
look at the variable timeout next. Here's the relevent section of a
dump of data.c:

odbc.c:3534:odbc_process_tokens: tds_process_tokens returned 2
odbc.c:3535: result_type=4052, TDS_DONE_COUNT=10, TDS_DONE_ERROR=2
odbc.c:820:SQLMoreResults: result_type=4046, row_count=-1, lastrc=0
mem.c:615:tds_free_all_results()
odbc.c:832:SQLMoreResults: row_status=0
odbc.c:834:SQLMoreResults: row_count=-1, lastrc=0
odbc.c:4154:SQLFreeStmt(1001168a0, 2)
odbc.c:4075:_SQLFreeStmt(1001168a0, 2, 0)
odbc.c:4154:SQLFreeStmt(1001168a0, 3)
odbc.c:4075:_SQLFreeStmt(1001168a0, 3, 0)
odbc.c:3463:SQLExecDirect(1001168a0, 100107310, -3)
prepare_query.c:203:parsing 0 parameters
odbc.c:3211:_SQLExecute(1001168a0)
odbc.c:3216:_SQLExecute() starting with state 0
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to QUERYING
util.c:156:Changed query state from QUERYING to PENDING
net.c:730:Sending packet
0000 0f 01 00 44 00 00 00 00-21 00 00 00 37 00 53 45 |...D.... !...7.SE|
0010 4c 45 43 54 20 43 4f 4e-56 45 52 54 28 55 4e 49 |LECT CON VERT(UNI|
0020 56 41 52 43 48 41 52 28-31 30 29 2c 20 75 26 27 |VARCHAR( 10), u&'|
0030 5c 30 36 41 34 5c 46 42-41 35 27 29 20 41 53 20 |\06A4\FB A5') AS |
0040 64 61 74 61 - |data|

token.c:539:tds_process_tokens(100115b60, ffffffff7fffeadc, ffffffff7fffead8,
0x6914)
util.c:156:Changed query state from PENDING to READING
net.c:546:Received header
0000 04 01 00 40 00 00 00 00- |...@....|

net.c:600:Received packet
0000 04 01 00 40 00 00 00 00-61 00 00 00 1d 00 01 04 |...@.... a.......|
0010 64 61 74 61 00 00 00 04-64 61 74 61 00 00 00 10 |data.... data....|
0020 00 00 00 23 e1 00 00 00-14 00 ae 00 01 00 d1 00 |...#.... ........|
0030 00 00 04 06 a4 fb a5 fd-00 10 00 02 00 00 00 01 |........ ........|

token.c:554:processing result tokens. marker is 61(ROWFMT2)
token.c:1831:tds5_process_result
mem.c:615:tds_free_all_results()
token.c:1855:num_cols=1
token.c:1958:col 0:
token.c:1959: column_name=[data]
token.c:1965: flags=10 utype=35 type=35 varint=5
token.c:1968: colsize=20 prec=0 scale=0
util.c:156:Changed query state from READING to PENDING
odbc.c:3534:odbc_process_tokens: tds_process_tokens returned 1
odbc.c:3535: result_type=4049, TDS_DONE_COUNT=0, TDS_DONE_ERROR=0
odbc.c:3605:odbc_process_tokens: returning result_type 4049
odbc.c:3374:_SQLExecute: odbc_process_tokens returned result_type 4049
token.c:539:tds_process_tokens(100115b60, ffffffff7fffeadc, ffffffff7fffead8,
0x6914)
util.c:156:Changed query state from PENDING to READING
token.c:554:processing result tokens. marker is ae(CONTROL)
token.c:122:tds_process_default_tokens() marker is ae(CONTROL)
token.c:237:Eating CONTROL token
token.c:554:processing result tokens. marker is d1(ROW)
token.c:665:tds_process_tokens::SET_RETURN stopping on current token
util.c:156:Changed query state from READING to PENDING
odbc.c:3534:odbc_process_tokens: tds_process_tokens returned 1
odbc.c:3535: result_type=4040, TDS_DONE_COUNT=10, TDS_DONE_ERROR=2
odbc.c:3605:odbc_process_tokens: returning result_type 4040
odbc.c:3374:_SQLExecute: odbc_process_tokens returned result_type 4040
odbc.c:1731:SQLBindCol(1001168a0, 1, -8, ffffffff7ffff130, 256,
ffffffff7ffff128)
odbc.c:3935:SQLFetch(1001168a0)
odbc.c:3671:_SQLFetch(1001168a0, 1, 0)
token.c:539:tds_process_tokens(100115b60, ffffffff7fffebfc, ffffffff7fffebf8,
0x6508)
util.c:156:Changed query state from PENDING to READING
token.c:554:processing result tokens. marker is d1(ROW)
token.c:2426:tds_process_row(): reading column 0
token.c:2171:tds_get_data: type 35, varint size 5
token.c:2232:tds_get_data(): wire column size is 4
util.c:156:Changed query state from READING to PENDING
odbc.c:3534:odbc_process_tokens: tds_process_tokens returned 1
odbc.c:3535: result_type=4040, TDS_DONE_COUNT=10, TDS_DONE_ERROR=2
odbc.c:3605:odbc_process_tokens: returning result_type 4040
convert_tds2sql.c:164:odbc_tds2sql: src is 225 dest = -8
odbc.c:3935:SQLFetch(1001168a0)
odbc.c:3671:_SQLFetch(1001168a0, 1, 0)
token.c:539:tds_process_tokens(100115b60, ffffffff7fffebfc, ffffffff7fffebf8,
0x6508)
util.c:156:Changed query state from PENDING to READING
token.c:554:processing result tokens. marker is fd(DONE)
token.c:2461:tds_process_end: more_results = 0
was_cancelled = 0
error = 0
done_count_valid = 1
token.c:2477:tds_process_end() state set to TDS_IDLE
util.c:156:Changed query state from READING to IDLE
token.c:2492: rows_affected = 1
util.c:104:logic error: cannot change query state from IDLE to PENDING
odbc.c:3534:odbc_process_tokens: tds_process_tokens returned 1
odbc.c:3535: result_type=4052, TDS_DONE_COUNT=10, TDS_DONE_ERROR=0
odbc.c:3575:odbc_process_tokens: row_count=1
odbc.c:3803:SQLFetch: NO_DATA_FOUND
odbc.c:793:SQLMoreResults(1001168a0)
token.c:539:tds_process_tokens(100115b60, ffffffff7fffed9c, ffffffff7fffed98,
0x5914)
token.c:542:tds_process_tokens() state is COMPLETED
odbc.c:3534:odbc_process_tokens: tds_process_tokens returned 2
odbc.c:3535: result_type=4052, TDS_DONE_COUNT=10, TDS_DONE_ERROR=2
odbc.c:820:SQLMoreResults: result_type=4046, row_count=-1, lastrc=0
mem.c:615:tds_free_all_results()
odbc.c:832:SQLMoreResults: row_status=0
odbc.c:834:SQLMoreResults: row_count=-1, lastrc=0
odbc.c:4154:SQLFreeStmt(1001168a0, 2)
odbc.c:4075:_SQLFreeStmt(1001168a0, 2, 0)
odbc.c:4154:SQLFreeStmt(1001168a0, 3)
odbc.c:4075:_SQLFreeStmt(1001168a0, 3, 0)
odbc.c:3463:SQLExecDirect(1001168a0, 100107310, -3)
prepare_query.c:203:parsing 0 parameters
odbc.c:3211:_SQLExecute(1001168a0)
odbc.c:3216:_SQLExecute() starting with state 0
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to QUERYING
util.c:156:Changed query state from QUERYING to PENDING
net.c:730:Sending packet


Let me know if I you need more info from the dump.

Thanks,

-Peter




Archive powered by MHonArc 2.6.24.

Top of Page