Disallow extended statistics on system columns
authorTomas Vondra <tomas.vondra@postgresql.org>
Sun, 19 Sep 2021 22:34:57 +0000 (00:34 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Sun, 19 Sep 2021 22:34:57 +0000 (00:34 +0200)
commitc9eeef2a15c02ff7dd2bf3251dbee925b050fc0f
tree52e6559cacf62a8e13636f67d3bb16199d453872
parentd5eeb51bc053d75f647136026de522d6ee3bf725
Disallow extended statistics on system columns

Since introduction of extended statistics, we've disallowed references
to system columns. So for example

    CREATE STATISTICS s ON ctid FROM t;

would fail. But with extended statistics on expressions, it was possible
to work around this limitation quite easily

    CREATE STATISTICS s ON (ctid::text) FROM t;

This is an oversight in a4d75c86bf, fixed by adding a simple check.
Backpatch to PostgreSQL 14, where support for extended statistics on
expressions was introduced.

Backpatch-through: 14
Discussion: https://postgr.es/m/20210816013255.GS10479%40telsasoft.com
src/backend/commands/statscmds.c