pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ernest E Vogelsinger <ernest@vogelsinger.at>
To: Jodi Kanter <jkanter@virginia.edu>
Cc: Postgres Admin List <pgsql-admin@postgresql.org>
Subject: Re: psql sequence question
Date: Mon, 16 Jun 2003 20:26:37 +0200
Message-ID: <5.1.1.6.2.20030616202213.03ce7be0@mail.vogelsinger.at> (raw)
In-Reply-To: <3EEDE12C.30401@virginia.edu>

At 17:24 16.06.2003, Jodi Kanter said:
--------------------[snip]-------------------- 

>If I'm using transactions (not autocommit), are sequences atomic?

Yes

>In other words, after inserting a record to a table that 
>uses sequence A, am I guaranteed that select last_value on 
>sequence A is atomic, and cannot be interfered with by other 
>transactions using that same sequence? Sequence A is used by
>several tables.

Yes. But you should use currval('seq_name') since this guarantees to return
the last value returned to the current connection. Check the recent posts -
there was a discussion on just this topic.

-- 
   >O     Ernest E. Vogelsinger
   (\)    ICQ #13394035
    ^     http://www.vogelsinger.at/





view thread (5+ messages)  latest in thread

Message-ID: <5.1.1.6.2.20030616202213.03ce7be0@mail.vogelsinger.at>
Permalink:  ../5.1.1.6.2.20030616202213.03ce7be0@mail.vogelsinger.at/
Also on:    postgresql.org/message-id/5.1.1.6.2.20030616202213.03ce7be0@mail.vogelsinger.at

 · 

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-admin@postgresql.org
  Cc: ernest@vogelsinger.at, jkanter@virginia.edu
  Subject: Re: psql sequence question
  In-Reply-To: <5.1.1.6.2.20030616202213.03ce7be0@mail.vogelsinger.at>
  References: <3EEDE12C.30401@virginia.edu> <5.1.1.6.2.20030616202213.03ce7be0@mail.vogelsinger.at>

* 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