Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache - Mailing list pgsql-bugs

From Sergei Kornilov
Subject Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache
Date
Msg-id 1015851589297759@mail.yandex.ru
Whole thread Raw
In response to BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache  (PG Bug reporting form <noreply@postgresql.org>)
List 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



pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache
Next
From: "David G. Johnston"
Date:
Subject: Re: BUG #16430: Sequence with cache > 1 makes it increment by numberspecified as cache