We're continuing with our struggles to get Perl working properly to
connect to MS SQL server, and have come up against a nasty bug that
results in segmentation faults when attempting to do a $dbh->do(...)
to set TEXTSIZE or truncate tables.
I'm running the following:
Perl : 5.012003 (x86_64-linux)
OS : linux (2.6.18-194.el5)
DBI : 1.616
DBD::ODBC : 1.29
EasySoft ODBC driver: 1.3
MS SQL Server 2008.
The following code generates a segfault when _ExecDirect is called at
DBD/ODBC.pm at line 396.
my $dbh = DBI->connect("dbi:ODBC:MSSQL", $user, $password) || die
"Error connecting: $!";
$dbh->{LongReadLen} = 25000;
$sql = 'SELECT @@TEXTSIZE';
$sth = $dbh->prepare($sql);
$sth->execute();
print "SQL1: $sql:\n";
while ( @row = $sth->fetchrow_array ) {
print join( ", ", @row ), "\n";
}
$sql = 'set textsize 100';
print "SQL2: $sql:\n";
$sth = $dbh->do($sql);
warn 0;
And the output is:
$ ./set_text_size_test.pl
SQL1: SELECT @@TEXTSIZE:
-1
SQL2: set textsize 100:
Segmentation fault (core dumped)
and the "0" is never printed.
Running this in the Perl debugger shows me that it dies at DBD::ODBC
at line 396, at which point it calls is an XS method defined in ODBC.c
on line 133:
void
_ExecDirect( dbh, stmt )
SV * dbh
SV * stmt
CODE:
{
STRLEN lna;
/*char *pstmt = SvOK(stmt) ? SvPV(stmt,lna) : "";*/
ST(0) = sv_2mortal(newSViv( (IV)dbd_db_execdirect( dbh, stmt ) ) );
}
Anyone have any idea what might be going on here?
Also, notice that the initial "SELECT @@TEXTSIZE" returns -1, which is
an unusual value.
Thanks for any help you might be able to provide.
Eric