Perl DBD Can't use placeholders with MySQL LIMITs

software development

#1

Very recently, another user and myself have noticed that scripts die if they use placeholders for the LIMIT parameters when using Perl, DBI and DBD::mysql.

If you don’t know what that means, ignore this post. But if you do, you’ll find that any of your Perl code which looks like this:

$sth = $dbh->prepare("select * from foo LIMIT ?,?"); $sth->execute(1,100)
will die with an error advising you to check your code for a syntax error near ''1','100''
The temporary fix is that you don’t prepare with placeholders, you just repeatedly do the prepare with the actual numbers.

The theory is that Dreamhost have upgraded the version of the DBD::mysql module to a more recent one, 2.9, which has this problem (more information at http://lists.mysql.com/perl/3543).

I’ve put in a support request and am waiting to hear back.