Re: BUG #3597: CREATE OR REPLACE VIEW

From: Reece Hart <reece(at)harts(dot)net>
To: "Luiz K(dot) Matsumura" <luiz(at)planit(dot)com(dot)br>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #3597: CREATE OR REPLACE VIEW
Date: 2007-09-04 17:33:27
Message-ID: 1188927207.5144.26.camel@snafu.site
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Luiz K. Matsumura 2007-09-04 18:09:16 Re: BUG #3597: CREATE OR REPLACE VIEW
Previous Message Jukka Holappa 2007-09-04 17:02:30 Re: BUG #3595: Segmentation fault with a simple select query