Re: Apparent anomaly with views and unions

From: Greg Stark <gsstark(at)mit(dot)edu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Apparent anomaly with views and unions
Date: 2005-02-13 05:55:28
Message-ID: 877jld6m27.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> In the cases I'm concerned about, DROP VIEW would fail unless you used
> CASCADE, and the subsequent CREATE VIEW would not magically bring back
> the dependent objects the CASCADE had killed. The entire *point* of
> REPLACE VIEW is that it does not have the side effect of destroying
> dependent objects; and therefore it has to act in a way that ensures
> the dependent objects still make sense. So, for the moment anyway,
> that means disallowing changes in the output column names and datatypes.

There have been a few times when people were confused by the way views adapted
to changes in their base tables. A typical example is when someone wants to
rename a column and then add a new column with the old name. They usually
expect the view to refer to the new column and not automagically change
definition to refer to the renamed column.

Based on the user reactions, it seems like the least-surprise behaviour would
actually be the naive implementation of keeping the raw text defining the view
and when anything changes in the base tables (or views) reinterpreting the
view based on the new context.

That would make both the ALTER TABLE and CREATE OR REPLACE VIEW behaviour
simple to implement. If you rename a column then any query using the view gets
an error until you put back a column with the name used.

It seems like this would be a huge behaviour change though. I don't suppose
the spec says anything about how views are supposed to respond to changes in
base context does it?

--
greg

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message ttina 2005-02-13 06:20:43 problem with thai language
Previous Message Russell Smith 2005-02-13 05:36:41 Re: [GENERAL] Website Documentation