[freetds] Status of UTF-8 support in 0.83 dev

ZIGLIO, Frediano, VF-IT Frediano.Ziglio at vodafone.com
Tue Sep 2 03:10:30 EDT 2008


> 
> Frediano,
> 
> While testing ParameterType = SQL_WVARCHAR, I faced a problem 
> with ColumnSize...
> 
> According to MSDN, ColumnSize defines the precision of the 
> type in *characters* (not bytes):
> 
>        http://msdn.microsoft.com/en-us/library/ms711786(VS.85).aspx
> 
> With attached example, when using a CHAR(2) column, I just 
> bind with ParameterType=SQL_WVARCHAR and ColumnSize=2 ...
> 
> But I get an error:
> 
> SQL State: 42000
> SQL code : 8016
> Message  : [FreeTDS][SQL Server]The incoming tabular data 
> stream (TDS) remote
>             procedure call (RPC) protocol stream is incorrect.
>             Parameter 3 (""): Data type 0xE7 has an invalid 
> data length or metadata length.
> 
> Please could you have a look at this?
> 

Mmm... yes, from http://freetds.sourceforge.net/up/out83/test/odbc_genparams.2.html 

...
CREATE TABLE #tmp_insert (col NVARCHAR(100))
SELECT * FROM #tmp_insert WHERE col = CONVERT(NVARCHAR(100), 0xA3006800f900)
DROP TABLE #tmp_insert
SELECT CONVERT(NVARCHAR(100), 0xA3006800f900)
CREATE TABLE #tmp_insert (col NVARCHAR(100))
SELECT * FROM #tmp_insert WHERE col = CONVERT(NVARCHAR(100), '£hù')
DROP TABLE #tmp_insert
IF OBJECT_ID('spTestProc') IS NOT NULL DROP PROC spTestProc
CREATE PROC spTestProc @i NVARCHAR(20) OUTPUT AS SELECT @i = CONVERT(NVARCHAR(20), 'foo
test')
Wrong result
  Got: 3 foo
  Expected: 6 foo te

I noted a bad computation of column size that lead to this problem (here is only a
truncation problem)

I updated the test (see
http://freetds.cvs.sourceforge.net/freetds/freetds/src/odbc/unittests/genparams.c?r1=1.28&
r2=1.29) and now it give

...
SELECT CONVERT(NVARCHAR(100), 'test')
CREATE TABLE #tmp_insert (col NVARCHAR(100))
SELECT * FROM #tmp_insert WHERE col = CONVERT(NVARCHAR(100), 'test')
DROP TABLE #tmp_insert
SELECT CONVERT(NVARCHAR(100), '01234567890')
CREATE TABLE #tmp_insert (col NVARCHAR(100))
genparams.c:150 SQLExecDirect() failure!
SQL error 42000 -- [FreeTDS][SQL Server]The incoming tabular data stream (TDS) remote
procedure call (RPC) protocol stream is incorrect. Parameter 3 (""): Data type 0xEF has an
invalid data length or metadata length.

which is your problem... the problem is the use and fill of on_server.column_size and
column_size. ODBC seems to not fill on_server.column_size and libTDS use column_size which
is 2, however for data it send 4 bytes causing size < length on TDS stream (N'ab' is not a
NVARCHAR(1) !!!)

> Note in my SQL Native Client driver, I do also use 
> SQL_WVARCHAR and ColumnSize has to be passed as a number of 
> characters.
> 
> 
> Thanks!
> Seb
> 

libTDS should pass on_server.column_size while ODBC should fill it... fix waiting... (this
evening I'm quite busy)

freddy77
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3129 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20080902/e4de8e4d/attachment.bin 


More information about the FreeTDS mailing list