Skip site navigation (1) Skip section navigation (2)

Re: ALTER TABLE ... TO ... to change related names

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org,Jonathan Gardner <jgardner(at)jonathangardner(dot)net>
Subject: Re: ALTER TABLE ... TO ... to change related names
Date: 2003-08-30 16:38:06
Message-ID: 3889.1062261486@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> There is no guarantee that a given sequence is used only for one column 
> in one table, as I understand it. So renaming it could screw you up badly.

Yeah, I would recommend having a discussion about the details of the
proposed behavior before you start coding, not after.

It'd probably be reasonable to rename only those sequences that are
connected to the target table/column by internal dependencies --- this
indicates that they were created by a SERIAL column definition and not
by manual operations.  IIRC, pg_dump already uses this same cue to
decide whether to dump the sequence definition separately or say SERIAL.

It'd still be possible for someone's schema to break, if they made a
sequence via SERIAL and then referred to it by name in defaults for
other columns.  But I think we could say they were being unreasonably
intimate with implementation details in that case.

Similar rules need to be agreed to about when to rename indexes.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Dennis BjörklundDate: 2003-08-30 16:52:41
Subject: Re: ALTER TABLE ... TO ... to change related names
Previous:From: Bruce MomjianDate: 2003-08-30 16:33:42
Subject: Re: FE/BE Protocol - Specific version

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group