pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Sergei Kornilov <sk@zsrv.org>
To: val.janeiko@gmail.com <val.janeiko@gmail.com>
To: pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>
Subject: Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache
Date: Tue, 12 May 2020 18:44:24 +0300
Message-ID: <1015851589297759@mail.yandex.ru> (raw)
In-Reply-To: <16430-f03b90a57994b00f@postgresql.org>
References: <16430-f03b90a57994b00f@postgresql.org>

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





view thread (6+ messages)  latest in thread

Message-ID: <1015851589297759@mail.yandex.ru>
Permalink:  ../1015851589297759@mail.yandex.ru/
Also on:    postgresql.org/message-id/1015851589297759@mail.yandex.ru

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: sk@zsrv.org, val.janeiko@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache
  In-Reply-To: <1015851589297759@mail.yandex.ru>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox