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
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---
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.
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