Re: SYBLONGBINARY mapping to CS_CHAR_TYPE in src/ctlib/ct.c

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <1260697743.5010.78.camel@freddy>
Il giorno gio, 10/12/2009 alle 15.19 +0100, Christian Hoffmann ha
scritto:
> Hi all,
> 
> I am facing a problem with freetds when calling a stored procedure
> that returns a SYBLONGBINARY (column in table is of type "varbinary
> (2000)"). It looks like the code in _ct_get_client_type (int, int,
> int) function returns a CS_CHAR_TYPE and not as I would expect a
> CS_LONGBINARY_TYPE. I tried to look in the CVS history and at
> somepoint it was changed from CS_BINARY_TYPE to CS_CHAR_TYPE:
> 
> http://freetds.cvs.sourceforge.net/viewvc/freetds/freetds/src/ctlib/ct.c?r1=1.108&r2=1.109
> 
> Any idea why this is done like this?
> 
> Kind regards,
> 
> Chris
> 
> PS: I would have thought to change the code to this:
> 
> Index: src/ctlib/ct.c
> ===================================================================
> --- src/ctlib/ct.c	(revision 89641)
> +++ src/ctlib/ct.c	(working copy)
> @@ -1991,7 +1991,7 @@
>  	case SYBLONGBINARY:
>  		if (usertype == USER_UNICHAR_TYPE || usertype == USER_UNIVARCHAR_TYPE)
>  			return CS_UNICHAR_TYPE;
> -		return CS_CHAR_TYPE;
> +		return CS_LONGBINARY_TYPE;
>  		break;
>  	}

>From commit

Sun Nov 30 13:00:17 CET 2003   Frediano Ziglio <[email protected]>
     * include/cspublic.h include/tds.h src/ctlib/cs.c:
     * src/ctlib/ct.c src/tds/convert.c src/tds/token.c:
     - applied Alex Kiesel patch on UNI(VAR)CHAR

So I applied the patch. This patch is supposed to fix some problems with
UNI(VAR)CHAR. UNI(VAR)CHAR are encoded with SYBLONGBINARY with specific
usertypes. I however agree that for no-char should be CS_BINARY_TYPE.
Probably there is no test for this behavior on our unittests.

Applied!

freddy77
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.