Re: Sequence behaviour.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Sequence behaviour.
Дата
Msg-id 21972.992930993@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Sequence behaviour.  (Grant <grant@conprojan.com.au>)
Ответы Re: Sequence behaviour.  (Grant <grant@conprojan.com.au>)
Список pgsql-sql
Grant <grant@conprojan.com.au> writes:
> Why is the following like it is? I would think that nextval would return 2
> in both instances, am I missing something here? :) Thanks!

> binary_data=# create sequence test;
> CREATE
> binary_data=# select nextval('test');
> NOTICE:  test.nextval: sequence was re-created

Um, how did you get that NOTICE?  I don't see it.

Anyway, the answer to your question is that there's another bit of
state in a sequence: the is_called flag is initially false and is
set true during the first-ever nextval().  This allows nextval to
deliver the specified start value on the first call, rather than
the one after that.  In 7.1 setval() takes an optional third
argument to reset the value of is_called...
        regards, tom lane


В списке pgsql-sql по дате отправления:

Предыдущее
От: Grant
Дата:
Сообщение: Sequence behaviour.
Следующее
От: darcy@druid.net (D'Arcy J.M. Cain)
Дата:
Сообщение: Re: How to build a TRIGGER in POSTGERSQL