Re: A problem with sequences...

From: Doug McNaught <doug(at)mcnaught(dot)org>
To: Dmitry Tkach <dmitry(at)openratings(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: A problem with sequences...
Date: 2003-02-21 18:37:29
Message-ID: m37kbtzdhy.fsf@varsoon.wireboard.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dmitry Tkach <dmitry(at)openratings(dot)com> writes:

> select setval('answer_id_seq', id) from answer order by id desc limit 1;
>
> Now, for some reason this reports a correct value, but what actually
> gets set is wrong!

I'm guessing that 'setval' is getting called more than once here.
Your 'LIMIT 1' controls how many rows are returned to the client, but
the server is probably generating more rows internally. So this is
just wrong, and

> select setval ('answer_id_seq', max(id)) from answer

is right.

-Doug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Hunter Hillegas 2003-02-21 18:51:34 Best PostgreSQL Tuning Reference
Previous Message Stephan Szabo 2003-02-21 18:35:43 Re: A problem with sequences...