From: | Alban Hertroys <alban(at)magproductions(dot)nl> |
---|---|
To: | Arturo Perez <aperez(at)hayesinc(dot)com>, Alban Hertroys <alban(at)magproductions(dot)nl>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Problems with sequences |
Date: | 2006-09-07 13:06:51 |
Message-ID: | 4500196B.3040706@magproductions.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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(at)magproductions(dot)nl
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 //
From | Date | Subject | |
---|---|---|---|
Next Message | Joshua D. Drake | 2006-09-07 13:15:15 | Re: Majordomo drops multi-line Subject: |
Previous Message | Andrew Sullivan | 2006-09-07 13:01:26 | Re: On DNS for postgresql.org |