Thread: pretty print viewdefs

pretty print viewdefs

From
Andrew Dunstan
Date:
The tiny patch attached fixes a long-standing peeve of mine (and at
least one of my clients'), namely that the target list printed in
viewdefs are unreadable.

example output now looks like this:

    regression=# select pg_get_viewdef('shoe',true);
                    pg_get_viewdef
    -----------------------------------------------
      SELECT
         sh.shoename,
         sh.sh_avail,
         sh.slcolor,
         sh.slminlen,
         sh.slminlen * un.un_fact AS slminlen_cm,
         sh.slmaxlen,
         sh.slmaxlen * un.un_fact AS slmaxlen_cm,
         sh.slunit
        FROM shoe_data sh, unit un
       WHERE sh.slunit = un.un_name;


Is there any objection?

cheers

andrew
Index: src/backend/utils/adt/ruleutils.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v
retrieving revision 1.306
diff -c -r1.306 ruleutils.c
*** src/backend/utils/adt/ruleutils.c    1 Aug 2009 19:59:41 -0000    1.306
--- src/backend/utils/adt/ruleutils.c    26 Aug 2009 12:51:23 -0000
***************
*** 2665,2670 ****
--- 2665,2672 ----

          appendStringInfoString(buf, sep);
          sep = ", ";
+         appendContextKeyword(context, "", -PRETTYINDENT_STD,
+                              PRETTYINDENT_STD, PRETTYINDENT_VAR);
          colno++;

          /*