Possible Documentation Update for ALTER STATISTICS

Started by Ahmet Gedemenliabout 5 years ago2 messageshackers
Jump to latest
#1Ahmet Gedemenli
agedemenli@microsoft.com

Hey,

I've noticed that the current documentation doesn't mention IF EXISTS clause for ALTER STATISTICS in the synopsis section, where PG supports it.
https://www.postgresql.org/docs/14/sql-alterstatistics.html
(Only for the last item, that is ALTER STATISTICS .. SET STATISTICS; for the others, PG just throws a syntax error.)

I'm from the Citus team and noticed this while bug fixing, and I wonder if it is intentional or not. If it's intentionally supported while the other ALTER STATISTICS statement types are not supported, it would be good to mention that in the documentation.

Best,
Ahmet

#2Tomas Vondra
tomas.vondra@enterprisedb.com
In reply to: Ahmet Gedemenli (#1)
Re: Possible Documentation Update for ALTER STATISTICS

Hi Ahmet,

On 11/4/21 14:35, Ahmet Gedemenli wrote:

Hey,

I've noticed that the current documentation doesn't mention IF EXISTS
clause for ALTER STATISTICS in the synopsis section, where PG supports it.
https://www.postgresql.org/docs/14/sql-alterstatistics.html
<https://www.postgresql.org/docs/14/sql-alterstatistics.html>
(Only for the last item, that is ALTER STATISTICS .. SET STATISTICS; for
the others, PG just throws a syntax error.)

I'm from the Citus team and noticed this while bug fixing, and I wonder
if it is intentional or not. If it's intentionally supported while the
other ALTER STATISTICS statement types are not supported, it would be
good to mention that in the documentation.

Well, it's intentional in the sense that support for IF EXISTS in ALTER
commands is rather spotty. For OWNER TO it's not supported at all, and
for the other (RENAME & SET SCHEMA) it's supported only for some object
types. So we added the minimum grammar and never got around to add it.

So you're right we should update the docs for the SET STATISTICS case to
show it's supported in 14. I'll do that shortly.

For 15+ we could improve this to allow IF EXISTS in the other cases. For
RENAME and SET SCHEMA it's fairly easy (see attached fix), for OWNER TO
it's going to be more work because the AlterOwnerStmt does not have the
missing_ok flag.

regards

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

Attachments:

t45060_2
alter-statistics-fix.patchtext/x-patch; charset=UTF-8; name=alter-statistics-fix.patchDownload+106-2