Re: pg_views definition format

From: Greg Smith <gsmith(at)gregsmith(dot)com>
To: Kevin Field <kevinjamesfield(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_views definition format
Date: 2009-05-13 21:37:47
Message-ID: alpine.GSO.2.01.0905131726550.24125@westnet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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;

--
* Greg Smith gsmith(at)gregsmith(dot)com http://www.gregsmith.com Baltimore, MD

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Euler Taveira de Oliveira 2009-05-13 21:45:38 Re: Problem with estimating pages for a table
Previous Message Simon Riggs 2009-05-13 21:04:06 Re: New trigger option of pg_standby