Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Tuesday October 16, 2007
10:28 AM

DBD::mysql Bug With Quotes In Comments

[ #34693 ]

I was trying to debug a 70 line SQL statement and it kept insisting that I was trying to call the statement with one bind variable when none were needed. I called over smylers and he was mystified, too. We tried many different things, but clearly there was a bind variable that wasn't being recognized. Pasting the SQL directly into MySQL seemed fine (though obviously without the bind variable).

Then smylers pointed out in my liberally commented SQL that I had single quote marks (') in said comments. I removed all of those quote marks and the SQL ran just fine. Here's a small program which reproduces the error:

#!/usr/bin/perl

use strict;
use warnings;

use DBI;

my $dsn = "DBI:mysql:database=mydatabase;host=localhost";
my $dbh = DBI->connect( $dsn, qw/user pass/, { RaiseError => 1 } )
  or die $DBI::errstr;

$dbh->do('DROP TABLE IF EXISTS buggy');
$dbh->do('CREATE TABLE buggy ( id int(3) )');
$dbh->do('INSERT INTO buggy (id) VALUES (1)');
$dbh->selectrow_arrayref(<<'END', {}, 1);
    SELECT id
    FROM buggy
    -- it's a bug!
    WHERE id = ?
END

This bug is now reported.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.