Re: WIP: pg_pretty_query - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: WIP: pg_pretty_query
Date
Msg-id 502165F8.6000403@dunslane.net
Whole thread Raw
In response to Re: WIP: pg_pretty_query  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: WIP: pg_pretty_query
Re: WIP: pg_pretty_query
List pgsql-hackers
On 08/07/2012 02:14 PM, Tom Lane wrote:

> * As per some of the complaints already registered in this thread,
> ruleutils.c is not designed with the goal of being a pretty-printer.
> Its primary charter is to support pg_dump by regurgitating rules/views
> in an unambiguous form, which does not necessarily look very similar to
> what was entered.  An example of a transformation that probably nobody
> would want in a typical pretty-printing context is expansion of
> "SELECT *" lists.  But again, there is really no way to turn that off.
> Another aspect that seems pretty undesirable for pretty-printing is
> loss of any comments embedded in the query text.
>
> I'm very much not in favor of trying to make ruleutils serve two
> masters, but that's the game we will be playing if we accept this patch.

I think this horse has probably bolted. If you wanted to segregate off 
this functionality we shouldn't have used things like pg_get_viewdef in 
psql, ISTM.


>
> In short, the only redeeming value of this patch is that it's short.
> The functionality it provides is not something that anyone would come
> up with in a green-field design for a pretty-printer, and if we take
> it we are going to be faced with a whole lot of redesign requests that
> will be painful to implement and will carry heavy risks of breaking
> pg_dump and/or EXPLAIN.
>
>             

One of the challenges is to have a pretty printer that is kept in sync 
with the dialect that's supported. Anything that doesn't use the 
backend's parser seems to me to be guaranteed to get out of sync very 
quickly.

cheers

andrew



pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: bug of pg_trgm?
Next
From: Tom Lane
Date:
Subject: Re: WIP: pg_pretty_query