Re: Perl and AutoCommit - Mailing list pgsql-general

From Greg Sabino Mullane
Subject Re: Perl and AutoCommit
Date
Msg-id d252273c12f3cfd318521979b8620dc4@biglumber.com
Whole thread Raw
In response to Re: Perl and AutoCommit  (Madison Kelly <linux@alteeve.com>)
List pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


> $DB->{AutoCommit} = 0 || die...

As someone pointed out, this always dies. In general, you don't
need (or want) to test the results of setting a variable. Also be
aware that in this case you probably want "or" and not "|" - the former
tests the result of "$DB->{AutoCommit} = 0", while the latter actually
tries to set $DB->{AutoCommit} to first "0" and then to the result
of "die". What you want is really

($DB->{AutoCommit} = 0) || die;

which is the same thing, and better written as:

$DB->{AutoCommit} = 0 or die;

Best of all is just to remove the line entirely, as there is no point in
testing the assignment: simply view the contents afterwards:

$DB->{AutoCommit} = 0;
print " |- AutoCommit now: $DB->{AutoCommit}\n";

Also be aware that for DBD::Pg, the following is a known bug
(will be fixed in the upcoming 1.41 release):

> $DB->commit() || die...

In some circumstances commit() returns false when it should return true
(even though it still committed). If you find that happening, simply change
it to $DB->commit(); and trust that the correct thing is indeed happening.

- --
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200503271548
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----

iD8DBQFCRx7hvJuQZxSWSsgRAntrAKDyjLhxsSMjIhsjMVtuEwbXXdeqSACg+ri1
F65YHQhWg2c0j8ZwT9LMDP4=
=gTE2
-----END PGP SIGNATURE-----



pgsql-general by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: Clustering system tables
Next
From: Mark Greenbank
Date:
Subject: dblinks?