]> granicus.if.org Git - postgresql/commit
Rework the pg_statistic_ext catalog
authorTomas Vondra <tomas.vondra@postgresql.org>
Thu, 13 Jun 2019 15:19:21 +0000 (17:19 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Sat, 15 Jun 2019 23:20:31 +0000 (01:20 +0200)
commit6cbfb784c3c91146148a76d50cda6f69ae6a79fb
tree468bd8af4fe30903c7975df67f9f195e8ff5ba1d
parente3846a00c2f87402dcedf7f07950ab2d89cf5827
Rework the pg_statistic_ext catalog

Since extended statistic got introduced in PostgreSQL 10, there was a
single catalog pg_statistic_ext storing both the definitions and built
statistic.  That's however problematic when a user is supposed to have
access only to the definitions, but not to user data.

Consider for example pg_dump on a database with RLS enabled - if the
pg_statistic_ext catalog respects RLS (which it should, if it contains
user data), pg_dump would not see any records and the result would not
define any extended statistics.  That would be a surprising behavior.

Until now this was not a pressing issue, because the existing types of
extended statistic (functional dependencies and ndistinct coefficients)
do not include any user data directly.  This changed with introduction
of MCV lists, which do include most common combinations of values.

The easiest way to fix this is to split the pg_statistic_ext catalog
into two - one for definitions, one for the built statistic values.
The new catalog is called pg_statistic_ext_data, and we're maintaining
a 1:1 relationship with the old catalog - either there are matching
records in both catalogs, or neither of them.

Bumped CATVERSION due to changing system catalog definitions.

Author: Dean Rasheed, with improvements by me
Reviewed-by: Dean Rasheed, John Naylor
Discussion: https://postgr.es/m/CAEZATCUhT9rt7Ui%3DVdx4N%3D%3DVV5XOK5dsXfnGgVOz_JhAicB%3DZA%40mail.gmail.com
25 files changed:
doc/src/sgml/catalogs.sgml
doc/src/sgml/func.sgml
doc/src/sgml/perform.sgml
doc/src/sgml/planstats.sgml
src/backend/catalog/Makefile
src/backend/commands/statscmds.c
src/backend/optimizer/util/plancat.c
src/backend/statistics/README.mcv
src/backend/statistics/dependencies.c
src/backend/statistics/extended_stats.c
src/backend/statistics/mcv.c
src/backend/statistics/mvdistinct.c
src/backend/utils/cache/syscache.c
src/include/catalog/catversion.h
src/include/catalog/indexing.h
src/include/catalog/pg_statistic_ext.h
src/include/catalog/pg_statistic_ext_data.h [new file with mode: 0644]
src/include/catalog/toasting.h
src/include/utils/syscache.h
src/test/regress/expected/oidjoins.out
src/test/regress/expected/sanity_check.out
src/test/regress/expected/stats_ext.out
src/test/regress/sql/oidjoins.sql
src/test/regress/sql/stats_ext.sql
src/tools/pgindent/typedefs.list