Re: Temporary Views

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Gavin Sherry <swm(at)linuxworld(dot)com(dot)au>, Hannu Krosing <hannu(at)tm(dot)ee>, Rod Taylor <rbt(at)zort(dot)ca>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Temporary Views
Date: 2002-08-14 04:38:29
Message-ID: 200208140438.g7E4cTa28378@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> > so, added to TODO:
> > * Have views on temporary tables exist in the temporary namespace
> > TODO updated to remove mention of temporary views.
>
> That's *clearly* backwards. Ignoring our little argument, I think there
> is no denying that temp views as such are useful --- for example,
> consider a temp view created on permanent tables to define a
> session-local shorthand for a complex query.

Oh, yes, good point.

> If you want a restriction, make it
> * Invent temporary views
> * Restrict permanent views from referring to temporary tables
> I agree with the first goal and disagree with the second --- but I can
> see your point of view on the second. OTOH I can't see any reason to
> hardwire tempness-of-views to tempness-of-referenced-tables, because
> that disallows the obviously useful case of temp view on permanent
> table.
>
> > I just removed them:
> > * Allow temporary views
> > * Require view using temporary tables to be temporary views
>
> It was right the first time.

Well, my real quandary is "what do we have now when we create a view
referencing a temporary table?" We have the session-drop of temporary
views, but not the visibility restrictions of temporary views, so I
can't put "Invent temporary views". In fact, given that indexes
auto-temp themselves, I think views should too, but fully, not just in
drop behavior.

Right now, I can do this in two sesssions at the same time:

test=> create temp table xxy(x int);
CREATE TABLE
test=> create index xxa on xxy(x);
CREATE INDEX

The temp-ness tracks to dependent objects, in visibility too.

In fact, we can't create a temporary index on a permanent table in our
current sources. It just auto-temps because it is on a temp table.
Views should do the same.

We can add the ability to do explicit temp views on permanent tables,
but no one has asked for that yet, as no one has asked for temp indexes;
temp indexes just happen on their own because it they use temp tables.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2002-08-14 04:38:55 Inheritance
Previous Message Christopher Kings-Lynne 2002-08-14 04:37:56 tsearch vs. fulltextindex