Skip Menu |

This queue is for tickets about the DBD-DB2 CPAN distribution.

Report information
The Basics
Id: 77414
Status: resolved
Priority: 0/
Queue: DBD-DB2

People
Owner: Nobody in particular
Requestors: dmcbride [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.84
Fixed in: (no value)



Subject: DBD::DB2 can't bind under perl 5.16.0
When I have a "SUM(CASE WHEN COL = 'Y' THEN 100 ELSE 0 END)" column *and* I have a variable for binding, DBD::DB2 is failing. Here is my code, pared down a lot: use 5.14.0; use DBI; my $dbh = DBI->connect('dbi:DB2:cbstats') or die "Can't connect: ", $DBI::errstr; say "Perl $^V, DBI $DBI::VERSION, DBD::DB2 $DBD::DB2::VERSION"; my $sql = <<SQL; SELECT SUM(CASE WHEN QUESTION = 'Y' THEN 100.00 ELSE 0 END) / COUNT(*) AS PCT FROM CBSTATS.LOGS, CBSTATS.USER WHERE FROM = NICK AND VISIBLE = ? GROUP BY FROM HAVING COUNT(*) > 10 SQL my $sth = $dbh->prepare($sql) or die "Can't prepare SQL: $dbh-> {errstr}"; my @param = ('Y'); $sth->execute(@param) or die "Can't execute: $dbh->{errstr}"; And here is the output using both Perl 5.14.2 and 5.16.0: $ for x in 14.2 16.0; do perl5.$x db.pl; done Perl v5.14.2, DBI 1.616, DBD::DB2 1.81 Perl v5.16.0, DBI 1.616, DBD::DB2 1.84 Can't bind unknown parameter marker ':p1' at db.pl line 29. With 5.14.2, this all works. With 5.16.0, not so much. Running Linux/amd64.
Looks like dbdimp.c: if (*src == '\'') { in_literal = ~in_literal; } should be: if (*src == '\'') { in_literal = !in_literal; } This seems to resolve it in perl5.16.0. I haven't tried in other perls. I'm not sure why this was using ~ in the first place.
Hi Darrin, Thanks for reporting this. I am currently tied up with other works and would need some time to look into this. -- Thanks Praveen IBM OpenSource Application Development Team India Software Labs, Bangalore (India)
Hi Darin, I am able to repro the issue, and Yes the unary negate operator (~) is the problem. Changing the operator to ! will fix the issue. I have checked this fix on older version of Perl too and it works fine. Will have this fix rolled out in the next release of the DBD::DB2 module. -- Thanks Praveen IBM OpenSource Application Development Team India Software Labs, Bangalore (India)
Fix available in version 1.85 -- Thanks Praveen IBM OpenSource Application Development Team India Software Labs, Bangalore (India)