Skip site navigation (1) Skip section navigation (2)

Re: pretty print viewdefs

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Greg Stark <gsstark(at)mit(dot)edu>, decibel <decibel(at)decibel(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pretty print viewdefs
Date: 2009-08-27 14:26:07
Message-ID: 4A96977F.4010700@dunslane.net (view raw or flat)
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Greg Stark <gsstark(at)mit(dot)edu> writes:
>   
>> Incidentally I just tried
>> \d information_schema.views
>>     
>
>   
>> and it *does* seem to put newlines after some of the target list
>> items. After each of the CASE expressions it puts a newline. So you
>> *already* get a mixture of some multiple items on a line and some
>> one-per-line.
>>     
>
> Yeah, sufficiently complex expressions (sub-selects, for an obvious
> case) will get internal pretty-printing that might include newlines.
>   


OK, drawing this together, what I did was to go back closer to my 
original idea, but put this in a separate function, so nobody would get 
too upset ;-)

Here is what my function does, and also what the current "pretty 
printing" does:

    andrew=# select pg_get_viewdef_long('foo');
         pg_get_viewdef_long     
    ------------------------------
      SELECT 'a'::text AS b,
             ( SELECT 1
                FROM dual) AS x,
             random() AS y,
             CASE
                 WHEN true THEN 1
                 ELSE 0
             END AS c,
             1 AS d
        FROM dual;
    (1 row)

    andrew=# select pg_get_viewdef('foo',true);
                   pg_get_viewdef               
    ---------------------------------------------
      SELECT 'a'::text AS b, ( SELECT 1
                FROM dual) AS x, random() AS y,
             CASE
                 WHEN true THEN 1
                 ELSE 0
             END AS c, 1 AS d
        FROM dual;
    (1 row)


WIP Patch is attached. To complete it I would add a psql option to use 
it, but maybe we should have a psql setting to enable it ... building 
something extra into the \d* stuff looks a bit ugly, since we already 
have a million options.

cheers

andrew



Attachment: prettyprint.patch
Description: text/x-patch (5.7 KB)

In response to

Responses

pgsql-hackers by date

Next:From: Bernd HelmleDate: 2009-08-27 14:30:47
Subject: Re: Build system problem in 8.3.x
Previous:From: Alvaro HerreraDate: 2009-08-27 14:17:32
Subject: Re: Unicode UTF-8 table formatting for psql text output

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group