Subject: | mysql_server_prepare and mysql_use_result are mutually incompatible Submitted: 8 Jun 2010 18:57 |
Originally reported by Becca Turner at
http://bugs.mysql.com/bug.php?id=54347
Description:
If you enable both mysql_server_prepare and mysql_use_result then all
queries result in statement handles that give this error when you call
fetchrow_* on them:
Attempt to read a row while there is no result set associated with the
statement
How to repeat:
The code below should print 'result=1' but instead generates the error
'DBD::mysql::st fetchrow_array failed: Attempt to read a row while there
is no result set associated with the statement'. Disabling either
server_prepare or use_result makes it work as expected.
my $dbh = DBI->connect( 'dbi:mysql:', $user, $pass );
$dbh->{'mysql_server_prepare'} = 1;
$dbh->{'mysql_use_result'} = 1;
my $sth = $dbh->prepare( "SELECT 1" );
$sth->execute;
my ($result) = $sth->fetchrow_array;
print "result=$result\n";
Output of attached test:
#Server version: 5.0.51a-24+lenny3 (Debian)
DBI: 1.611
DBD::mysql 4.014
SQL: SELECT 1
server_prepare=0, use_result=0: 1
server_prepare=0, use_result=1: 1
server_prepare=1, use_result=0: 1
server_prepare=1, use_result=1: DBD::mysql::st fetchrow_array failed:
Attempt to read a row while there is no result set associated with the
statement at test.pl line 18.
Subject: | sp_and_ur_break.pl |
use DBI;
my $dbh = DBI->connect( 'dbi:mysql:', @ARGV )
or die "Could not connect.\n";
my $sql = "SELECT 1";
print "DBI: $DBI::VERSION\n";
print "DBD::mysql $DBD::mysql::VERSION\n";
print "SQL: $sql\n";
$|=1;
for my $sp ( 0..1 ) {
$dbh->{'mysql_server_prepare'} = $sp;
for my $ur ( 0..1 ) {
print "server_prepare=$sp, use_result=$ur: ";
$dbh->{'mysql_use_result'} = $ur;
my $sth = $dbh->prepare( $sql );
$sth->execute;
my ($result) = $sth->fetchrow_array;
$sth->finish;
print "$result\n";
}
}