Re: DBI driver and transactions

Поиск
Список
Период
Сортировка
От greg@turnstep.com
Тема Re: DBI driver and transactions
Дата
Msg-id 8c57f32fbc49613858db7e564b49e7e3@biglumber.com
обсуждение исходный текст
Ответ на Re: DBI driver and transactions  (Lincoln Yeoh <lyeoh@pop.jaring.my>)
Ответы Re: DBI driver and transactions  ("Nigel J. Andrews" <nandrews@investsystems.co.uk>)
Список 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 по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: FOSDEM schedule
Следующее
От: Tom Lane
Дата:
Сообщение: Re: commit errors