Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache

From: Sergei Kornilov <sk(at)zsrv(dot)org>
To: "val(dot)janeiko(at)gmail(dot)com" <val(dot)janeiko(at)gmail(dot)com>, "pgsql-bugs(at)lists(dot)postgresql(dot)org" <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache
Date: 2020-05-12 15:44:24
Message-ID: 1015851589297759@mail.yandex.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hello

In one DB connection:

=> CREATE SEQUENCE resource_surrogate_id_uniquifier_sequence
AS integer
START WITH 0
INCREMENT BY 1
MINVALUE 0
MAXVALUE 79999
CYCLE
CACHE 5;
CREATE SEQUENCE
=> select nextval('resource_surrogate_id_uniquifier_sequence');
nextval
---------
0
=> select nextval('resource_surrogate_id_uniquifier_sequence');
nextval
---------
1
=> select nextval('resource_surrogate_id_uniquifier_sequence');
nextval
---------
2
=> select nextval('resource_surrogate_id_uniquifier_sequence');
nextval
---------
3

In another connection:

=> select nextval('resource_surrogate_id_uniquifier_sequence');
nextval
---------
5
=> select nextval('resource_surrogate_id_uniquifier_sequence');
nextval
---------
6

All as expected. This is how the sequence cache option works - we preallocate values for further use in current connection.

regards, Sergei

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2020-05-12 15:47:35 Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache
Previous Message Tom Lane 2020-05-12 15:42:45 Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache