pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@enterprisedb.com>
To: Justin Pryzby <pryzby@telsasoft.com>
Cc: Dean Rasheed <dean.a.rasheed@gmail.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: PoC/WIP: Extended statistics on expressions
Date: Mon, 16 Aug 2021 15:19:53 +0200
Message-ID: <58cbfa74-9356-778b-3e10-94e3075c5807@enterprisedb.com> (raw)
In-Reply-To: <20210816013101.GR10479@telsasoft.com>
References: <2f2a3b3b-93e4-723f-144e-bc21f10d6b61@enterprisedb.com>
	<20210118045331.GF8560@telsasoft.com>
	<CAEZATCVnQccV_Z7AuvbvquaOYxUj+cVFk48pPGASYHFjXWgW5g@mail.gmail.com>
	<3f20da4d-89dc-0912-98d2-b6f0ef06c87f@enterprisedb.com>
	<CAEZATCUuj5FPjtOU2=7Z2pTC8LEvrf79+Go7R8yQ+eE0ezfgfQ@mail.gmail.com>
	<f865af90-c19c-769e-8c65-19692e245479@enterprisedb.com>
	<20210122022958.GC27167@telsasoft.com>
	<acf27932-8159-8872-8fca-902c7a35b351@enterprisedb.com>
	<20210122040101.GF27167@telsasoft.com>
	<04b100f9-201b-0bc8-c613-0f918451b599@enterprisedb.com>
	<20210816013101.GR10479@telsasoft.com>



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





view thread (107+ messages)  latest in thread

Message-ID: <58cbfa74-9356-778b-3e10-94e3075c5807@enterprisedb.com>
Permalink:  ../58cbfa74-9356-778b-3e10-94e3075c5807@enterprisedb.com/
Also on:    postgresql.org/message-id/58cbfa74-9356-778b-3e10-94e3075c5807@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tomas.vondra@enterprisedb.com, pryzby@telsasoft.com, dean.a.rasheed@gmail.com
  Subject: Re: PoC/WIP: Extended statistics on expressions
  In-Reply-To: <58cbfa74-9356-778b-3e10-94e3075c5807@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox