Steps to reproduce on Ubuntu 20.04:
Install perlbrew
Install FreeTDSsudo apt install gcc make -y wget -O - https://install.perlbrew.pl | bash echo "source ~/perl5/perlbrew/etc/bashrc" >> ~/.profile source ~/perl5/perlbrew/etc/bashrc perlbrew install perl-5.33.8 perlbrew switch perl-5.33.8 perlbrew install-cpanm
Install DBI and Sybasewget ftp://ftp.freetds.org/pub/freetds/stable/freetds-1.2.20.tar.gz tar xfvz freetds-1.2.20.tar.gz cd freetds-1.2.20/ ./configure --prefix=/home/username/tdslib make make install
export SYBASE=/home/username/tdslib cpanm install DBI cpanm DBD::Sybase --verbose --force
The test code above runs a total of six queries with different combinations of (1) specifying the TDS level (2), running a query with or without placeholders , and (3) running a query that does or does not return results. The test query that produces the hang is run last.use warnings; use strict; use DBI; use Data::Dumper; runTest(''); runTest(';tdsLevel=CS_TDS_495'); sub runTest { my ($tdsLevel) = @_; my $dsn = "dbi:Sybase:server=172.28.79.294$tdsLevel"; my $UserName = 'myusername'; my $Password = 'supersecretpassword'; my $dbh = DBI->connect( $dsn, $UserName, $Password, ) or ( print "Can't connect to the DB: $DBI::errstr\n" and die ); print "\nTesting no placeholders, no results $dsn\n"; my $sth = $dbh->prepare("select 'test' where 1=0"); $sth->execute(); my $results = $sth->fetchall_arrayref( {} ); print Dumper $results; print "\nTesting placeholders with results $dsn\n"; my $sthSecond = $dbh->prepare("select ? where 1=1"); $sthSecond->execute("test"); my $resultsSecond = $sthSecond->fetchall_arrayref( {} ); print Dumper $resultsSecond; print "\nTesting placeholders with no results $dsn\n"; my $sthThird = $dbh->prepare("select ? where 1=0"); $sthThird->execute("test"); my $resultsThird = $sthThird->fetchall_arrayref( {} ); print Dumper $resultsThird; $dbh->disconnect(); }
Full disclosure: I first wrote this test script on one computer and then created a virtual machine to test the "steps to reproduce" shown above. On the second computer, the connection with no TDS level specified does not work. However, I believe this to be a separate issue.
The SQL Server here is MS SQL Server Standard version 12.0.5223.6
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |