Re: Sequence bug or feature?
| От | Tom Lane |
|---|---|
| Тема | Re: Sequence bug or feature? |
| Дата | |
| Msg-id | 17316.978800397@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Sequence bug or feature? ("rob" <rob@cabrion.com>) |
| Список | pgsql-general |
"rob" <rob@cabrion.com> writes:
> 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.
It's by design. Note the is_called flag, which might be better named
ever_advanced or some such. The initial state is last_value = initial
value, is_called = false. The first nextval changes is_called to true;
subsequent ones increment last_value. So last_value is the last value
assigned only if a value has ever been assigned, ie, is_called is true.
This is a little bit baroque, agreed. I think the idea was to allow
sequences to start at MININT without creating arithmetic-overflow
issues.
regards, tom lane
В списке pgsql-general по дате отправления: