Re: Alter column to type serial - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Alter column to type serial
Date
Msg-id 4505.1288879499@sss.pgh.pa.us
Whole thread Raw
In response to Alter column to type serial  (Thom Brown <thom@linux.com>)
Responses Re: Alter column to type serial
List pgsql-hackers
Thom Brown <thom@linux.com> writes:
> Would it be possible (or reasonable) to add support for changing the type of
> a column to serial or bigserial (yes, yes, I know they're not actual
> types)?

We've looked at that in the past and decided there were enough corner
cases that it wasn't clearly a good idea.  In particular, what do you do
with the existing data in the column?  What do you do if there's already
a DEFAULT expression for the column, throw it away?  In particular, what
of the special case that the column is in fact already a serial, so the
default is pointing at an existing sequence?

It is possible to accomplish everything that such a command would do
manually, so the argument for having it boils down to wanting it to
be a bit easier.  But unless the command can always do the right thing
automatically, I'm not sure "easy" is a good argument.

There's also the objection that such an operation would actually have
very little to do with ALTER COLUMN TYPE --- most of the things it would
do are not that.  The fact that serial was bolted on as a fake type is a
wart that maybe we shouldn't extend in this particular fashion.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: contrib: auth_delay module
Next
From: Dimitri Fontaine
Date:
Subject: Re: ALTER OBJECT any_name SET SCHEMA name