Re: Alter column to type serial

From: Thom Brown <thom(at)linux(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Alter column to type serial
Date: 2010-11-04 14:12:23
Message-ID: AANLkTim2ysWsQtB6UO2Gkoveew1SA4fi7fZnBR9wVB1+@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 4 November 2010 14:04, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> Thom Brown <thom(at)linux(dot)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.
>
>
I suspected this may have been discussed previously, I just failed to find
it. And yes, it's purely for simplification, and to auto-clean sequences
when tables are dropped. I didn't think it would be straightforward, but
clearly there are show-stoppers abound.

Thanks for the reply though. :)

--
Thom Brown
Twitter: @darkixion
IRC (freenode): dark_ixion
Registered Linux user: #516935

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2010-11-04 14:27:45 Re: ALTER OBJECT any_name SET SCHEMA name
Previous Message Dimitri Fontaine 2010-11-04 14:06:48 Re: ALTER OBJECT any_name SET SCHEMA name