Re: ALTER TABLE ... TO ... to change related names - Mailing list pgsql-hackers

From Jonathan Gardner
Subject Re: ALTER TABLE ... TO ... to change related names
Date
Msg-id 200308301030.29817.jgardner@jonathangardner.net
Whole thread Raw
In response to Re: ALTER TABLE ... TO ... to change related names  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Saturday 30 August 2003 09:38, Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.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.
>

Agreed. I definitely only want to manipulate the sequences created with
SERIAL.

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

The only indexes I see that are created during table construction are
PRIMARY KEY and UNIQUE indexes. I think these should be renamed as if they
were created for a table with the new name.

The whole intent is to make PostgreSQL easier to use for novices. When they
craete a table with SERIAL, PRIMARY KEY, UNIQUE, and then rename it, they
expect to be able to create another table with the old name and not have
those sequences and indexes collide. Experts can read the documentation and
see how the indexes and sequences are created and renamed.

- --
Jonathan Gardner
jgardner@jonathangardner.net
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/UN80WgwF3QvpWNwRAj1yAKDsEHdPNEIIZPMARVfgtvQ43TZeGACgzunp
ssH+tMKhGPby/vBREQJ2Rsw=
=eJwg
-----END PGP SIGNATURE-----



pgsql-hackers by date:

Previous
From: Jonathan Gardner
Date:
Subject: Re: ALTER TABLE ... TO ... to change related names
Next
From: Joe Conway
Date:
Subject: database corruption