Sequence bug or feature?

From: "rob" <rob(at)cabrion(dot)com>
To: "pgsql-general" <pgsql-general(at)postgresql(dot)org>
Subject: Sequence bug or feature?
Date: 2001-01-06 14:15:03
Message-ID: 000901c077eb$10339610$4100fd0a@cabrion.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

It appears that sequence.last_value and nextval('sequence') are out of sync
when first created. My comments below are in [brackets]. Is this by design
or is this a bug? Does this conform to SQL92? TIA.

--rob

partner=> create SEQUENCE junk;
CREATE
partner=> select junk.last_value;
last_value
------------
1 [ last value is one . . . Thought it would be 0, but
that's no big deal]
(1 row)

partner=> select nextval('junk');
nextval
---------
1 [If last value was one then why is nextval() not 2 ?!?!?]
(1 row)

partner=> select junk.last_value;
last_value
------------
1 [Consistent, but I expected 2 as described above]
(1 row)

partner=> select nextval('junk');
nextval
---------
2 [Ahhh now that's better]
(1 row)

partner=> select junk.last_value;
last_value
------------
2 [Just what I expected . . . ]
(1 row)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Frank Joerdens 2001-01-06 16:12:27 Re: PHP and PostgreSQL
Previous Message Mike Mascari 2001-01-06 10:46:15 Is libpq thread-safe?