Skip to Content.
Sympa Menu

freetds - Re: [freetds] problems storing more than 8000 bytes of data in a varchar(max) column

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "James K. Lowden" <jklowden AT freetds.org>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] problems storing more than 8000 bytes of data in a varchar(max) column
  • Date: Fri, 17 Aug 2007 10:53:23 -0400

Moritz Bunkus wrote:
> So I think, the biggest question is: why does FreeTDS think that the
> column type on the server is a varchar even though it isn't? The next
> question is: Why are there the very same problems with "varchar(max)"
> columns? Are those simply not supported yet?

I think we're both a little confused.

As you've found out, you can't put more than 8000 bytes in a varchar
column, no matter what you do with tds_get_column_declaration(). That's a
server constraint.

The real question, as you say, is why the column is seen as a SYBVARCHAR
instead of SYBTEXT. The answer may actually be somewhere in the ODBC
placeholder code or how it's used. Certainly the server knows what's
there.

We need to see the whole conversation to know what's going on. I'd try
something like this:

1. Turn on logging with TDSDUMP.
2. Use bsqldb or tsql or bsqlodbc to send a receive a giant row.
3. Look at the log. See how much is sent and what type is returned. I
think the log should be detailed enough for that. Save tle log for later
comparison.
4. Run your program, trying to send the same data. Also try to receive
the previously (successfully) sent row. Does that work?
5. Modify your program not to use placeholders. Does that work?

The logs should help. Post them here if you have questions.

The ODBC placeholder API requires the caller to declare each placeholder's
datatype. Perl may be making some simplifying assumptions; it might be
sending everything (or all non-numeric data) as varchar. After all, it
doesn't have a good way to associate your placeholder with a column in a
table. To do that, it would have to parse the SQL and retrieve the type
from the server. (That's a service Sybase servers provide, making
ct-lib's placeholder API easier to use.)

If I'm right about Perl, all is not lost. ISTR support for text columns
as an extension. Certainly DBD::Sybase supports text columns.

HTH.

--jkl




Archive powered by MHonArc 2.6.24.

Top of Page