Thread: how to view original source of rules?

how to view original source of rules?

From
Ed L.
Date:
I know about this query...

  SELECT * FROM pg_rewrite where r.rulename = 'myrule';

...but the output is none too friendly to look at.

Anyone know how one can see something closer to the original input
source of a rule via psql?

Re: how to view original source of rules?

From
Alvaro Herrera
Date:
On Tue, Nov 26, 2002 at 02:08:52PM -0700, Ed L. wrote:
>
> I know about this query...
>
>   SELECT * FROM pg_rewrite where r.rulename = 'myrule';
>
> ...but the output is none too friendly to look at.
>
> Anyone know how one can see something closer to the original input
> source of a rule via psql?

Did you look at the pg_rules view?  Also look at its definition (\d
pg_rules), it uses a function for converting the parsetree of the rule
into a human readable version, pg_get_ruledef(text).  You can probably
use the same function for your own purposes.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Y dijo Dios: "Que sea Satanás, para que la gente no me culpe de todo a mí."
"Y que hayan abogados, para que la gente no culpe de todo a Satanás"