[freetds] freetds silently truncating text/varchar/etc fields to 80 characters

Robert Jay bryopsis at gmail.com
Thu Apr 23 17:23:27 EDT 2009

Okay, log file attached.  I'm not sure how the list handles attachments, but
i'll find out :)

The bit of Perl that does the insert is (which is pretty straightforward):
use warnings;
use DBI;
use DBD::Sybase;

my $dbh = DBI->connect("DBI:Sybase:server=acmt;database=acmt;", "l_acmt_rw",
  or die("Failed to connect to database");

my $sql = "INSERT INTO test (test_string) VALUES (?)";
my $v =

my $sth = $dbh->prepare($sql) or die("Error preparing ($sql):
$sth->execute($v) or die("Error executing ($sql): $DBI::errstr");

The column test_string is defined in the DB as varchar(120).  The DB is
running at compatibility level 90, and freetds.conf is set to tds version
8.0.  I tried changing both of these around and it didn't make any
difference that I could see.

In the log file at around line #375 you can see it casting the parameter to
varchar(255) - it got cast to varchar(80) before I patched the code.

Hopefully this comes through okay,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freetds.log
Type: application/octet-stream
Size: 28484 bytes
Desc: not available
Url : http://lists.ibiblio.org/pipermail/freetds/attachments/20090424/8492c363/attachment.obj 

More information about the FreeTDS mailing list