Add pg_stats_ext view for extended statistics
authorTomas Vondra <tomas.vondra@postgresql.org>
Thu, 13 Jun 2019 15:25:04 +0000 (17:25 +0200)
committerTomas Vondra <tomas.vondra@postgresql.org>
Sat, 15 Jun 2019 23:20:39 +0000 (01:20 +0200)
commitaa087ec64f703a52f3c48c70117bb02e578f1802
tree1027f38d6120b6b3672d3795b30534124480e971
parent6cbfb784c3c91146148a76d50cda6f69ae6a79fb
Add pg_stats_ext view for extended statistics

Regular per-column statistics are stored in pg_statistics catalog, which
is however rather difficult to read, so we also have pg_stats view with
a human-reablable version of the data.

For extended statistic the catalog was fairly easy to read, so we did
not have such human-readable view so far.  Commit 9b6babfa2d however did
split the catalog into two, which makes querying harder.  Furthermore,
we want to show the multi-column MCV list in a way similar to per-column
stats (and not as a bytea value).

This commit introduces pg_stats_ext view, joining the two catalogs and
massaging the data to produce human-readable output similar to pg_stats.
It also considers RLS and access privileges - the data is shown only when
the user has access to all columns the extended statistic is defined on.

Bumped CATVERSION due to adding new system view.

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
doc/src/sgml/catalogs.sgml
src/backend/catalog/system_views.sql
src/include/catalog/catversion.h
src/test/regress/expected/rules.out