freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
[freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string
- From: Marc Abramowitz <marca AT surveymonkey.com>
- To: "freetds AT lists.ibiblio.org" <freetds AT lists.ibiblio.org>
- Subject: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string
- Date: Wed, 27 Feb 2013 21:49:52 +0000
Hi all,
I'm working on a bug that I discovered in pymssql
(http://code.google.com/p/pymssql/issues/detail?id=109). I'm trying to send a
string with 10 Unicode characters as a parameter to a stored procedure.
I've traced through the code and pymssql is taking the Unicode string of
length 10 and encoding it to 20 UTF-8 bytes and then it calls dbrpcparam as
follows:
dbrpcparam(proc = ???, param_name = '', status = 0, dbtype = 39,
max_length = -1, length = 20, data =
'\xd0\x97\xd0\xb4\xd1\x80\xd0\xb0\xd0\xb2\xd1\x81\xd1\x82\xd0\xb2\xd1\x83\xd0\xb9')
=> 1
The result is that SQL Server receives a blank string for that parameter. In
the FreeTDS log, I can see an error related to character set conversion:
Error converting characters into server's character set. Some
character(s) could not be converted", client returns 2 (INT_CANCEL)
What's also interesting is that if instead of creating a stored proc and
binding a parameter, I simply send a raw query with the Unicode string in it
(preceded by the "N" prefix), then it works and the database receives the
string as expected. The problem only occurs when explicitly instantiating the
stored proc and binding the parameter to it.
Is this a known issue? Is this the same issue as this:
http://lists.ibiblio.org/pipermail/freetds/2008q2/023367.html ?
Relevants snippets from the FreeTDS log:
log.c:196:Starting log file for FreeTDS 0.91
on 2013-02-27 13:28:32 with debug flags 0x4fff.
iconv.c:330:tds_iconv_open(0x10158bc40, UTF-8)
iconv.c:187:local name for ISO-8859-1 is ISO-8859-1
iconv.c:187:local name for UTF-8 is UTF-8
iconv.c:187:local name for UCS-2LE is UCS-2LE
iconv.c:187:local name for UCS-2BE is UCS-2BE
iconv.c:349:setting up conversions for client charset "UTF-8"
iconv.c:351:preparing iconv for "UTF-8" <-> "UCS-2LE" conversion
iconv.c:391:preparing iconv for "ISO-8859-1" <-> "UCS-2LE" conversion
iconv.c:394:tds_iconv_open: done
net.c:205:Connecting to 127.0.0.1 port 1433 (TDS version 7.1)
…
rpc.c:84:dbrpcinit(0x10159fac0, someProcWithOneParam, 0)
rpc.c:136:dbrpcinit() added rpcname "someProcWithOneParam"
rpc.c:171:dbrpcparam(0x10159fac0, , 0x0, 39, -1, 20, 0x101591680)
rpc.c:263:dbrpcparam() added parameter ""
dblib.c:3196:dbcancel(0x10159fac0)
query.c:2155:tds_send_cancel: not in_cancel and idle
rpc.c:282:dbrpcsend(0x10159fac0)
rpc.c:401:parm_info_alloc(): parameter null-ness = 0
rpc.c:331:parameter size = 20, data = 0x101567db0, row_size = 0
rpc.c:336:copying 20 bytes of data to parameter #0
mem.c:615:tds_free_all_results()
util.c:156:Changed query state from IDLE to QUERYING
query.c:1437:tds_put_data_info putting param_name.
query.c:1471:tds_put_data_info putting status.
query.c:1572:tds_put_data: colsize = 20
util.c:331:tdserror(0x101506eb0, 0x10159fdb0, 2402, 0)
dblib.c:7929:dbperror(0x10159fac0, 2402, 0)
dblib.c:7981:2402: "Error converting characters into server's character set.
Some character(s) could not be converted"
dblib.c:8002:"Error converting characters into server's character set. Some
character(s) could not be converted", client returns 2 (INT_CANCEL)
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
query.c:1640:tds_put_data: not null param varint_size = 2
util.c:156:Changed query state from QUERYING to PENDING
net.c:741:Sending packet
0000 03 01 00 40 00 00 01 00-14 00 73 00 6f 00 6d 00 |...@.... ..s.o.m.|
0010 65 00 50 00 72 00 6f 00-63 00 57 00 69 00 74 00 |e.P.r.o. c.W.i.t.|
0020 68 00 4f 00 6e 00 65 00-50 00 61 00 72 00 61 00 |h.O.n.e. P.a.r.a.|
0030 6d 00 00 00 00 00 a7 14-00 09 04 d0 00 34 00 00 |m....... .....4..|
rpc.c:319:dbrpcsend() returning SUCCEED
-
[freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string,
Marc Abramowitz, 02/27/2013
-
Re: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string,
Marc Abramowitz, 02/27/2013
-
Re: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string,
Marc Abramowitz, 02/27/2013
-
Re: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string,
Frediano Ziglio, 02/28/2013
-
Re: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string,
Marc Abramowitz, 02/28/2013
- Re: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string, Marc Abramowitz, 02/28/2013
-
Re: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string,
Marc Abramowitz, 02/28/2013
- Re: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string, Frediano Ziglio, 02/28/2013
-
Re: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string,
Frediano Ziglio, 02/28/2013
-
Re: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string,
Marc Abramowitz, 02/27/2013
-
Re: [freetds] Sending Unicode (UTF-8) data to dbrpcparam - SQL Server receives blank string,
Marc Abramowitz, 02/27/2013
Archive powered by MHonArc 2.6.24.