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 11:56:49
Message-ID: 20060207115649.GB19240@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

On Tue, Feb 07, 2006 at 02:33:56PM +0300, Nikolay Samokhvalov wrote:
> Maybe it was discussed already, but I think it's very strange behavior
> and things should be changed (please correct me if I'm wrong)
>
> Suppose we have database containing only one simple table:

<snip>

> So, if we don't know the history we cannot understand that id is of
> type SERIAL. We think as it's INTEGER with DEFAULT
> 'nextval('test_id_seq'::regclass)' [as expression]
>
> This is the question #1 - how I can distinguish pure SERIAL and
> INTEGER with corresponding DEFAULT setting?

You can't because there is no difference. SERIAL is just a shortcut. If
there is no difference, why would you want to distinguish them?

> Then... Imagine that we should use sequence in some other manner. For example:
> ***
> ALTER TABLE test ALTER COLUMN id SET DEFAULT nextval('test_id_seq') * 10;

<snip>

> In dump file I see SERIAL as the type for test.id ...
> So, the question #2 (the main Q): why pg_dump didn't dump my expression?

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.

> 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.

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.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nikolay Samokhvalov 2006-02-07 12:28:31 Re: Sequences/defaults and pg_dump
Previous Message Nikolay Samokhvalov 2006-02-07 11:33:56 Sequences/defaults and pg_dump

Browse pgsql-hackers by date

  From Date Subject
Next Message Nikolay Samokhvalov 2006-02-07 12:28:31 Re: Sequences/defaults and pg_dump
Previous Message Pavel Stehule 2006-02-07 11:40:53 Re: Need Help In arrays