Re: Sequences in transaction context - Mailing list pgsql-general

From Tom Lane
Subject Re: Sequences in transaction context
Date
Msg-id 22489.991805562@sss.pgh.pa.us
Whole thread Raw
In response to RE: Sequences in transaction context  ("Erik Pearson" <erik@cariboulake.com>)
List pgsql-general
"Erik Pearson" <erik@cariboulake.com> writes:
> Thanks for the reply!  I'm afraid I didn't test this thoroughly.  I noticed
> that nextval changed the sequence for all transactions, and assumed that
> currval simply translated to the (nextval() - 1), which it does not, as I
> now understand it.

No.  Each backend process caches the last nextval() result it got for
every sequence object it's ever nextval'd, and this data is what
currval() consults.  That's the only way to ensure cross-process
consistency.  What you see in currval is the last value you obtained,
regardless of what anyone else is doing.

> One last followup question -- what's MVCC?

Multi-version concurrency control.  See
http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/mvcc.html
or my slides on Postgres' transaction model at
http://www.ca.postgresql.org/osdn/index.html

            regards, tom lane

pgsql-general by date:

Previous
From: Igor
Date:
Subject: Re[2]: How to Alter tables with ARRAY? Help PLease
Next
From: Tom Lane
Date:
Subject: Re: Re[2]: How to Alter tables with ARRAY? Help PLease