Skip site navigation (1) Skip section navigation (2)

dbd:pg finish() bug

From: Vivek Khera <khera(at)kcilink(dot)com>
To: E(dot)Mergl(at)bawue(dot)de, pgsql-bugs(at)postgresql(dot)org
Subject: dbd:pg finish() bug
Date: 2001-05-26 18:42:15
Message-ID: 15119.63751.783572.411703@yertle.kciLink.com (view raw or flat)
Thread:
Lists: 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
\.


Responses

pgsql-bugs by date

Next:From: Edmund MerglDate: 2001-05-27 14:15:22
Subject: Re: dbd:pg finish() bug
Previous:From: Tom LaneDate: 2001-05-26 15:01:30
Subject: Re: DROP USER results in backend closure

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group