Re: Sequences/defaults and pg_dump - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Sequences/defaults and pg_dump
Date
Msg-id 20060207115649.GB19240@svana.org
Whole thread Raw
In response to Sequences/defaults and pg_dump  (Nikolay Samokhvalov <samokhvalov@gmail.com>)
Responses Re: Sequences/defaults and pg_dump
List pgsql-general
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@svana.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.

Attachment

pgsql-general by date:

Previous
From: Nikolay Samokhvalov
Date:
Subject: Sequences/defaults and pg_dump
Next
From: Nikolay Samokhvalov
Date:
Subject: Re: Sequences/defaults and pg_dump