modifying views - Mailing list pgsql-general

From Sim Zacks
Subject modifying views
Date
Msg-id ctq5tc$g0u$1@news.hub.org
Whole thread Raw
Responses Re: modifying views
List pgsql-general
I read the following thread from Nov 2002 on the impossibilities of
modifying a view and I was wondering if anything had changed in this regard
since then?
http://archives.postgresql.org/pgsql-hackers/2002-11/msg00609.php

Basically I want to remove a column from a table. The column is used in a
view. The view, but not the column that I want to remove, is used in 24
other views. A number of those views are also used in other views...

I can't remove the columns from the view without dropping over 100 other
views, removing the columns from this view and recreating them. I was able
to remove the columns from the table by modifying the view so instead of
"table1.field1" it has "null::varchar as field1"
The problem is that the field is still in the view and I don't want it there
(obviously).

I read somewhere that a possible solution would be to do a pg_dump, manually
change the text file and then do a pg_restore. Unfortunately, that means
taking the system offline, which I can't do.

Even adding a column to a view isn't allowed. So if I want a new field in my
table to be accessible in the same manner that the view would be accessible
in, I would have to go through the same process of dropping 100 views,
making my change and then recreating 100 views. Talk about inefficient.

Are there any realistic methods for changing the number of columns in a
view? Is it possible to manually modify the backend? I looked at the
pg_views view SQL and it seemed to work completely internally.
the definition is called by this function "pg_get_viewdef(c.oid) AS
definition"
and the pg_get_viewdef(oid) function  just calls 'pg_get_viewdef' with a
language Internal (as shown below)

CREATE OR REPLACE FUNCTION pg_get_viewdef(oid)
  RETURNS text AS
'pg_get_viewdef'
  LANGUAGE 'internal' STABLE STRICT;
GRANT EXECUTE ON FUNCTION pg_get_viewdef(oid) TO public;
COMMENT ON FUNCTION pg_get_viewdef(oid) IS 'select statement of a view';

I could use any help that you can give me.
Thanks
Sim



pgsql-general by date:

Previous
From: "Andreas Duffner"
Date:
Subject: Re: NewsServer down ? (PostgreSql.org: trusted sender for your account)
Next
From: "Julian Scarfe"
Date:
Subject: Re: pgpool 2.5b2 released