Re: A problem with sequences...

Поиск
Список
Период
Сортировка
Искать
От
Stephan Szabo
Тема
Re: A problem with sequences...
Дата
Msg-id
20030221103441.H59965-100000@megazone23.bigpanda.com
Ответ на
Список
Дерево обсуждения
A problem with sequences... Dmitry Tkach <dmitry@openratings.com>
Re: A problem with sequences... Richard Huxton <dev@archonet.com>
Re: A problem with sequences... Dima Tkach <dmitry@openratings.com>
Re: A problem with sequences... Richard Huxton <dev@archonet.com>
Re: A problem with sequences... Dmitry Tkach <dmitry@openratings.com>
Re: A problem with sequences... Dmitry Tkach <dmitry@openratings.com>
Re: A problem with sequences... Stephan Szabo <sszabo@megazone23.bigpanda.com>
Re: A problem with sequences... Dmitry Tkach <dmitry@openratings.com>
On Fri, 21 Feb 2003, Dmitry Tkach wrote:

> rapidb=# select last_value from answer_id_seq;
>   last_value
> ------------
>        22124
> (1 row)
>
> rapidb=# select setval ('answer_id_seq', id) from answer order by id desc limit 1;
>   setval
> --------
>    25000
> (1 row)
>
> rapidb=# select currval('answer_id_seq');
>   currval
> ---------
>     21452
> (1 row)
>
> So, the question I have now is - what's going on?
> How come setval() reports 25000, but the currval changes to 21452
> If my query is wrong (and I can't really see what's wrong with it), then why does it report the correct value?

IIRC, currval returns the last value given by the sequence (in nextval) to
this session.  What does a select nextval('answer_id_seq') give you?
21453 or 25001?

В списке pgsql-general по дате отправления
От: Stephan Szabo
Дата:
Сообщение: Re: Mutating table (urgent)
От: Doug McNaught
Дата:
FAQ