Skip to Content.
Sympa Menu

freetds - Re: SqlServer text size limitation

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Eric Deutsch <edeutsch AT systemsbiology.org>
  • To: TDS Development Group <freetds AT franklin.oit.unc.edu>
  • Subject: Re: SqlServer text size limitation
  • Date: Fri, 30 Mar 2001 10:03:14 -0800 (PST)


>On Fri, 30 Mar 2001, Guille -bisho- wrote:
>
> I have another problem. Using text fields and protocol version 7.0 and SQL
> Server 7.0 SP3 it says that the server gives a erroneous response.
>
> The protocol 4.2 connect and return queries, but the text fields are
> returned
> without the last character.
>
> I'm using FreeTDS 0.51.
>
> Is a known issue??? Is there any patch???
>

Hi, I'm not certain I understand your problem, since I'm not sure if
you're really referring to datatype TEXT, or just text in general like
VARCHAR, etc.

BUT, I have been having problems with TEXT fields in the following setup:
Perl 5.6.0 on Linux accessing MS SQL Server 2000
via perl DBI::Sybase + FreeTDS 0.51

If I try to retrieve data from a columntype of TEXT, program crashes with
error "Out of Memory!" (VARCHAR, CHAR, etc. are all fine; indeed if I
SELECT a TEXT field with SUBSTRING(textcolumn,1,8000) all is also well).
But a raw TEXT column is bad news.

I inserted the following hack to fix the problem:
*** ct.c:orig Sat Nov 4 12:41:43 2000
--- ct.c Fri Mar 30 09:30:59 2001
***************
*** 743,746 ****
--- 745,756 ----
datafmt->precision = curcol->column_prec;
datafmt->scale = curcol->column_scale;
+ tdsdump_log("%L inside ct_describe() datafmt->maxlength = %d,
datafmt->usertype = %d, datafmt->precision = %d, datafmt->scale = %d\n",
datafmt->maxlength, datafmt->usertype, datafmt->precision, datafmt->scale);
+
+ /* FIX ME Deutsch hack */
+ if (datafmt->maxlength > 10000) {
+ datafmt->maxlength=100000;
+ tdsdump_log("%L inside ct_describe() datafmt->maxlength = %d
after artificial limiting\n", datafmt->maxlength);
+ }
+
/* FIX ME -- TDS 5.0 has status information in the results
** however, this will work for 4.2 as well */

----------------

The TDSDUMP output looks like this for me now:

2001-03-30 09:31:37 inside ct_describe()
2001-03-30 09:31:37 inside _ct_get_client_type()
2001-03-30 09:31:37 inside ct_describe() datafmt->datatype = 16 server type 35
2001-03-30 09:31:37 inside ct_describe() datafmt->maxlength = 2147483647,
datafmt->usertype = 0, datafmt->precision = 0, datafmt->scale = 0
2001-03-30 09:31:37 inside ct_describe() datafmt->maxlength = 100000 after
artificial limiting
2001-03-30 09:31:37 inside ct_bind()
2001-03-30 09:31:37 inside ct_bind() item = 2 datafmt->datatype = 16
2001-03-30 09:31:37 inside ct_fetch()

What appears to be happening is that the maxlength for a TEXT field
appears to be getting returned as 2GB, and I assume that some part of the
program is then trying a malloc() 2GB, which is bad. So my hacked code
just limits this to 100 kB, which is probably fine for my current
purposes. But obviously, this is not a proper fix. If a TEXT field
really were larger than 100 kB, the result would be truncated.

Perhaps the experts out there can figure out how to handle this properly
and incorporate into current codebase?

thanks,
Eric






Archive powered by MHonArc 2.6.24.

Top of Page