freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
- From: "ZIGLIO Frediano" <Frediano.Ziglio AT vodafone.com>
- To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
- Subject: RE: [freetds] iconv problem
- Date: Wed, 23 Jul 2003 17:49:56 +0200
I attached a small patch that do not fix the problem but improve mainly
a tds test...
I don't think to have many time for some day to dedicate to FreeTDS and
I have small problem with our firm proxy (so I cannot commit
directly)...
freddy77
Index: src/tds/write.c
===================================================================
RCS file: /home/fziglio/freetds/freetds/src/tds/write.c,v
retrieving revision 1.43
diff -d -u -1 -0 -b -r1.43 write.c
--- src/tds/write.c 5 Jul 2003 15:09:19 -0000 1.43
+++ src/tds/write.c 23 Jul 2003 12:58:02 -0000
@@ -108,21 +108,21 @@
/**
* Output a string to wire
* automatic translate string to unicode if needed
* @param s string to write
* @param len length of string in characters, or -1 for null terminated
*/
int
tds_put_string(TDSSOCKET * tds, const char *s, int len)
{
TDS_ENCODING *client;
- char outbuf[256], *poutbuf = outbuf;
+ char outbuf[256], *poutbuf;
unsigned int outbytesleft, bytes_out = 0;
client = &tds->iconv_info->client_charset;
if (len < 0) {
if (client->min_bytes_per_char == 1) { /* ascii or UTF-8 */
len = strlen(s);
} else {
if (client->min_bytes_per_char == 2 &&
client->max_bytes_per_char == 2) { /* UCS-2 or variant */
@@ -137,20 +137,21 @@
}
}
}
assert(len >= 0);
if (IS_TDS7_PLUS(tds)) {
while (len > 0) {
tdsdump_log(TDS_DBG_NETWORK, "%L tds_put_string
converting %d bytes of \"%s\"\n", len, s);
outbytesleft = sizeof(outbuf);
+ poutbuf = outbuf;
if (-1 == tds_iconv(tds, tds->iconv_info, to_server,
&s, &len, &poutbuf, &outbytesleft))
break;
bytes_out = poutbuf - outbuf;
tds_put_n(tds, outbuf, bytes_out);
}
tdsdump_log(TDS_DBG_NETWORK, "%L tds_put_string wrote %d
bytes\n", bytes_out);
return bytes_out;
}
return tds_put_n(tds, s, len);
}
Index: src/tds/unittests/t0004.c
===================================================================
RCS file: /home/fziglio/freetds/freetds/src/tds/unittests/t0004.c,v
retrieving revision 1.15
diff -d -u -1 -0 -b -r1.15 t0004.c
--- src/tds/unittests/t0004.c 11 Jun 2003 20:11:00 -0000 1.15
+++ src/tds/unittests/t0004.c 23 Jul 2003 15:46:09 -0000
@@ -41,20 +41,21 @@
main(int argc, char **argv)
{
TDSLOGIN *login;
TDSSOCKET *tds;
int verbose = 0;
int rc;
int result_type;
int row_type;
int compute_id;
+ int rows_returned = 0;
const char *len200 =
"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789";
char long_query[1000];
sprintf(long_query,
"SELECT name FROM #longquerytest WHERE (name = 'A%s' OR name
= 'B%s' OR name = 'C%s' OR name = 'correct')", len200,
len200, len200);
fprintf(stdout, "%s: Test large (>512 bytes) queries\n", __FILE__);
@@ -89,20 +90,21 @@
while ((rc = tds_process_result_tokens(tds, &result_type, NULL)) ==
TDS_SUCCEED) {
switch (result_type) {
case TDS_ROWFMT_RESULT:
if (tds->res_info->columns[0]->column_type !=
SYBVARCHAR) {
fprintf(stderr, "Wrong column_type in %s\n",
__FILE__);
return 1;
}
break;
case TDS_ROW_RESULT:
while ((rc = tds_process_row_tokens(tds, &row_type,
&compute_id)) == TDS_SUCCEED) {
+ ++rows_returned;
if (verbose) {
printf("col 0 is %s\n",
varchar_as_string(tds, 0));
}
}
if (rc == TDS_FAIL) {
fprintf(stderr, "tds_process_row_tokens()
returned TDS_FAIL\n");
return 1;
} else if (rc != TDS_NO_MORE_ROWS) {
fprintf(stderr, "tds_process_row_tokens()
unexpected return\n");
return 1;
@@ -110,18 +112,23 @@
break;
default:
break;
}
}
if (rc == TDS_FAIL) {
fprintf(stderr, "tds_process_result_tokens() returned
TDS_FAIL for long query\n");
return 1;
} else if (rc != TDS_NO_MORE_RESULTS) {
fprintf(stderr, "tds_process_result_tokens() unexpected
return\n");
+ }
+
+ if (rows_returned != 1) {
+ fprintf(stderr, "%d rows returned, 1 expected\n",
rows_returned);
+ return 1;
}
/* do not check error here, if TABLE is not create this give error */
rc = run_query(tds, "DROP TABLE #longquerytest");
try_tds_logout(login, tds, verbose);
return 0;
}
-
[freetds] iconv problem,
ZIGLIO Frediano, 07/23/2003
- <Possible follow-up(s)>
- RE: [freetds] iconv problem, Lowden, James K, 07/23/2003
-
RE: [freetds] iconv problem,
ZIGLIO Frediano, 07/23/2003
- Re: [freetds] iconv problem, James K. Lowden, 07/23/2003
- RE: [freetds] iconv problem, ZIGLIO Frediano, 07/23/2003
- RE: [freetds] iconv problem, ZIGLIO Frediano, 07/24/2003
Archive powered by MHonArc 2.6.24.