Skip to Content.
Sympa Menu

freetds - Re: [freetds] Truncation of string values to 80 characters using placeholders and MSSQL

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Neuhauser, Roman (GE Capital, consultant)" <Roman.Neuhauser AT ge.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] Truncation of string values to 80 characters using placeholders and MSSQL
  • Date: Thu, 5 May 2011 16:03:43 +0100

From: freetds-bounces AT lists.ibiblio.org
[mailto:freetds-bounces AT lists.ibiblio.org] On Behalf Of Ed Avis
> As others have mentioned, the bug appears to be caused in src/tds/query.c
> and can be largely fixed with this patch:
>
> --- freetds-0.91RC2-orig/src/tds/query.c 2011-03-30
> +++ freetds-0.91RC2-patch_truncation/src/tds/query.c 2011-05-05
> @@ -799,7 +799,7 @@
> if (tds_get_column_declaration(tds,
> params->columns[i], \ declaration + strlen(declaration)) == TDS_FAIL)
> goto Cleanup;
> } else {
> - strcat(declaration, "varchar(80)");
> + strcat(declaration, "varchar(4000)");
> }
>
> /* convert it to ucs2 and append */
>
> However, I'm not sure that every server accepts varchar(4000) as a column
> type, and some may allow even larger varchars (so that
> the fixed code is still buggy if the string is longer than 4000 chars).
> I'd be interested in your thoughts on the right way to fix it.

depending on server version, the fix could be "varchar(max)", but that's
deprecated in sql server 2005 IIRC...

--
roman



Archive powered by MHonArc 2.6.24.

Top of Page