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

From: Jonathan Gardner <jgardner(at)jonathangardner(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: ALTER TABLE ... TO ... to change related names
Date: 2003-08-30 17:30:28
Message-ID: 200308301030.29817.jgardner@jonathangardner.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

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(at)jonathangardner(dot)net
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Russell Garrett 2003-08-30 17:43:22 Re: Selecting random rows efficiently
Previous Message Joe Conway 2003-08-30 17:30:14 database corruption