pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adriaan Joubert <a.joubert@albourne.com>
Cc: Oleg Bartunov <oleg@sai.msu.su>
Cc: pgsql-hackers@postgreSQL.org
Subject: Re: [HACKERS] Re: [SQL] inserts/updates problem under stressing !
Date: Mon, 26 Jul 1999 09:57:18 +0300
Message-ID: <379C06CE.70797269@albourne.com> (raw)
References: <Pine.GSO.3.96.SK.990726100222.10884A-100000@ra>
	<379BFF7E.BD57269E@krs.ru>

> >
> > 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



view thread (11+ messages)

Message-ID: <379C06CE.70797269@albourne.com>
Permalink:  ../379C06CE.70797269@albourne.com/
Also on:    postgresql.org/message-id/379C06CE.70797269@albourne.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: a.joubert@albourne.com, oleg@sai.msu.su, pgsql-hackers@postgreSQL.org
  Subject: Re: [HACKERS] Re: [SQL] inserts/updates problem under stressing !
  In-Reply-To: <379C06CE.70797269@albourne.com>
  References: <Pine.GSO.3.96.SK.990726100222.10884A-100000@ra> <379BFF7E.BD57269E@krs.ru> <379C06CE.70797269@albourne.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox