Skip to Content.
Sympa Menu

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

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Sebastien FLAESCH <sf AT 4js.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Status of UTF-8 support in 0.83 dev
  • Date: Mon, 08 Sep 2008 09:29:30 +0200

Hi all,

Any chance to get this fixed soon?

For now I am blocked and cannot continue my developments and our
customer is waiting for this fix...

If you point me to the piece of code (in libTDS and ODBC) I can
have a look...

Thanks a lot.
Seb

ZIGLIO, Frediano, VF-IT wrote:
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
FreeTDS AT lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds





Archive powered by MHonArc 2.6.24.

Top of Page