Skip Menu |

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

Report information
The Basics
Id: 75713
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: rep.dot.nop [...] gmail.com
Cc:
AdminCc:

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



Subject: using named bind parameter more than once fails on execute (2.19.1 REGRESSION)
Date: Mon, 12 Mar 2012 14:48:01 +0100
To: bug-DBD-Pg [...] rt.cpan.org
From: Bernhard Reutner-Fischer <rep.dot.nop [...] gmail.com>
Hi, With 2.19.1, binding two occurances of a named bind_param fails. This used to work fine with 2.18.1. $ cat x.pl ;echo "---8<---";perl ./x.pl #!/usr/bin/env perl use warnings; use strict; use DBI; my $dbh = DBI->connect('dbi:Pg:dbname=mydb', '', ''); my $sth = $dbh->prepare(' select 1 where 1 = :foo and 0 < :foo '); $sth->bind_param(':foo', 1); $sth->execute; my $rows = $sth->rows; print "ROWS [$rows]\n"; $sth->finish; $dbh->disconnect; ---8<--- 2.19.1: DBD::Pg::st execute failed: execute called with an unbound placeholder at x.pl line 11. 2.18.1: works fine: ROWS [1] Using unnamed placeholders (like $1) of course works fine. Something like this in the testsuite might be handy to prevent future regressions: $ git diff t/12placeholders.t | cat diff --git a/t/12placeholders.t b/t/12placeholders.t index 0fdd3b5..9460eaf 100644 --- a/t/12placeholders.t +++ b/t/12placeholders.t @@ -65,6 +65,16 @@ eval { }; like ($@, qr{when 0 are needed}, $t); +# in 2.19.1 we counted named bind params wrongly: +# Each bind_param satisfies one OR MORE occurances in the SQL string! +$t='Execute with two identical placeholders works'; +$sql = 'SELECT 1 WHERE 1 = :foo AND 0 < :foo'; +$sth = $dbh->prepare($sql); +$sth->bind_param(':foo', '1'); +$sth->execute(); +($retr) = $sth->fetchrow_array(); +is ($retr, '1', $t); + $t='Execute with ? placeholder works'; $sql = 'SELECT pname FROM dbd_pg_test WHERE pname = ?'; $sth = $dbh->prepare($sql); TIA and cheers,
Subject: Re: [rt.cpan.org #75713] using named bind parameter more than once fails on execute (2.19.1 REGRESSION)
Date: Tue, 13 Mar 2012 16:09:33 +0100
To: Bugs in DBD-Pg via RT <bug-DBD-Pg [...] rt.cpan.org>
From: Bernhard Reutner-Fischer <rep.dot.nop [...] gmail.com>
On Mon, Mar 12, 2012 at 09:48:13AM -0400, Bugs in DBD-Pg via RT wrote: Show quoted text
>
Works fine now in 2.19.2, thanks for the speedy fix! cheers,