perl script hangs on query with where clause
Hi,
Can somebody tell me why the second query in this script hangs.
The first query is a simple query without a where clause.
The second one is a query on the same table with a simple where clause.
Tried this on Activestate 5.10.0 distribution (ActivePerl-5.10.0.1004-MSWin32-x86-287188.msi)and Camelbox 5.10.0 distribution (camelbox_2008.304.0742Z-odin.exe)
Mysql = 5.0.51b
Thx
use strict;
use warnings;
use DBI;
my $database="mde";
my $hostname="localhost";
my $dsn = "dbi:mysqlPP:database=$database;host=$hostname";
my $user="root";
my $password="neptunus";
my $sth;
my $dbh = DBI->connect($dsn, $user, $password, {'RaiseError' => 1});
my $drh = DBI->install_driver("mysqlPP");
print "Drop table test...";
$sth = $dbh->do(qq{drop table test});
print "done\n\n";
print "create table test...";
$sth = $dbh->do(qq{
create table test (
v1 int auto_increment primary key
, v2 varchar(10)
, v3 varchar(10)
, v4 varchar(10)
, v5 varchar(10)
)
});
print "done\n\n";
print "Inserting row...";
$dbh->do(qq{insert test(v2,v3,v4,v5) values("a", "b", "c", "d")});
print "done\n\n";
print "The next statement works fine...\n";
print "Executing: select v2 from test...";
$sth = $dbh->prepare("select v1 from test");
$sth->execute();
my @row = $sth->fetchrow_array;
$sth->finish;
print "done\n\n";
print "The next statement will hang...\n";
print "Executing: select v2 from test where v1=1\n";
$sth = $dbh->prepare("select v2 from test where v1=1");
$sth->execute();
print "select with where clause hangs. You will never see this message\n";
$sth->finish;
$dbh->disconnect;