MySQL Forums
Forum List  »  Perl

perl script hangs on query with where clause
Posted by: Johan De Graeve
Date: December 05, 2008 07:02PM


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- Camelbox 5.10.0 distribution (camelbox_2008.304.0742Z-odin.exe)

Mysql = 5.0.51b


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");
my @row = $sth->fetchrow_array;
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");
print "select with where clause hangs. You will never see this message\n";


Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.