Search Postgresql Archives

Re: Problems with sequences

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martijn van Oosterhout wrote:
On Thu, Sep 07, 2006 at 07:15:43AM -0400, Arturo Perez wrote:
iht=> select max(article_id) from article;
max
------
4992
(1 row)

iht=> select nextval('pk_article');
nextval
---------
    4986
(1 row)

Assuming the sequence number is being used correctly why would they be 6 apart?

The last four transactions could be rolled back, or not committed yet.

Could you elaborate on that? I'm confused...

AFAIK after the sequence was initialised at max(article_id), nextval(article_id) could never return a number that's lower than max(article_id).

Unless:
a) the OP managed to query max(article_id) and nextval(article_id) from different transactions, the one querying nextval being older than the one querying max. b) the OP inserted numbers not coming from the sequence; he shot his own feet.
  c) the sequence wrapped around due to reaching numbers exceeding 2^32.

Or are you short on caffeine perhaps? ;)

Regards,
--
Alban Hertroys
alban@xxxxxxxxxxxxxxxxx

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux