Re: patch: Add columns via CREATE OR REPLACE VIEW - Mailing list pgsql-hackers

From Tom Lane
Subject Re: patch: Add columns via CREATE OR REPLACE VIEW
Date
Msg-id 10395.1218123833@sss.pgh.pa.us
Whole thread Raw
In response to Re: patch: Add columns via CREATE OR REPLACE VIEW  (Alvaro Herrera <alvherre@commandprompt.com>)
Responses Re: patch: Add columns via CREATE OR REPLACE VIEW  (Alvaro Herrera <alvherre@commandprompt.com>)
Re: patch: Add columns via CREATE OR REPLACE VIEW  ("David E. Wheeler" <david@kineticode.com>)
Re: patch: Add columns via CREATE OR REPLACE VIEW  ("Robert Haas" <robertmhaas@gmail.com>)
Re: patch: Add columns via CREATE OR REPLACE VIEW  (Andrew Dunstan <andrew@dunslane.net>)
Re: patch: Add columns via CREATE OR REPLACE VIEW  ("Pavel Stehule" <pavel.stehule@gmail.com>)
List pgsql-hackers
Alvaro Herrera <alvherre@commandprompt.com> writes:
> Robert Haas escribi�:
>> Here's a patch that allows CREATE OR REPLACE VIEW to add new columns
>> to an existing view.

> What happens with the columns previously defined?  What happens if I
> specify a different column definition for them; does it raise an error?

The original idea here was to give REPLACE VIEW as much flexibility
as we've recently added for tables via ALTER TABLE, which would ideally
include

1. adding columns
2. renaming columns
3. dropping columns that are not referenced elsewhere
4. changing type of columns that are not referenced elsewhere

But it seems hard to tell the difference between a "rename" and a
"drop".  I think that we aren't going to get far on this until we
decide what we will consider to be the identity of a view column.
With regular tables the attnum is a persistent identifier, but that
doesn't seem to play nicely for REPLACE VIEW, at least not if you're
wanting to allow people to remove columns from their view definitions.

Maybe the right way is to *not* use CREATE OR REPLACE VIEW, but
rather ALTER VIEW ADD COLUMN and so on.  Then column identity seems
a lot easier to keep track of.

Thoughts?
        regards, tom lane


pgsql-hackers by date:

Previous
From: "Robert Haas"
Date:
Subject: Re: patch: Add columns via CREATE OR REPLACE VIEW
Next
From: Stephen Frost
Date:
Subject: Re: Parsing of pg_hba.conf and authentication inconsistencies