Re: Sequences/defaults and pg_dump

From: Nikolay Samokhvalov <samokhvalov(at)gmail(dot)com>
To: PostgreSQL-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Sequences/defaults and pg_dump
Date: 2006-02-07 12:28:31
Message-ID: e431ff4c0602070428ge4864ffr6c842778d91ea572@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On 2/7/06, Martijn van Oosterhout <kleptog(at)svana(dot)org> wrote:
> On Tue, Feb 07, 2006 at 02:33:56PM +0300, Nikolay Samokhvalov wrote:
<snip>
> Well, it's a very contrived example (I can't think of a reason why one
> would do that) but I agree it is a bug. You could acheive the same
> effect by setting the step of the sequence to 10.

'* 10' is just an example.
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
;-) ).

> > For me as end-user this is very-very strange and I consider it as
> > 'gotcha' of PosgreSQL.
>
> Well, I would hardly call the latter a gotcha, given you're probably
> the first person to notice it. As for the first question, I'm not sure
> what you expect. SERIAL has always just been a sort of macro, so I
> don't see how this could be changed.

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.

>
> Have a nice day,
> --
> 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.
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
>
> iD8DBQFD6IsBIB7bNG8LQkwRAi2bAJ9H4Sl3u2YF9rt7mzyeu7Ixk1RCawCfddBN
> S7SicAM05rTpTipucoEN/yw=
> =ygVy
> -----END PGP SIGNATURE-----
>
>
>

--
Best regards,
Nikolay

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Robert Treat 2006-02-07 13:03:20 Re: Compile of Pgmail function fails
Previous Message Martijn van Oosterhout 2006-02-07 11:56:49 Re: Sequences/defaults and pg_dump

Browse pgsql-hackers by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-02-07 13:12:45 Re: Sequences/defaults and pg_dump
Previous Message Martijn van Oosterhout 2006-02-07 11:56:49 Re: Sequences/defaults and pg_dump