how to view original source of rules?

Started by Ed L.over 23 years ago2 messagesgeneral
Jump to latest
#1Ed L.
pggeneral@bluepolka.net

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?

#2Alvaro Herrera
alvherre@dcc.uchile.cl
In reply to: Ed L. (#1)
Re: how to view original source of rules?

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"