Re: renaming table leaves constraint behind [7.3.2] - Mailing list pgsql-general

From Holger Klawitter
Subject Re: renaming table leaves constraint behind [7.3.2]
Date
Msg-id 200302110911.01513.lists@klawitter.de
Whole thread Raw
In response to Re: renaming table leaves constraint behind [7.3.2]  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Hi Tom,

thanks for your reply!

> Sure it did.  The error message seems to have changed a trifle, but
> you'd get a conflict on the index name in either case.

The error message is okay. In 7.2.x the constraint was DROP INDEXed, so it
didn't show up there.

> This isn't real desirable ... but having ALTER TABLE RENAME run around
> and rename associated indexes might create issues too ...

But in particular when names are automatically created one likes a way to
change the names of the constraints. I've found a workaround:

-- as postgres --
create view my_connames as select conname from pg_constraint;
create rule upd_connames as on update to my_connames do instead
  update pg_constraint
  set conname = new.conname where conname = old.conname;
grant select,update on my_connames to '<user>';

With kind regards / mit freundlichem Gruß
    Holger Klawitter
--
Holger Klawitter                          http://www.klawitter.de
lists@klawitter.de

pgsql-general by date:

Previous
From: "Ben-Nes Michael"
Date:
Subject: Re: PostgreSQL x Oracle
Next
From: jerome
Date:
Subject: URGENT: pg_dump error