Skip to Content.
Sympa Menu

freetds - Re: [freetds] FreeTDS SYBUNIQUE Bug / Patch

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Frediano Ziglio <freddy77 AT gmail.com>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] FreeTDS SYBUNIQUE Bug / Patch
  • Date: Wed, 16 May 2012 21:41:30 +0100

Applied!

Added support if srctype != desttype

Frediano

2012/5/16 Willi Langenberger <wlang AT wu.ac.at>:
> Hi!
>
>
> I think there is a bug in FreeTDS regarding SYBUNIQUE column type...
>
> I'm accessing a MS SQLServer 2008 using freetds-0.91/ctlib. The server
> table has "uniqueidentifier" columns (which correspond to SYBUNIQUE /
> CS_UNIQUE_TYPE).
>
> With "ct_bind" i set the datatype to CS_UNIQUE_TYPE. However,
> "ct_fetch" doesnt return any data (copied=0) :-(
>
> Using "tdsdump", i see the following lines in the tracefile:
>
>  01:19:57.072719 7027 (ct.c:1736):_ct_bind_data(): column 25 is type 36 and
> has length 16
>  01:19:57.072725 7027 (ct.c:1907):_ct_get_client_type(type 36, user 0, size
> 16)
>  01:19:57.072730 7027 (cs.c:523):cs_convert(0x8d8d2e0, 0xbfc76fcc,
> 0xb74a1bc4, 0xbfc76f20, 0x8e85438, 0x8e85450)
>  01:19:57.072735 7027 (ct.c:2018):_ct_get_server_type(40)
>  01:19:57.072740 7027 (ct.c:2018):_ct_get_server_type(40)
>  01:19:57.072745 7027 (cs.c:569):converting type 36 (16 bytes) to type = 36
> (16 bytes)
>  01:19:57.072750 7027 (cs.c:583):cs_convert() srctype == desttype
>  01:19:57.072755 7027 (cs.c:697):error: unrecognized type
>                                  ^^^^^^^^^^^^^^^^^^^^^^^^
>  01:19:57.072760 7027 (cs.c:66):cs_prretcode(0)
>  01:19:57.072764 7027 (cs.c:702):cs_convert() returning  CS_FAIL
>  01:19:57.072769 7027 (ct.c:1779):cs_convert-result = 1
>  01:19:57.072774 7027 (ct.c:1781):error: converted only 0 bytes for type 40
>
>
> Where:
>  client type 40: CS_UNIQUE_TYPE
>  server type 36: SYBUNIQUE
>
> Ie, while trying to "cs_convert(SYBUNIQUE -> SYBUNIQUE)" we come to:
>
> freetds-0.91/src/ctlib/cs.c
> ...
> convert()
> {
>  ...
>  /* many times we are asked to convert a data type to itself */
>  if (src_type == desttype) {
>    tdsdump_log(TDS_DBG_FUNC, "cs_convert() srctype == desttype\n");
>    switch (desttype) {
>      case SYBLONGBINARY:
>      case SYBBINARY:
>      ...
>      default:
>      ^^^^^^^^
>        tdsdump_log(TDS_DBG_FUNC, "error: unrecognized type\n");
>        ret = CS_FAIL;
>        break;
>    }
>
>
> So it seems, that the SYBUNIQUE case is missing...
>
> Anyway, here is my patch:
>
> --- freetds-0.91/src/ctlib/cs.c.ori   2010-10-05 10:36:36.000000000 +0200
> +++ freetds-0.91/src/ctlib/cs.c         2012-05-16 02:09:42.000000000 +0200
> @@ -682,6 +682,7 @@
>       case SYBDECIMAL:
>           src_len = tds_numeric_bytes_per_prec[
>             ((TDS_NUMERIC *) srcdata)->precision] + 2;
>       case SYBBITN:
> +      case SYBUNIQUE:
>            memcpy(dest, srcdata, minlen);
>           *resultlen = minlen;
>
> At least, that seems to solve my problem ;-)
>
>
> \wlang{}
>
> --
> Willi.Langenberger AT wu.ac.at            Fax: +43/1/31336/39207
> IT-Services,     WU Wirtschaftsuniversitaet Wien,     Austria
> _______________________________________________
> 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