Re: DBI driver and transactions - Mailing list pgsql-general

From greg@turnstep.com
Subject Re: DBI driver and transactions
Date
Msg-id 8c57f32fbc49613858db7e564b49e7e3@biglumber.com
Whole thread Raw
In response to Re: DBI driver and transactions  (Lincoln Yeoh <lyeoh@pop.jaring.my>)
Responses Re: DBI driver and transactions
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> Yep before you disconnect/quit, you're supposed to finish active
> statements. e.g. prepare, execute, use up results, or call finish if you
> don't need the rest of the results.

Exactly. The error only appears after you have done a prepare *and* a
select, with no concomitant finish or fetching. Here is a code sample:

use DBI;

my $dbh = DBI->connect("dbi:Pg:dbname=foobar", $user, $pass,
         {AutoCommit=>0, RaiseError=>1, PrintError=>0});

my $sth = $dbh->prepare("SELECT * FROM baz WHERE waldo > ?");

my $count = $sth->execute(120);

## Exiting here will cause the warning described

if ($count eq "0E0") {
  $sth->finish();
}
else {
  my $info = $sth->fetchall_arrayref({});
  ## Do something with info...
}

## Exiting is now safe: commit and disconnect are separate issues...


- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200302030912

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE+PnomvJuQZxSWSsgRAhTMAKDLEzXWlGdEQJWKZ72qafkkBL9PRQCfVuh3
uFGqo2u41jwQFONCT9VBAks=
=axjF
-----END PGP SIGNATURE-----



pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: FOSDEM schedule
Next
From: Tom Lane
Date:
Subject: Re: commit errors