pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tomas Vondra <tomas.vondra@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Rework the pg_statistic_ext catalog
Date: Sat, 15 Jun 2019 23:21:16 +0000
Message-ID: <E1hcHz2-0005mY-5A@gemulon.postgresql.org> (raw)

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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6cbfb784c3c91146148a76d50cda6f69ae6a79fb

Modified Files
--------------
doc/src/sgml/catalogs.sgml                  | 70 ++++++++++++++++++++++-----
doc/src/sgml/func.sgml                      |  6 +--
doc/src/sgml/perform.sgml                   | 20 ++++----
doc/src/sgml/planstats.sgml                 |  4 +-
src/backend/catalog/Makefile                |  2 +-
src/backend/commands/statscmds.c            | 73 ++++++++++++++++++++++-------
src/backend/optimizer/util/plancat.c        | 12 +++--
src/backend/statistics/README.mcv           |  9 ++--
src/backend/statistics/dependencies.c       |  7 +--
src/backend/statistics/extended_stats.c     | 61 +++++++++++++-----------
src/backend/statistics/mcv.c                |  7 +--
src/backend/statistics/mvdistinct.c         |  7 +--
src/backend/utils/cache/syscache.c          | 12 +++++
src/include/catalog/catversion.h            |  2 +-
src/include/catalog/indexing.h              | 17 ++++---
src/include/catalog/pg_statistic_ext.h      |  9 ++--
src/include/catalog/pg_statistic_ext_data.h | 52 ++++++++++++++++++++
src/include/catalog/toasting.h              |  1 +
src/include/utils/syscache.h                |  1 +
src/test/regress/expected/oidjoins.out      |  8 ++++
src/test/regress/expected/sanity_check.out  |  1 +
src/test/regress/expected/stats_ext.out     | 38 ++++++++++-----
src/test/regress/sql/oidjoins.sql           |  4 ++
src/test/regress/sql/stats_ext.sql          | 30 ++++++++----
src/tools/pgindent/typedefs.list            |  2 +
25 files changed, 337 insertions(+), 118 deletions(-)



view thread (13+ messages)  latest in thread

Message-ID: <E1hcHz2-0005mY-5A@gemulon.postgresql.org>
Permalink:  ../E1hcHz2-0005mY-5A@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1hcHz2-0005mY-5A@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: tomas.vondra@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Rework the pg_statistic_ext catalog
  In-Reply-To: <E1hcHz2-0005mY-5A@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox