Re: reprise: pretty print viewdefs

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Greg Stark <stark(at)mit(dot)edu>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: reprise: pretty print viewdefs
Date: 2011-12-25 16:22:13
Message-ID: 4EF74DB5.8090403@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/24/2011 02:26 PM, Greg Stark wrote:
> On Thu, Dec 22, 2011 at 5:52 PM, Andrew Dunstan<andrew(at)dunslane(dot)net> wrote:
>> I've looked at that, and it was discussed a bit previously. It's more
>> complex because it requires that we keep track of (or calculate) where we
>> are on the line,
> You might try a compromise, just spit out all the columns on one line
> *unless* either the previous or next column is longer than something
> like 30 columns. So if you have a long list of short columns it just
> gets wrapped by your terminal but if you have complex expressions like
> CASE expressions or casts or so on they go on a line by themselves.

I think that sounds too complex, honestly. Here's what I have working:

/*
* If the field we're adding already has a leading newline
* or wrap mode is disabled (pretty_wrap < 0), don't add one.
* Otherwise, add one, plus some indentation,
* if either the new field would cause an
* overflow or the last field had a multiline spec.
*/

Here's an illustration:
<http://developer.postgresql.org/~adunstan/pg_get_viewdef.png>

cheers

andrew

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2011-12-25 19:37:45 Re: 16-bit page checksums for 9.2
Previous Message Martijn van Oosterhout 2011-12-25 15:25:19 Re: 16-bit page checksums for 9.2