Re: PoC/WIP: Extended statistics on expressions - Mailing list pgsql-hackers

From Tomas Vondra
Subject Re: PoC/WIP: Extended statistics on expressions
Date
Msg-id 58cbfa74-9356-778b-3e10-94e3075c5807@enterprisedb.com
Whole thread Raw
In response to Re: PoC/WIP: Extended statistics on expressions  (Justin Pryzby <pryzby@telsasoft.com>)
List pgsql-hackers

On 8/16/21 3:31 AM, Justin Pryzby wrote:
> On 1/22/21 5:01 AM, Justin Pryzby wrote:
>>> In any case, why are there so many parentheses ?
> 
> On Fri, Jan 22, 2021 at 02:09:04PM +0100, Tomas Vondra wrote:
>> That's a bug in pg_get_statisticsobj_worker, probably. It shouldn't be
>> adding extra parentheses, on top of what deparse_expression_pretty does.
>> Will fix.
> 
> The extra parens are still here - is it intended ?
> 

Ah, thanks for reminding me! I was looking at this, and the problem is 
that pg_get_statisticsobj_worker only does this:

     prettyFlags = PRETTYFLAG_INDENT;

Changing that to

     prettyFlags = PRETTYFLAG_INDENT | PRETTYFLAG_PAREN;

fixes this (not sure we need the INDENT flag - probably not).

I'm a bit confused, though. My assumption was "PRETTYFLAG_PAREN = true" 
would force the deparsing itself to add the parens, if needed, but in 
reality it works the other way around.

I guess it's more complicated due to deparsing multi-level expressions, 
but unfortunately, there's no comment explaining what it does.

regards

-- 
Tomas Vondra
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Daniel Gustafsson
Date:
Subject: Re: Slightly improve initdb --sync-only option's help message
Next
From: Peter Eisentraut
Date:
Subject: Some RELKIND macro refactoring