Re: Make name optional in CREATE STATISTICS - Mailing list pgsql-hackers

From Matthias van de Meent
Subject Re: Make name optional in CREATE STATISTICS
Date
Msg-id CAEze2WjCAo3s1TLWLNLr+rgGQri3+1=p+wtOEWquLzc2PGWHAg@mail.gmail.com
Whole thread Raw
In response to Make name optional in CREATE STATISTICS  (Simon Riggs <simon.riggs@enterprisedb.com>)
Responses Re: Make name optional in CREATE STATISTICS
List pgsql-hackers
On Sun, 15 May 2022 at 14:20, Simon Riggs <simon.riggs@enterprisedb.com> wrote:
>
> Currently, CREATE STATS requires you to think of a name for each stats
> object, which is fairly painful, so users would prefer an
> automatically assigned name.
>
> Attached patch allows this, which turns out to be very simple, since a
> name assignment function already exists.
>
> The generated name is simple, but that's exactly what users do anyway,
> so it is not too bad.

Cool.

> Tests, docs included.

Something I noticed is that this grammar change is quite different
from how create index specifies its optional name. Because we already
have a seperate statement sections for with and without IF NOT EXISTS,
adding another branch will add even more duplication. Using a new
opt_name production (potentially renamed from opt_index_name?) would
probably reduce the amount of duplication in the grammar.

We might be able to use opt_if_not_exists to fully remove the
duplicated grammars, but I don't think we would be able to keep the
"CREATE STATISTICS IF NOT EXISTS <<no name>> ON col1, col2 FROM table"
syntax illegal.

Please also update the comment in gram.y above the updated section
that details the expected grammar for CREATE STATISTICS, as you seem
to have overlooked that copy of grammar documentation.

Apart from these two small issues, this passes tests and seems complete.


Kind regards,

Matthias van de Meent



pgsql-hackers by date:

Previous
From: Jacob Champion
Date:
Subject: Re: Make mesage at end-of-recovery less scary.
Next
From: Alexander Korotkov
Date:
Subject: Re: Add red-black tree missing comparison searches