From: | Kevin Field <kevinjamesfield(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: pg_views definition format |
Date: | 2009-05-14 18:22:18 |
Message-ID: | 3cbefb0e-a614-4f5d-b335-8098c513be64@m24g2000vbp.googlegroups.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On May 13, 5:37 pm, gsm(dot)(dot)(dot)(at)gregsmith(dot)com (Greg Smith) wrote:
> On Wed, 13 May 2009, Kevin Field wrote:
> > Or would the only way to do this be to actually create a view and then
> > call pg_get_viewdef() and then delete the view?
>
> Just make it a temporary view and then it drops when the session ends.
> Here's a working shell example that transforms a view into the parsed form
> and returns it:
>
> $ v="select * from pg_views"
> $ p=`psql -Atc "create temporary view x as ${v}; select pg_get_viewdef('x'::regclass);"`
> $ echo $p
> SELECT pg_views.schemaname, pg_views.viewname, pg_views.viewowner, pg_views.definition FROM pg_views;
Thanks. This works more quickly than I thought it might, which is
good.
Something I ran into though when trying to extend this logic to rules:
for some reason rule definitions are compiled with "create rule x as "
in front of them, unlike views, which just have everything after the
"as". I can keep the two parts separate and test accordingly, but it
seems a bit inconsistent.
From | Date | Subject | |
---|---|---|---|
Next Message | Kevin Field | 2009-05-14 18:35:30 | Re: pg_rules definition format |
Previous Message | Robert Haas | 2009-05-14 18:06:40 | Re: Optimizing Read-Only Scalability |