ALTER TABLE table RENAME COLUMN x TO y

From: "Donald Fraser" <demolish(at)cwgsy(dot)net>
To: "[BUGS]" <pgsql-bugs(at)postgresql(dot)org>
Subject: ALTER TABLE table RENAME COLUMN x TO y
Date: 2003-08-11 13:08:22
Message-ID: 004a01c36009$a79a1110$1664a8c0@DEMOLITION
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

PostgreSQL version 7.3.3, GCC 2.96, Redhat 7.2

When issuing the following type of command:
ALTER TABLE table RENAME COLUMN x TO y
The column name change is not cascading through to RULEs on a VIEW.

For example I had a column named "id_security" in TABLE "tbl_valrule" and I had
a RULE on a view that stated:
CREATE RULE rul_i03 AS ON INSERT TO vu_tbl_valrule DO INSTEAD INSERT INTO
tbl_valrule (id_security, id_valmonthend, n_lagdays ) VALUES (new.id_security,
new.id_valmonthend, new.n_lagdays );

After issuing the following command:
ALTER TABLE tbl_valrule RENAME COLUMN id_security TO id_seclass;
The Rule stated above never changed.
I noted that the underlying SELECT rule (rule name _RETURN) for the view
changed by replacing the column named "id_security" to "id_seclass AS
id_security".

Regards
Donald Fraser

Ps. The way I checked that the Rule had changed was by issuing the following
command.
SELECT r.rulename, pg_get_ruledef(r.oid) AS definition FROM pg_class AS c,
pg_rewrite AS r WHERE r.ev_class = c.oid AND c.relname = 'vu_tbl_valrule' ORDER
BY r.rulename

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2003-08-11 14:52:59 Re: Correct Unicode sorting depends on how initdb was run
Previous Message Peter Eisentraut 2003-08-11 11:48:11 Re: Correct Unicode sorting depends on how initdb was run

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Page 2003-08-11 13:20:27 Re: Farewell
Previous Message The Hermit Hacker 2003-08-11 13:03:12 Re: Farewell