Hi,

I notice that the pretty printing version of pg_get_ruledef inserts extra
newlines whereas all the others pretty functions (except view defs) do
not.  In fact, Andreas argued against a version of pg_get_triggerdef()
that added extra newlines.

eg, non-pretty:

test=# select pg_get_ruledef(oid) from pg_rewrite order by oid desc limit
8;;
                                                 pg_get_ruledef
-----------------------------------------------------------------------------------------------------------------
 CREATE RULE r5 AS ON INSERT TO v DO INSTEAD NOTHING;
 CREATE RULE r4 AS ON INSERT TO v DO INSTEAD NOTHING;
 CREATE RULE r3 AS ON INSERT TO v DO INSTEAD NOTHING;
 CREATE RULE r2 AS ON INSERT TO v DO INSTEAD NOTHING;
 CREATE RULE r1 AS ON INSERT TO v DO INSTEAD NOTHING;
 CREATE RULE "_RETURN" AS ON SELECT TO v DO INSTEAD SELECT 1;
 CREATE RULE asdfx AS ON INSERT TO test WHERE ((((1 = 1) OR (1 = 2)) OR (1
= 3)) OR (1 = 5)) DO INSTEAD NOTHING;
 CREATE RULE asdf AS ON INSERT TO test WHERE ((((1 = 1) OR (1 = 2)) OR (1
= 3)) OR (1 = 5)) DO INSTEAD NOTHING;
(8 rows)

eg, pretty:

test=# select pg_get_ruledef(oid, true) from pg_rewrite order by oid desc
limit 8;;
                                              pg_get_ruledef
----------------------------------------------------------------------------------------------------------
 CREATE RULE r5 AS
    ON INSERT TO v DO INSTEAD NOTHING;
 CREATE RULE r4 AS
    ON INSERT TO v DO INSTEAD NOTHING;
 CREATE RULE r3 AS
    ON INSERT TO v DO INSTEAD NOTHING;
 CREATE RULE r2 AS
    ON INSERT TO v DO INSTEAD NOTHING;
 CREATE RULE r1 AS
    ON INSERT TO v DO INSTEAD NOTHING;
 CREATE RULE "_RETURN" AS
    ON SELECT TO v DO INSTEAD  SELECT 1;
 CREATE RULE asdfx AS
    ON INSERT TO test
   WHERE 1 = 1 OR 1 = 2 OR 1 = 3 OR 1 = 5 DO INSTEAD NOTHING;
 CREATE RULE asdf AS
    ON INSERT TO test
   WHERE 1 = 1 OR 1 = 2 OR 1 = 3 OR 1 = 5 DO INSTEAD NOTHING;
(8 rows)


Are those newlines really necessary?  They seem a bit out of place?

Chris



Mon, 29 Sep 2003 12:35:02 +0800 (WST)
Christopher Kings-Lynne <chriskl@familyhealth.com.au>
pg_get_ruledef and extra line breaks
Christopher Kings-Lynne wrote:

>Hi,
>
>I notice that the pretty printing version of pg_get_ruledef inserts extra
>newlines whereas all the others pretty functions (except view defs) do
>not.  In fact, Andreas argued against a version of pg_get_triggerdef()
>that added extra newlines.
>
No, I did not *in general*, but for now because there's no node 
traversing and a pretty formatted query can be easily constructed by 
yourself as for all other non-pg_get_xxx supported objects.


>
> CREATE RULE asdfx AS
>    ON INSERT TO test
>   WHERE 1 = 1 OR 1 = 2 OR 1 = 3 OR 1 = 5 DO INSTEAD NOTHING;
> CREATE RULE asdf AS
>    ON INSERT TO test
>   WHERE 1 = 1 OR 1 = 2 OR 1 = 3 OR 1 = 5 DO INSTEAD NOTHING;
>(8 rows)
>
>
>Are those newlines really necessary?  They seem a bit out of place?
>
Matter of taste. Things look different if action is not NOTHING, but 
something more.

Regards,
Andreas



Mon, 29 Sep 2003 11:14:02 +0200
Andreas Pflug <pgadmin@pse-consulting.de>
Re: pg_get_ruledef and extra line breaks

> No, I did not *in general*, but for now because there's no node 
> traversing and a pretty formatted query can be easily constructed by 
> yourself as for all other non-pg_get_xxx supported objects.

The reason I bring it up is that if psql is changed to use the pretty 
printing option, then the rules take up several lines, instead of one 
(like the other objects)

Chris




Mon, 29 Sep 2003 17:23:34 +0800
Christopher Kings-Lynne <chriskl@familyhealth.com.au>
Re: pg_get_ruledef and extra line breaks
Christopher Kings-Lynne wrote:
> 
> > No, I did not *in general*, but for now because there's no node 
> > traversing and a pretty formatted query can be easily constructed by 
> > yourself as for all other non-pg_get_xxx supported objects.
> 
> The reason I bring it up is that if psql is changed to use the pretty 
> printing option, then the rules take up several lines, instead of one 
> (like the other objects)

Chris, can you show us what that would look like?  I can see a reason
for using multiple lines for rules, and single lines for everything
else.

-- 
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073

Mon, 29 Sep 2003 09:47:43 -0400 (EDT)
Bruce Momjian <pgman@candle.pha.pa.us>
Re: pg_get_ruledef and extra line breaks