Re: BUG #3597: CREATE OR REPLACE VIEW - Mailing list pgsql-bugs

From Reece Hart
Subject Re: BUG #3597: CREATE OR REPLACE VIEW
Date
Msg-id 1188927207.5144.26.camel@snafu.site
Whole thread Raw
In response to BUG #3597: CREATE OR REPLACE VIEW  ("Luiz K. Matsumura" <luiz@planit.com.br>)
List pgsql-bugs
On Tue, 2007-09-04 at 07:42 +0000, Luiz K. Matsumura wrote:

> When we do a command Create or Replace View that change columns of
> previous view we got a error.


Right. Many folks consider views to be a sort of API to the database.
Using views to provide an API substantially insulates client code from
implementation changes because the logic "behind" a view can change
without changing the interface. So, although the prohibition against
changing the column specification is occasionally irksome, I have grown
to appreciate the protection from wanton changes to the API that this
prohibition provides.

Here are two tricks that may help you (and which you may already know):

1) Views can be renamed. When you do this, nearly all intra-cluster
references to it are updated. So, if your view is /solely/ for use
within the database, this allows you to deprecate a view.

2) Views can depend on views. So, consider your view1 as version1, then
create view2 which depends on view1 and merely recasts the type1 column
as character(3). New code can use view2 and old code can be migrated to
view2 as needed.

-Reece

--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #3599: Wrong search_path inside a function
Next
From: "Luiz K. Matsumura"
Date:
Subject: Re: BUG #3597: CREATE OR REPLACE VIEW