On 12/24/2011 02:26 PM, Greg Stark wrote:
On Thu, Dec 22, 2011 at 5:52 PM, Andrew Dunstan<and...@dunslane.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



--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to