Bug #27421 Using mysql_server_prepare causes segmentation fault
Submitted: 25 Mar 2007 1:55 Modified: 20 Feb 2013 22:50
Reporter: Jeff Rife Email Updates:
Status: Unsupported Impact on me:
None 
Category:Connectors: DBD::mysql ( Perl ) Severity:S2 (Serious)
Version:4.004 OS:Linux (Fedora 6)
Assigned to: CPU Architecture:Any

[25 Mar 2007 1:55] Jeff Rife
Description:
Repeatedly executing any prepared statement with a placeholder parameter causes a segmentation fault if "mysql_server_prepare" has been set.

The value of the parameter passed doesn't seem to matter, nor does calling "finish" (although I thought that was the issue, so that's why I did it).

This happens for all users and regardless of whether the connection is local or via TCP/IP.

How to repeat:
use DBI;
my $dbh = DBI->connect('DBI:mysql:mysql_server_prepare=1');

# any prepare with a placeholder parameter will exhibit the symptoms
my $sth = $dbh->prepare("SELECT * FROM mytable WHERE a = ?");

print "About to execute #1";
$sth->execute(1);
print "Finished #1";
$sth->finish();

print "About to execute #2";
$sth->execute(1);  # Segmentation fault here
print "Finished #2";
$sth->finish();
[26 Mar 2007 8:03] Sveta Smirnova
Thank you for the report.

Can you repeat crash without first $sth->finish(); call?

I.e.:

$sth->execute(1);
print "Finished #1";

print "About to execute #2";
$sth->execute(1);
[26 Mar 2007 12:42] Jeff Rife
Yes, if I actually retrieve the row, it segfaults.  Otherwise, the second "execute" generates the following somewhat expected error:

DBD::mysql::st execute failed: no metadata information while trying describe result set at ./dbtest

I did not have the $sth->finish() in my app at first, and added it to test even though I was retrieving all the rows, and it didn't help.  I left it in the bug report to let you know that the statement had been fully executed and everything had been retrieved.
[29 Mar 2007 7:43] Sveta Smirnova
Please indicate version of Perl you use. Also indicate version of MySQL libraries DBD::mysql linked with.
[29 Mar 2007 13:42] Jeff Rife
Perl v5.8.8 built for i386-linux-thread-multi, from Fedora RPM perl-5.8.8-10.

Client libraries are version 5.0.27 from Fedora RPM mysql-5.0.27-1.fc6.
[30 Mar 2007 7:58] Sveta Smirnova
Thank you for the report.

Verified as described.
[20 Feb 2013 22:50] Sveta Smirnova
Thank you for the report.

We don't work on DBD::mysql bugs anymore. All its bugs should go to CPAN: https://rt.cpan.org/Public/Dist/Display.html?Name=DBD-mysql

I re-submitted your report to https://rt.cpan.org/Public/Bug/Display.html?id=83497
Please subscribe to the new report on CPAN and work with DBD::mysql developers in case if they need additional details.