mirror of https://github.com/postgres/postgres
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.compull/47/head
parent
e3846a00c2
commit
6cbfb784c3
@ -0,0 +1,52 @@ |
||||
/*-------------------------------------------------------------------------
|
||||
* |
||||
* pg_statistic_ext_data.h |
||||
* definition of the "extended statistics data" system catalog |
||||
* (pg_statistic_ext_data) |
||||
* |
||||
* This catalog stores the statistical data for extended statistics objects. |
||||
* |
||||
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group |
||||
* Portions Copyright (c) 1994, Regents of the University of California |
||||
* |
||||
* src/include/catalog/pg_statistic_ext_data.h |
||||
* |
||||
* NOTES |
||||
* The Catalog.pm module reads this file and derives schema |
||||
* information. |
||||
* |
||||
*------------------------------------------------------------------------- |
||||
*/ |
||||
#ifndef PG_STATISTIC_EXT_DATA_H |
||||
#define PG_STATISTIC_EXT_DATA_H |
||||
|
||||
#include "catalog/genbki.h" |
||||
#include "catalog/pg_statistic_ext_data_d.h" |
||||
|
||||
/* ----------------
|
||||
* pg_statistic_ext_data definition. cpp turns this into |
||||
* typedef struct FormData_pg_statistic_ext_data |
||||
* ---------------- |
||||
*/ |
||||
CATALOG(pg_statistic_ext_data,3429,StatisticExtDataRelationId) |
||||
{ |
||||
Oid stxoid; /* statistics object this data is for */ |
||||
|
||||
#ifdef CATALOG_VARLEN /* variable-length fields start here */ |
||||
|
||||
pg_ndistinct stxdndistinct; /* ndistinct coefficients (serialized) */ |
||||
pg_dependencies stxddependencies; /* dependencies (serialized) */ |
||||
pg_mcv_list stxdmcv; /* MCV (serialized) */ |
||||
|
||||
#endif |
||||
|
||||
} FormData_pg_statistic_ext_data; |
||||
|
||||
/* ----------------
|
||||
* Form_pg_statistic_ext_data corresponds to a pointer to a tuple with |
||||
* the format of pg_statistic_ext_data relation. |
||||
* ---------------- |
||||
*/ |
||||
typedef FormData_pg_statistic_ext_data *Form_pg_statistic_ext_data; |
||||
|
||||
#endif /* PG_STATISTIC_EXT_DATA_H */ |
||||
Loading…
Reference in new issue