dbd:pg finish() bug - Mailing list pgsql-bugs

From Vivek Khera
Subject dbd:pg finish() bug
Date
Msg-id 15119.63751.783572.411703@yertle.kciLink.com
Whole thread Raw
List pgsql-bugs
The DBD::Pg driver doesn't properly reset "Active" state when all data
from a handle is fetched, as specified in the DBI docs under the
description of finish().

This program should not report any warnings with the finish() method
commented out.  It however, complains about an active handle during
the destroy.

The sample database is below.

--cut here--
#! /usr/bin/perl
use strict;

use DBI;

&main();

sub main {
  my $dbh = DBI->connect('dbi:Pg:dbname=khera','khera',undef,{PrintError=>1})
    or die "dbi connect failure: ".$DBI::errstr;

  my $sth = $dbh->prepare('select a,b from t1')
    or die $dbh->errstr;

  $sth->execute();
  while (my ($a,$b) = $sth->fetchrow_array()) {
    print "a=$a, b=$b\n";
  }

  print 'active:',$sth->{Active},"\n";
  # finish is not necessary according to DBI...
  $sth->finish();
  print 'active:',$sth->{Active},"\n";

  print "--------\n";

  $dbh->disconnect();
}
--cut here--


CREATE TABLE "t1" (
        "a" integer,
        "b" integer
);
COPY "t1"  FROM stdin;
1       2
2       3
3       4
\.

pgsql-bugs by date:

Previous
From: Edmund Mergl
Date:
Subject: Re: dbd:pg finish() bug
Next
From: Brent Ewing
Date:
Subject: repeated pointless memmove() calls in pqReadData()