Skip Menu |
 

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

Report information
The Basics
Id: 92810
Status: resolved
Priority: 0/
Queue: DBD-Firebird

People
Owner: dam [...] cpan.org
Requestors: HMBRAND [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: 1.16
Fixed in: 1.17



Subject: Cannot execute prepared statement twice
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
Message-ID: <rt-4.0.18-13241-1391792227-1884.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 1662
Download (untitled) / with headers
text/plain 1.6k
my $sth= $dbh->prepare ("select * from foo where id = ?"); should be excutable multiple times. Currently it is not The below patch adds the test case The error is as follows: prove -wvb t/43-cursor.t t/43-cursor.t .. 1..27 ok 1 - Connected to the database ok 2 - TABLE is 'TESTAE' ok 3 - CREATE TABLE 'TESTAE' ok 4 - PREPARE INSERT ok 5 - INSERT id 6 ok 6 - INSERT id 1 ok 7 - INSERT id 2 ok 8 - STH ok 9 - Excute for 1 ok 10 - Fetch for 1 ok 11 - Comment for 1 ok 12 - Excute for 2 DBD::Firebird::st fetchrow_array failed: The cursor identified in an OPEN statement is already open. -Dynamic SQL Error -SQL error code = -502 -Attempt to reopen an open cursor at t/43-cursor.t line 65. Use of uninitialized value in null operation at t/43-cursor.t line 65. --8<--- diff --git a/t/43-cursor.t b/t/43-cursor.t index 3edb64f..af30fb7 100644 --- a/t/43-cursor.t +++ b/t/43-cursor.t @@ -28,7 +28,7 @@ unless ( $dbh->isa('DBI::db') ) { plan skip_all => 'Connection to database failed, cannot continue testing'; } else { - plan tests => 17; + plan tests => 27; } ok($dbh, 'Connected to the database'); @@ -59,6 +59,13 @@ ok($cursor->execute($_, $values{$_}), "INSERT id $_") for (keys %values); $dbh->{AutoCommit} = 0; +ok (my $sth = $dbh->prepare("select comment from $table where user_id = ?"),"STH"); +foreach my $id (sort keys %values) { + ok($sth->execute($id),"Excute for $id"); + ok(my($c)=$sth->fetchrow_array(),"Fetch for $id"); + is($c,$values{$id},"Comment for $id"); +} + my $sql_sele = qq{SELECT * FROM $table WHERE user_id < 5 FOR UPDATE OF comment}; ok(my $cursor2 = $dbh->prepare($sql_sele), 'PREPARE SELECT'); -->8---
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-13241-1391792227-1884.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-13241-1391792227-1884.0-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-16416-1391861742-159.92810-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 520
Download (untitled) / with headers
text/plain 520b
Show quoted text
> my $sth= $dbh->prepare ("select * from foo where id = ?"); > should be excutable multiple times. Currently it is not > > The below patch adds the test case
Thanks for the patch. This is certainly a bug. Here's what the DBI docs say about statement's execute() method: ----- If execute() is called on a statement handle that's still active ($sth->{Active} is true) then it should effectively call finish() to tidy up the previous execution results before starting this new execution. ----- I'll work on fixing this.
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-16416-1391861742-159.92810-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline
X-RT-Interface: Web
References: <rt-4.0.18-13241-1391792227-1884.0-0-0 [...] rt.cpan.org> <rt-4.0.18-16416-1391861742-159.92810-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="utf-8"
Message-ID: <rt-4.0.18-7011-1392133366-1348.92810-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 507
Download (untitled) / with headers
text/plain 507b
Show quoted text
> Thanks for the patch. This is certainly a bug. Here's what the DBI > docs say about statement's execute() method: > > ----- > If execute() is called on a statement handle that's still active > ($sth->{Active} is true) then it should effectively call finish() to > tidy up the previous execution results before starting this new > execution. > ----- > > I'll work on fixing this.
You can also get the fix from my github fork. I could not resist the temptation. https://github.com/Tux/perl-dbd-firebird


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.