Re: idea: storing view source in system catalogs - Mailing list pgsql-hackers

From Hannu Krosing
Subject Re: idea: storing view source in system catalogs
Date
Msg-id 1211370991.7045.4.camel@huvostro
Whole thread Raw
In response to Re: idea: storing view source in system catalogs  (Andreas Pflug <pgadmin@pse-consulting.de>)
Responses Re: idea: storing view source in system catalogs
List pgsql-hackers
On Wed, 2008-05-21 at 10:40 +0200, Andreas Pflug wrote:
> Florian Pflug wrote:
> >
> > 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
> 
> 
> Not the whole reason. To get a view definition that is more readable, 
> the pretty_bool option of pg_get_viewdef already does some newline and 
> indent formatting. Not the initial formatting, but Good Enough (TM), I 
> believe.
> 
> What's really lost is any comment that might have existed in the initial 
> source. I previously had the idea to invent comment nodes, but never 
> came to implement them.

Is'nt a view roughly equivalent to a SQL language FUNCTION with no
arguments and a single select.

If it is so, then I can't see, why we can store the source for functions
but not for VIEWs

like this - 

hannu=# create function viewfunc(out pg_proc) language sql as $$ select
* from pg_proc where proname = 'viewfunc' $$; 
CREATE FUNCTION
hannu=# \x
Expanded display is on.
hannu=# select * from viewfunc();
-[ RECORD 1 ]--+---------------------------------------------------
proname        | viewfunc
pronamespace   | 2200
proowner       | 10
prolang        | 14
procost        | 100
prorows        | 0
proisagg       | f
prosecdef      | f
proisstrict    | f
proretset      | f
provolatile    | v
pronargs       | 0
prorettype     | 81
proargtypes    | 
proallargtypes | {81}
proargmodes    | {o}
proargnames    | 
prosrc         |  select * from pg_proc where proname = 'viewfunc' 
probin         | -
proconfig      | 
proacl         | 

---------------
Hannu




pgsql-hackers by date:

Previous
From: "Merlin Moncure"
Date:
Subject: Re: idea: storing view source in system catalogs
Next
From: "Heikki Linnakangas"
Date:
Subject: Re: plpgsql: penalty due to double evaluation of parameters