Re: Status of UTF-8 support in 0.83 dev

"ZIGLIO, Frediano, VF-IT" <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <[email protected]>
> 
> 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

_______________________________________________
FreeTDS mailing list
[email protected]
http://lists.ibiblio.org/mailman/listinfo/freetds
smime.p7s (application/x-pkcs7-signature, 3.1 KB) - not displayed
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.