Re: reprise: pretty print viewdefs

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
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-22 23:14:46
Message-ID: 4EF3B9E6.5050308@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12/22/2011 06:11 PM, Andrew Dunstan wrote:
>
>
> On 12/22/2011 02:17 PM, Andrew Dunstan wrote:
>>
>>
>> On 12/22/2011 01:05 PM, Tom Lane wrote:
>>> Maybe, though I fear it might complicate the ruleutils code a bit.
>>> You'd probably have to build the output for a column first and then
>>> see how long it is before deciding whether to insert a newline.
>>>
>>> In short, I don't mind trying to make this work better, but I think it
>>> will take more work than a two-line patch.
>>>
>>>
>>
>> OK. Let me whip something up. I had already come to the conclusion
>> you did about how best to do this.
>>
>>
>
> Here's a WIP patch. At least it's fairly localized, but as expected
> it's rather more than 2 lines :-). Sample output:
>
> regression=# \pset format unaligned
> Output format is unaligned.
> regression=# select pg_get_viewdef('shoelace',true);
> pg_get_viewdef
> SELECT s.sl_name, s.sl_avail, s.sl_color, s.sl_len, s.sl_unit,
> s.sl_len * u.un_fact AS sl_len_cm
> FROM shoelace_data s, unit u
> WHERE s.sl_unit = u.un_name;
> (1 row)
> regression=#
>
>
> I just had an idea. We could invent a flavor of pg_get_viewdef() that
> took an int as the second param, that would be the wrap width. For the
> boolean case as above, 80 would be implied. 0 would mean always wrap.
> psql could be made to default to the window width, or maybe window
> width - 1, but we could provide a psql setting that would override it.
>
>

This time with patch.

cheers

andrew

Attachment Content-Type Size
viewdefs-wip.patch text/x-patch 3.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Phil Sorber 2011-12-23 00:01:21 Re: WIP patch: Improve relation size functions such as pg_relation_size() to avoid producing an error when called against a no longer visible relation
Previous Message Andrew Dunstan 2011-12-22 23:11:23 Re: reprise: pretty print viewdefs