Re: Make name optional in CREATE STATISTICS
Matthias van de Meent <boekewurm+postgres@gmail.com>
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
To: Simon Riggs <simon.riggs@enterprisedb.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2022-07-06T18:35:17Z
Lists: 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
Commits
-
Fix a few issues with REINDEX grammar
- 0a5f06b84de7 16.0 landed
-
Rework grammar for REINDEX
- 83011ce7d7f4 16.0 landed
-
parser: centralize common auxiliary productions
- 7d158e8cb44b 16.0 landed
-
Make the name optional in CREATE STATISTICS.
- 624aa2a13bd0 16.0 landed