pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #9485: RFE - cycling sequence rollover to do modulo
2+ messages / 2 participants
[nested] [flat]
* BUG #9485: RFE - cycling sequence rollover to do modulo
@ 2014-03-08 03:54 Paul.Murray@environment.gov.au
0 siblings, 1 reply; 2+ messages in thread
From: Paul.Murray@environment.gov.au @ 2014-03-08 03:54 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 9485
Logged by: Paul Murray
Email address: Paul.Murray@environment.gov.au
PostgreSQL version: 9.3.2
Operating system: OSX
Description:
When a sequence with a cycle does a rollover, it sets itself to its minimum
value.
I would like an option to create a sequence that resets to the minimum value
plus the amount by which the next number exceeded the maximum. Perhaps like
this:
create sequence foo increment 616 min value 0 maxvalue 999 cycle modulo;
This allows me to create a sequence where the generated numbers are not
consecutive, but which will exhaust the number range I have assigned (by
making the increment relatively prime to the number of elements in the
range).
(PS: 616/1000 is, of course, the golden ratio <g>)
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #9485: RFE - cycling sequence rollover to do modulo
@ 2014-03-09 23:47 Alvaro Herrera <alvherre@2ndquadrant.com>
parent: Paul.Murray@environment.gov.au
0 siblings, 0 replies; 2+ messages in thread
From: Alvaro Herrera @ 2014-03-09 23:47 UTC (permalink / raw)
To: Paul.Murray@environment.gov.au; +Cc: pgsql-bugs
Paul.Murray@environment.gov.au wrote:
> When a sequence with a cycle does a rollover, it sets itself to its minimum
> value.
>
> I would like an option to create a sequence that resets to the minimum value
> plus the amount by which the next number exceeded the maximum. Perhaps like
> this:
>
> create sequence foo increment 616 min value 0 maxvalue 999 cycle modulo;
Would this be useful?
http://www.postgresql.org/message-id/CA+U5nMKh+pmbaGUd_x9ev-F5k+whT8HM7wXfkX9ouF=cPkAQEg@mail.gmail....
You'd have to create a new "sequence access method" that provided the
behavior you want.
I think it'd be interesting to have an implementation of the behavior
you want on top of the proposed patch.
--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2014-03-09 23:47 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-03-08 03:54 BUG #9485: RFE - cycling sequence rollover to do modulo Paul.Murray@environment.gov.au
2014-03-09 23:47 ` Alvaro Herrera <alvherre@2ndquadrant.com>
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