Re: [HACKERS] Re: [SQL] inserts/updates problem under stressing ! - Mailing list pgsql-hackers

From Adriaan Joubert
Subject Re: [HACKERS] Re: [SQL] inserts/updates problem under stressing !
Date
Msg-id 379C06CE.70797269@albourne.com
Whole thread Raw
In response to Re: [SQL] inserts/updates problem under stressing !  (Oleg Bartunov <oleg@sai.msu.su>)
List pgsql-hackers
> >
> > my $sth = $dbh->do("LOCK TABLE hits IN SHARE ROW EXCLUSIVE MODE");
> > my $sth = $dbh->do("SELECT acc_hits($1)") || die $dbh->errstr;
> >
> > am I right ?
> 
> You should run LOCK and SELECT inside BEGIN/END (i.e. in
> the same transaction), do you?

Yes, in DBI that translates to switching AutoCommit off, and doing an
explicit commit, (roughly)
$dbh->{AutoCommit} = 0;eval {  $dbh->do (...)  ...};if ($@) {   // There was an error   $dbh->rollback();    } else {
$dbh->commit();      }
 

I think you need to set RaiseError=>1 as well when connecting to the
database, to get die's inside the eval.

Adriaan


pgsql-hackers by date:

Previous
From: Oleg Bartunov
Date:
Subject: Re: [SQL] inserts/updates problem under stressing !
Next
From: "Ansley, Michael"
Date:
Subject: RE: [HACKERS] RE: [INTERFACES] Re: SSL patch