Re: Sequences/defaults and pg_dump

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: nikolay(at)samokhvalov(dot)com
Cc: PostgreSQL-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Sequences/defaults and pg_dump
Date: 2006-02-07 13:12:45
Message-ID: 20060207131245.GC19240@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Tue, Feb 07, 2006 at 03:28:31PM +0300, Nikolay Samokhvalov wrote:
> The real situation would be as the following.
> I want to use some algorithm to hide real number of registered users
> in my table user. So, I don't want to use simple sequence, when every
> new registered user in my system can guess what is the number of
> registered users simply observing his ID. So, I use following
> algorithm:
> (nextval('...name of the sequnence...') * N) mod % M,
> where N and M are quite big numbers that have no common multiples
> besides 1 (sorry, do not remember the English term for those numbers
> ;-) ).

Even then you could do it by saying:

ALTER SEQUENCE x MAXVALUE M INCREMENT N CYCLE;

> I wonder why people didn't notice this bug earlier, but I'm sure that
> there are many situations when it could be revealed. For example, what
> if I want to use nextval('seq1') * nextval('seq2') ?.. I'm sure that
> if you think you'll discover new examples that would be used in real
> world.
>
> Anyway, this is a bug, and I'll write the bug report to bugs mailing list.

Please do. It wouldn't be noticed much due to most people regarding
sequences as opaque ie the numbers themselves don't mean anything. But
if you alter the sequence or the default, pg_dump should dump it
correctly.

(This may be a know bug btw, I don't know).
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message gwx cathy 2006-02-07 14:00:16 Installation of PostGIS
Previous Message Robert Treat 2006-02-07 13:03:20 Re: Compile of Pgmail function fails

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2006-02-07 14:43:34 Re: Sequences/defaults and pg_dump
Previous Message Nikolay Samokhvalov 2006-02-07 12:28:31 Re: Sequences/defaults and pg_dump