Re: idea: storing view source in system catalogs

From: Florian Pflug <fgp(dot)phlo(dot)org(at)gmail(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: Merlin Moncure <mmoncure(at)gmail(dot)com>, PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: idea: storing view source in system catalogs
Date: 2008-05-20 23:17:51
Message-ID: 48335C1F.5060807@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

David Fetter wrote:
> On Tue, May 20, 2008 at 02:03:17PM -0400, Merlin Moncure wrote:
>> I wonder if there is any merit to the idea of storing the 'create
>> view' statement that created the view in an appropriate place.
>> There are basically two reasons for this:
>
> +1 for DDL in general, including the original CREATE and appending all
> subsequent ALTERs. DROP would have to make the thing go away. I
> suppose CREATE OR REPLACE would also wipe the earlier versions, but
> I'm not married to to that idea.

The 1000$ question is how to deal with renames, though. Not of view
itself, but of the tables it depends on. Currently, the view tracks
those renames (which is an important feature, IMHO), and you get the
correct (using the new names) SQL when dumping the view. Anything that
stores the original statement, but fails to track renames is more
confusing that what it's worth, I think...

But maybe you could store the whitespace appearing before (or after?) a
token in the parse tree that is stored for a view. That might not allow
reconstructing the *precise* statement, but at least the reconstructed
statement would preserve newlines and indention - which probably is the
whole reason for wanting to store the original statement in the first
place, no? I have no idea how hard I'd be to carry that information from
the lexer into the parser, and then into whatever representation we use
for storing a view, though...

regards, Florian Pflug

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Denne 2008-05-21 03:44:49 Re: triggers on prepare, commit, rollback... ?
Previous Message Tom Lane 2008-05-20 22:58:45 Re: idea: storing view source in system catalogs