Problems with renaming a column - Mailing list pgsql-hackers

From Rod Taylor
Subject Problems with renaming a column
Date
Msg-id 1054572874.79386.13.camel@jester
Whole thread Raw
Responses Re: Problems with renaming a column  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
As you can see below, after a rename the check constraint still refers
to 'col' and not 'newname' as pg_constraint.consrc is not updated.

Of course, this functions fine (conbin is still valid) but when it comes
time to do a pg_dump, the database is dumped using the old column name.

It seems this is a problem in 7.3 as well.  I believe the solution is to
outright remove consrc, and enable the interface to request a text
version of conbin on the fly.


test=# CREATE TABLE test (col integer check(col > 2));
CREATE TABLE
test=#
test=# ALTER TABLE test RENAME COLUMN col TO newname;
ALTER TABLE
test=#
test=# \d test     Table "public.test"Column  |  Type   | Modifiers
---------+---------+-----------newname | integer |
Check Constraints:   "test_col" CHECK (col > 2)

--
Rod Taylor <rbt@rbt.ca>

PGP Key: http://www.rbt.ca/rbtpub.asc

pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Linux startup script
Next
From: Josh Berkus
Date:
Subject: Proposal for Re-ordering CONF (was: Re: GUC and postgresql.conf docs)