ERROR: cannot change name of view column

From: Réal A(dot) Carbonneau <contact(at)realcarbonneau(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: ERROR: cannot change name of view column
Date: 2019-01-01 16:21:08
Message-ID: CAJ-S0v57o6Ltgij0zBRnHLK2ustVsM7XinJJF8geJpamq-ortA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Changing the name of any column in a view gives the error "ERROR: cannot
change name of view column".

The documentation is clear: "The new query must generate the same columns
that were generated by the existing view query (that is, the same column
names in the same order and with the same data types)"
Reference 1: https://www.postgresql.org/docs/9.3/sql-createview.html
Reference 2:
https://dba.stackexchange.com/questions/586/cant-rename-columns-in-postgresql-views-with-create-or-replace

However, ALTER TABLE ... RENAME COLUMN will change the view column name
(see Reference 2 above).

Thus, the original error message is not completely correct. Ideally,
the CREATE OR REPLACE VIEW would automatically apply the ALTER TABLE ...
RENAME COLUMN (or underlying procedure) since it is available and fulfills
the original DDL request, thus making the error message unnecessary.

Or at the very least, the error message could be changed to suggest using
the ALTER TABLE ... RENAME COLUMN until the feature is included in the
CREATE OR REPLACE VIEW.

PostgreSQL version 11.1

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2019-01-01 18:18:29 Re: ERROR: cannot change name of view column
Previous Message Phil Hildebrand 2019-01-01 08:13:05 Re: BUG #15570: Vacuum analyze ERROR: MultiXactId XXXX has not been created yet -- apparent wraparound