Possible enhancement : replace view ?
Dear all,
The current implementation of views uses OIDs, not table/view names. As
a consequence, when you happen to replace (drop then create) an
underlying table or view, you also have to drop and recreate all views
using this table|view (and this recursively, of course ...).
I stumbled on this while doing repeat analyses (involving repeated uses
of aggregation) of the same dataset using slight variations of the
subset of interest. When my dataset was small, I used to do that in
(yuck !) MS-Access by creating a view defining the subset of interest,
then creating views based on this view, and so on... Now that my dataset
is too large to be Access-manageable, I migrated it to PostgreSQL
(which, BTW, gave me nice performance enhancements), but I had to change
my working habits. I have now to create a script defining my views,
then to run it at each and every variation of the subset of interest ...
To be able to conserve existing views would definitely be a bonus.
Of course, the overhead is necessary to handle the general case.
However, there is a special case where this is unnecessary : when the
new table or view "class" definition is a (possibly improper) subclass
of the original one, or, if you prefer, when the column set of the new
definition is a (possibly improper) superset of the old one.
For tables, this case is already handled by a judicious use of alter
table, at least in its present form (adding DROP COLUMN, which might be
an interesting feature for other reasons, entails the risk of
invalidating existing views ...). However, there is currently no easily
reachable way to do that for a view (I suppose that the special case of
modifying the definition of a view creating the same columns in the old
and new definitions might be possible with a "clever" (ab)use of system
catalogs, but I tend to be *very* wary of such hacks ...).
Of course, I am aware that view definitions aren't just stored, but that
a lot of rewriting is involved before storing the actual execution
plan. Modifying a view definition would entail re-processing of other
view definitions. But so is the case with the modification of a table ...
What do you think ?
--
Emmanuel Charpentier
Emmanuel Charpentier <charpent@bacbuc.dyndns.org> writes:
What do you think ?
I think Gavin Sherry is already working on this.
regards, tom lane
Tom,
I submitted a patch for this a few days ago. Did it not hit pgsql-patches?
Gavin
On Tue, 13 Aug 2002, Tom Lane wrote:
Show quoted text
Emmanuel Charpentier <charpent@bacbuc.dyndns.org> writes:
What do you think ?
I think Gavin Sherry is already working on this.
regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster
Gavin Sherry <swm@linuxworld.com.au> writes:
I submitted a patch for this a few days ago. Did it not hit pgsql-patches?
It did ... I had some gripes about it ... I thought you were working on
the gripes?
regards, tom lane
Ah, that's why it wasn't in my mailbox. Gavin,
Gavin Sherry <swm@linuxworld.com.au> writes:
It passes all regression tests. There's only one really sketchy part of
the patch: UpdateAttributeTuples(). This routine is fairly dangerous since
it simply removes a given relid's pg_attribute entries and creates a new
set basic on a given TupleDesc. Naturally, it is only useful for views.
You can NOT allow CREATE OR REPLACE VIEW to change the tupledesc of the
view, so I stopped reading right here --- take it out and install
prevention instead. Why do you think that REPLACE VIEW is interesting?
It's so you can modify a view without breaking things that depend on it
... and things that depend on it depend on the tupledesc. This is
exactly analogous to not allowing REPLACE FUNCTION to change the return
type of the function.
regards, tom lane
---------------------------------------------------------------------------
Tom Lane wrote:
Gavin Sherry <swm@linuxworld.com.au> writes:
I submitted a patch for this a few days ago. Did it not hit pgsql-patches?
It did ... I had some gripes about it ... I thought you were working on
the gripes?regards, tom lane
---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073