Discussion:
[freetds] ODBC bug large image parameter
Matthew McGillis
2012-02-27 17:08:55 UTC
Permalink
With intel 64 running Red Hat Enterprise Linux Server 6.1 using FreeTDS 0.82, unixODBC 2.3.0, perl 5.10 and DBD::ODBC 1.29.

Connecting to a Windows box with Microsoft SQL Server 2005 - 9.00.4035.00 (X64)

If I create this stored procedure in a database.

"create procedure testbug @data image as begin return end"

Then create a script "bug" with the following:

#!/usr/bin/perl

use DBI;

my $dbh=DBI->connect("dbi:ODBC:".$ENV{DB},$ENV{USER},$ENV{PASS},
{PrintError => 1, RaiseError=> 1}) ||
die "Failed DB connect: ".$dbh->errstr;


my $query = qq/{call testbug( ? )}/;
my $sth = $dbh->prepare($query);

my $name="";
while (true) {
$name.="a";
$sth->bind_param(1,$name, -4);
$sth->execute() || die $dbh->errstr;
print length($name)."\n";
}

The "bug" script will die when $name reaches 32768 chars with the message:

DBD::ODBC::st execute failed: Unable to fetch information about the error at ./bug line 17.

however if I replace the query so it includes a ";" at the end like:

my $query = qq/{call testbug( ? )};/;

The code will not die at 32768 chars and goes way beyond (never actually let the program run long enough to determine if it ever does die at some other larger limit).

Matthew
Frediano Ziglio
2012-07-11 21:08:52 UTC
Permalink
Hi,
sorry to reply so late but I saw the mail only after looking at
DBD::ODBC bug report.

Probably that's something wrong with the way we handle parsing the rpc
call. mssql have a limit of 64kb of query so perhaps from here the
32kb limit came (still to test).

Frediano
Post by Matthew McGillis
With intel 64 running Red Hat Enterprise Linux Server 6.1 using FreeTDS 0.82, unixODBC 2.3.0, perl 5.10 and DBD::ODBC 1.29.
Connecting to a Windows box with Microsoft SQL Server 2005 - 9.00.4035.00 (X64)
If I create this stored procedure in a database.
#!/usr/bin/perl
use DBI;
my $dbh=DBI->connect("dbi:ODBC:".$ENV{DB},$ENV{USER},$ENV{PASS},
{PrintError => 1, RaiseError=> 1}) ||
die "Failed DB connect: ".$dbh->errstr;
my $query = qq/{call testbug( ? )}/;
my $sth = $dbh->prepare($query);
my $name="";
while (true) {
$name.="a";
$sth->bind_param(1,$name, -4);
$sth->execute() || die $dbh->errstr;
print length($name)."\n";
}
DBD::ODBC::st execute failed: Unable to fetch information about the error at ./bug line 17.
my $query = qq/{call testbug( ? )};/;
The code will not die at 32768 chars and goes way beyond (never actually let the program run long enough to determine if it ever does die at some other larger limit).
Matthew
Loading...