Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache
От | Tom Lane |
---|---|
Тема | Re: BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache |
Дата | |
Msg-id | 22565.1589298165@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache (PG Bug reporting form <noreply@postgresql.org>) |
Список | pgsql-bugs |
PG Bug reporting form <noreply@postgresql.org> writes: > When using Sequence inside a plpgsql function called using SELECT func() > using Npgsql library a sequence is incremented by the value specified in > CACHE. If you're reconnecting for each query, this is the expected result. Per the manual (see Notes under CREATE SEQUENCE): Unexpected results might be obtained if a cache setting greater than one is used for a sequence object that will be used concurrently by multiple sessions. Each session will allocate and cache successive sequence values during one access to the sequence object and increase the sequence object's last_value accordingly. Then, the next cache-1 uses of nextval within that session simply return the preallocated values without touching the sequence object. So, any numbers allocated but not used within a session will be lost when that session ends, resulting in “holes” in the sequence. If you don't like it, don't use cache settings greater than one. regards, tom lane
В списке pgsql-bugs по дате отправления: